blob: 28f8e000897306df80eda664f42a114942dbe6cf [file] [log] [blame]
DRC84697032010-10-15 03:43:24 +00001#
2# Setup
3#
4
5cmake_minimum_required(VERSION 2.6)
6
DRC5d6f8582011-02-18 23:08:58 +00007project(libjpeg-turbo C)
DRCcf137ac2011-05-31 20:23:07 +00008set(VERSION 1.1.2)
DRC84697032010-10-15 03:43:24 +00009
DRC378da4d2010-10-15 19:11:11 +000010if(MINGW OR CYGWIN)
DRC84697032010-10-15 03:43:24 +000011 execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
12 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
13elseif(WIN32)
14 execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat"
15 OUTPUT_VARIABLE BUILD)
16 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
17else()
DRC378da4d2010-10-15 19:11:11 +000018 message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
DRC84697032010-10-15 03:43:24 +000019endif()
20
DRC760ea8d2012-02-07 23:25:19 +000021# This does nothing except when using MinGW. CMAKE_BUILD_TYPE has no meaning
22# in Visual Studio, and it always defaults to Debug when using NMake.
DRC84697032010-10-15 03:43:24 +000023if(NOT CMAKE_BUILD_TYPE)
24 set(CMAKE_BUILD_TYPE Release)
25endif()
26
27message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
28
29# This only works if building from the command line. There is currently no way
DRC760ea8d2012-02-07 23:25:19 +000030# to set a variable's value based on the build type when using Visual Studio.
DRC84697032010-10-15 03:43:24 +000031if(CMAKE_BUILD_TYPE STREQUAL "Debug")
32 set(BUILD "${BUILD}d")
33endif()
34
DRCeb2b9d62010-10-15 04:55:13 +000035message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
36
DRC98b85292011-04-15 00:20:15 +000037option(WITH_SIMD "Include SIMD extensions" TRUE)
38option(WITH_ARITH_ENC "Include arithmetic encoding support" TRUE)
39option(WITH_ARITH_DEC "Include arithmetic decoding support" TRUE)
40option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
41option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
DRC245cfdf2010-11-23 17:11:06 +000042
43if(WITH_ARITH_ENC)
44 set(C_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000045 message(STATUS "Arithmetic encoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000046else()
DRC990e28d2011-01-04 21:40:11 +000047 message(STATUS "Arithmetic encoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000048endif()
49
50if(WITH_ARITH_DEC)
51 set(D_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000052 message(STATUS "Arithmetic decoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000053else()
DRC990e28d2011-01-04 21:40:11 +000054 message(STATUS "Arithmetic decoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000055endif()
56
DRC84697032010-10-15 03:43:24 +000057set(JPEG_LIB_VERSION 62)
58set(DLL_VERSION ${JPEG_LIB_VERSION})
DRCa9d5b252010-10-15 06:42:45 +000059set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000060if(WITH_JPEG8)
61 set(JPEG_LIB_VERSION 80)
62 set(DLL_VERSION 8)
DRCa9d5b252010-10-15 06:42:45 +000063 set(FULLVERSION ${DLL_VERSION}.0.2)
DRCf38eee02011-02-18 07:00:38 +000064 message(STATUS "Emulating libjpeg v8 API/ABI")
DRC84697032010-10-15 03:43:24 +000065elseif(WITH_JPEG7)
66 set(JPEG_LIB_VERSION 70)
67 set(DLL_VERSION 7)
DRCa9d5b252010-10-15 06:42:45 +000068 set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000069 message(STATUS "Emulating libjpeg v7 API/ABI")
70endif(WITH_JPEG8)
71
72if(MSVC)
73 # Use the static C library for all build types
74 foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
DRC2e4d0442011-02-08 01:18:37 +000075 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
DRC84697032010-10-15 03:43:24 +000076 if(${var} MATCHES "/MD")
77 string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
78 endif()
79 endforeach()
80
81 add_definitions(-W3 -wd4996)
82endif()
83
84# Detect whether compiler is 64-bit
85if(MSVC AND CMAKE_CL_64)
86 set(SIMD_X86_64 1)
87 set(64BIT 1)
88elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
89 set(SIMD_X86_64 1)
90 set(64BIT 1)
91endif()
92
93if(64BIT)
94 message(STATUS "64-bit build")
95else()
96 message(STATUS "32-bit build")
97endif()
98
99configure_file(win/jconfig.h.in jconfig.h)
100configure_file(win/config.h.in config.h)
101
102include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
103
104
105#
106# Targets
107#
108
DRC245cfdf2010-11-23 17:11:06 +0000109set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
110 jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
111 jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
112 jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
113 jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
114 jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
115 jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
116
117if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
118 set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
119endif()
120
121if(WITH_ARITH_ENC)
122 set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
123endif()
124
125if(WITH_ARITH_DEC)
126 set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
127endif()
DRC84697032010-10-15 03:43:24 +0000128
129if(WITH_SIMD)
130 add_definitions(-DWITH_SIMD)
131 add_subdirectory(simd)
132 if(SIMD_X86_64)
133 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
134 else()
135 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
136 endif()
137 # This tells CMake that the "source" files haven't been generated yet
138 set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
139else()
140 set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
DRC6f4ba612010-10-16 21:27:38 +0000141 message(STATUS "Not using SIMD acceleration")
DRC84697032010-10-15 03:43:24 +0000142endif()
143
144add_subdirectory(sharedlib)
145
146add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
DRC84697032010-10-15 03:43:24 +0000147if(NOT MSVC)
148 set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
149endif()
150if(WITH_SIMD)
151 add_dependencies(jpeg-static simd)
152endif()
153
154add_library(turbojpeg SHARED turbojpegl.c)
155set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
156target_link_libraries(turbojpeg jpeg-static)
157set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
158
159add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
160 turbojpegl.c)
DRC84697032010-10-15 03:43:24 +0000161if(NOT MSVC)
162 set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
163endif()
164if(WITH_SIMD)
165 add_dependencies(turbojpeg-static simd)
166endif()
167
168add_executable(jpegut jpegut.c)
169target_link_libraries(jpegut turbojpeg)
170
171add_executable(jpegut-static jpegut.c)
172target_link_libraries(jpegut-static turbojpeg-static)
173
DRC2e4d0442011-02-08 01:18:37 +0000174add_executable(jpgtest jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000175target_link_libraries(jpgtest turbojpeg)
176
DRC2e4d0442011-02-08 01:18:37 +0000177add_executable(jpgtest-static jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000178target_link_libraries(jpgtest-static turbojpeg-static)
179
180add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
181 rdtarga.c)
182set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
DRC5ee81f42011-05-02 00:35:50 +0000183 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000184target_link_libraries(cjpeg-static jpeg-static)
185
186add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
187 wrppm.c wrtarga.c)
188set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
DRC5ee81f42011-05-02 00:35:50 +0000189 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000190target_link_libraries(djpeg-static jpeg-static)
191
192add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
193target_link_libraries(jpegtran-static jpeg-static)
DRC7e3fd2f2011-05-25 06:04:43 +0000194set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000195
196add_executable(rdjpgcom rdjpgcom.c)
197
198add_executable(wrjpgcom rdjpgcom.c)
199
200
201#
202# Tests
203#
204
205enable_testing()
206add_test(jpegut jpegut)
DRCfbb67472010-11-24 04:02:37 +0000207add_test(jpegut-yuv jpegut -yuv)
DRC84697032010-10-15 03:43:24 +0000208add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000209add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000210add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000211add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000212add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
213add_test(cjpeg-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000214add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
215if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000216add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000217else()
DRCb42a48c2010-10-18 01:06:36 +0000218add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000219endif()
220add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000221add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000222add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000223add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000224add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
225if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000226add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000227else()
DRCb42a48c2010-10-18 01:06:36 +0000228add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000229endif()
230add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000231add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000232add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000233add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000234add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000235add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000236if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000237add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
238add_test(cjpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000239add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
240add_test(jpegtran-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
241endif()
242if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000243add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
244add_test(djpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000245add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000246add_test(jpegtran-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000247endif()
DRC84697032010-10-15 03:43:24 +0000248add_test(jpegtran-crop sharedlib/jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000249add_test(jpegtran-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC84697032010-10-15 03:43:24 +0000250
251add_test(jpegut-static jpegut-static)
DRCfbb67472010-11-24 04:02:37 +0000252add_test(jpegut-static-yuv jpegut-static -yuv)
DRC84697032010-10-15 03:43:24 +0000253add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000254add_test(cjpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000255add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000256add_test(cjpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000257add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
258add_test(cjpeg-static-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000259add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
260if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000261add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000262else()
DRCb42a48c2010-10-18 01:06:36 +0000263add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000264endif()
265add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000266add_test(djpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000267add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000268add_test(djpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000269add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
270if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000271add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000272else()
DRCb42a48c2010-10-18 01:06:36 +0000273add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000274endif()
275add_test(djpeg-static-256 djpeg-static -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000276add_test(djpeg-static-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000277add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000278add_test(cjpeg-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000279add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000280add_test(jpegtran-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000281if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000282add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
283add_test(cjpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000284add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
285add_test(jpegtran-static-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
286endif()
287if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000288add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
289add_test(djpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000290add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000291add_test(jpegtran-static-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000292endif()
DRC84697032010-10-15 03:43:24 +0000293add_test(jpegtran-static-crop jpegtran-static -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000294add_test(jpegtran-static-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC2c0a4e12010-10-16 08:51:43 +0000295
296
297#
298# Installer
299#
300
DRC2c0a4e12010-10-16 08:51:43 +0000301if(MSVC)
302 set(INST_PLATFORM "Visual C++")
DRC1c87e452011-03-22 06:49:31 +0000303 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-vc)
304 set(INST_DIR ${CMAKE_PROJECT_NAME})
DRC2c0a4e12010-10-16 08:51:43 +0000305elseif(MINGW)
306 set(INST_PLATFORM GCC)
DRC1c87e452011-03-22 06:49:31 +0000307 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-gcc)
308 set(INST_DIR ${CMAKE_PROJECT_NAME}-gcc)
DRC2c0a4e12010-10-16 08:51:43 +0000309 set(INST_DEFS -DGCC)
310endif()
311
312if(64BIT)
313 set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
314 set(INST_NAME ${INST_NAME}64)
DRC1c87e452011-03-22 06:49:31 +0000315 set(INST_DIR ${INST_DIR}64)
DRC2c0a4e12010-10-16 08:51:43 +0000316 set(INST_DEFS ${INST_DEFS} -DWIN64)
317endif()
318
319if(MSVC_IDE)
DRC926e01f2011-04-06 06:35:38 +0000320 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
DRC2c0a4e12010-10-16 08:51:43 +0000321else()
322 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
323endif()
324
325configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
326
327add_custom_target(installer
328 makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
DRC95db4f42011-03-22 00:20:43 +0000329 DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
330 cjpeg djpeg jpegtran jpgtest
DRC2c0a4e12010-10-16 08:51:43 +0000331 SOURCES libjpeg-turbo.nsi)
DRC7284c9a2010-10-16 21:55:14 +0000332
DRC8569c2f2011-02-18 23:49:42 +0000333install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom jpgtest
DRC7284c9a2010-10-16 21:55:14 +0000334 ARCHIVE DESTINATION lib
335 LIBRARY DESTINATION lib
336 RUNTIME DESTINATION bin
337)
338
339install(FILES ${CMAKE_SOURCE_DIR}/LGPL.txt ${CMAKE_SOURCE_DIR}/LICENSE.txt
340 ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
341 ${CMAKE_SOURCE_DIR}/libjpeg.txt ${CMAKE_SOURCE_DIR}/usage.txt
342 DESTINATION doc)
DRCe2befde2010-10-17 07:28:08 +0000343
344install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
345 ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
346 ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)