blob: 74ec2a3253fbe814f10f651cfabc6dafa9dc960c [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)
DRC0caa0b42011-02-06 16:11:41 +00008set(VERSION 1.1.90)
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
21if(NOT CMAKE_BUILD_TYPE)
22 set(CMAKE_BUILD_TYPE Release)
23endif()
24
25message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
26
27# This only works if building from the command line. There is currently no way
28# to set a variable's value based on the build type when using the MSVC IDE.
29if(CMAKE_BUILD_TYPE STREQUAL "Debug")
30 set(BUILD "${BUILD}d")
31endif()
32
DRCeb2b9d62010-10-15 04:55:13 +000033message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
34
DRC84697032010-10-15 03:43:24 +000035if(NOT DEFINED WITH_SIMD)
36 set(WITH_SIMD 1)
37endif()
38
DRC245cfdf2010-11-23 17:11:06 +000039if(NOT DEFINED WITH_ARITH_ENC)
40 set(WITH_ARITH_ENC 1)
41endif()
42
43if(NOT DEFINED WITH_ARITH_DEC)
44 set(WITH_ARITH_DEC 1)
45endif()
46
47if(WITH_ARITH_ENC)
48 set(C_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000049 message(STATUS "Arithmetic encoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000050else()
DRC990e28d2011-01-04 21:40:11 +000051 message(STATUS "Arithmetic encoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000052endif()
53
54if(WITH_ARITH_DEC)
55 set(D_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000056 message(STATUS "Arithmetic decoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000057else()
DRC990e28d2011-01-04 21:40:11 +000058 message(STATUS "Arithmetic decoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000059endif()
60
DRC218c0c12011-02-05 06:01:18 +000061if(NOT DEFINED WITH_JNI)
62 set(WITH_JNI 0)
63endif()
64
65if(WITH_JNI)
66 message(STATUS "TurboJPEG/OSS JNI wrapper enabled")
67else()
68 message(STATUS "TurboJPEG/OSS JNI wrapper disabled")
69endif()
70
DRC84697032010-10-15 03:43:24 +000071set(JPEG_LIB_VERSION 62)
72set(DLL_VERSION ${JPEG_LIB_VERSION})
DRCa9d5b252010-10-15 06:42:45 +000073set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000074if(WITH_JPEG8)
75 set(JPEG_LIB_VERSION 80)
76 set(DLL_VERSION 8)
DRCa9d5b252010-10-15 06:42:45 +000077 set(FULLVERSION ${DLL_VERSION}.0.2)
DRCf38eee02011-02-18 07:00:38 +000078 message(STATUS "Emulating libjpeg v8 API/ABI")
DRC84697032010-10-15 03:43:24 +000079elseif(WITH_JPEG7)
80 set(JPEG_LIB_VERSION 70)
81 set(DLL_VERSION 7)
DRCa9d5b252010-10-15 06:42:45 +000082 set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000083 message(STATUS "Emulating libjpeg v7 API/ABI")
84endif(WITH_JPEG8)
85
86if(MSVC)
87 # Use the static C library for all build types
88 foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
DRC2e4d0442011-02-08 01:18:37 +000089 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
DRC84697032010-10-15 03:43:24 +000090 if(${var} MATCHES "/MD")
91 string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
92 endif()
93 endforeach()
94
95 add_definitions(-W3 -wd4996)
96endif()
97
98# Detect whether compiler is 64-bit
99if(MSVC AND CMAKE_CL_64)
100 set(SIMD_X86_64 1)
101 set(64BIT 1)
102elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
103 set(SIMD_X86_64 1)
104 set(64BIT 1)
105endif()
106
107if(64BIT)
108 message(STATUS "64-bit build")
109else()
110 message(STATUS "32-bit build")
111endif()
112
113configure_file(win/jconfig.h.in jconfig.h)
114configure_file(win/config.h.in config.h)
115
116include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
117
DRC218c0c12011-02-05 06:01:18 +0000118if(WITH_JNI)
119 include(CheckIncludeFiles)
120 check_include_files(jni.h HAVE_JNI_H)
121 if(NOT HAVE_JNI_H)
122 message(FATAL_ERROR "Cannot find jni.h. Be sure to add the Java include directories to the INCLUDE environment variable (MSVC) or the CPATH environment variable (GCC).")
123 endif()
124endif()
125
DRC84697032010-10-15 03:43:24 +0000126
127#
128# Targets
129#
130
DRC245cfdf2010-11-23 17:11:06 +0000131set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
132 jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
133 jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
134 jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
135 jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
136 jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
137 jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
138
139if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
140 set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
141endif()
142
143if(WITH_ARITH_ENC)
144 set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
145endif()
146
147if(WITH_ARITH_DEC)
148 set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
149endif()
DRC84697032010-10-15 03:43:24 +0000150
151if(WITH_SIMD)
152 add_definitions(-DWITH_SIMD)
153 add_subdirectory(simd)
154 if(SIMD_X86_64)
155 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
156 else()
157 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
158 endif()
159 # This tells CMake that the "source" files haven't been generated yet
160 set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
161else()
162 set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
DRC6f4ba612010-10-16 21:27:38 +0000163 message(STATUS "Not using SIMD acceleration")
DRC84697032010-10-15 03:43:24 +0000164endif()
165
166add_subdirectory(sharedlib)
167
168add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
DRC84697032010-10-15 03:43:24 +0000169if(NOT MSVC)
170 set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
171endif()
172if(WITH_SIMD)
173 add_dependencies(jpeg-static simd)
174endif()
175
DRCda5220a2011-03-02 02:17:30 +0000176set(TURBOJPEG_SOURCES turbojpegl.c transupp.c)
DRC218c0c12011-02-05 06:01:18 +0000177if(WITH_JNI)
178 set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
179endif()
180
181add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
DRC84697032010-10-15 03:43:24 +0000182set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
DRC389c4722011-02-06 18:48:13 +0000183if(MINGW)
184 set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
185endif()
DRC84697032010-10-15 03:43:24 +0000186target_link_libraries(turbojpeg jpeg-static)
187set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
188
189add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
DRCda5220a2011-03-02 02:17:30 +0000190 turbojpegl.c transupp.c)
DRC84697032010-10-15 03:43:24 +0000191if(NOT MSVC)
192 set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
193endif()
194if(WITH_SIMD)
195 add_dependencies(turbojpeg-static simd)
196endif()
197
198add_executable(jpegut jpegut.c)
199target_link_libraries(jpegut turbojpeg)
200
201add_executable(jpegut-static jpegut.c)
202target_link_libraries(jpegut-static turbojpeg-static)
203
DRC2e4d0442011-02-08 01:18:37 +0000204add_executable(jpgtest jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000205target_link_libraries(jpgtest turbojpeg)
206
DRC2e4d0442011-02-08 01:18:37 +0000207add_executable(jpgtest-static jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000208target_link_libraries(jpgtest-static turbojpeg-static)
209
210add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
211 rdtarga.c)
212set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
213 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
214target_link_libraries(cjpeg-static jpeg-static)
215
216add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
217 wrppm.c wrtarga.c)
218set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
219 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
220target_link_libraries(djpeg-static jpeg-static)
221
222add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
223target_link_libraries(jpegtran-static jpeg-static)
224
225add_executable(rdjpgcom rdjpgcom.c)
226
227add_executable(wrjpgcom rdjpgcom.c)
228
229
230#
231# Tests
232#
233
234enable_testing()
235add_test(jpegut jpegut)
DRCfbb67472010-11-24 04:02:37 +0000236add_test(jpegut-yuv jpegut -yuv)
DRC84697032010-10-15 03:43:24 +0000237add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000238add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000239add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000240add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000241add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
242add_test(cjpeg-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000243add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
244if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000245add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000246else()
DRCb42a48c2010-10-18 01:06:36 +0000247add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000248endif()
DRCda5220a2011-03-02 02:17:30 +0000249add_test(cjpeg-int-gray sharedlib/cjpeg -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
250add_test(cjpeg-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimggray.jpg testoutgray.jpg)
DRC84697032010-10-15 03:43:24 +0000251add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000252add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000253add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000254add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000255add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
256if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000257add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000258else()
DRCb42a48c2010-10-18 01:06:36 +0000259add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000260endif()
261add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000262add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000263add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000264add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000265add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000266add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000267if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000268add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
269add_test(cjpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000270add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
271add_test(jpegtran-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
272endif()
273if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000274add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
275add_test(djpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000276add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000277add_test(jpegtran-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000278endif()
DRC84697032010-10-15 03:43:24 +0000279add_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 +0000280add_test(jpegtran-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC84697032010-10-15 03:43:24 +0000281
282add_test(jpegut-static jpegut-static)
DRCfbb67472010-11-24 04:02:37 +0000283add_test(jpegut-static-yuv jpegut-static -yuv)
DRC84697032010-10-15 03:43:24 +0000284add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000285add_test(cjpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000286add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000287add_test(cjpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000288add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
289add_test(cjpeg-static-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000290add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
291if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000292add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000293else()
DRCb42a48c2010-10-18 01:06:36 +0000294add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000295endif()
DRCda5220a2011-03-02 02:17:30 +0000296add_test(cjpeg-static-int-gray cjpeg-static -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
297add_test(cjpeg-static-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimggray.jpg testoutgray.jpg)
DRC84697032010-10-15 03:43:24 +0000298add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000299add_test(djpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000300add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000301add_test(djpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000302add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
303if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000304add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000305else()
DRCb42a48c2010-10-18 01:06:36 +0000306add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000307endif()
308add_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 +0000309add_test(djpeg-static-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000310add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000311add_test(cjpeg-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000312add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000313add_test(jpegtran-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000314if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000315add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
316add_test(cjpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000317add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
318add_test(jpegtran-static-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
319endif()
320if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000321add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
322add_test(djpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000323add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000324add_test(jpegtran-static-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000325endif()
DRC84697032010-10-15 03:43:24 +0000326add_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 +0000327add_test(jpegtran-static-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC2c0a4e12010-10-16 08:51:43 +0000328
329
330#
331# Installer
332#
333
334set(INST_NAME ${CMAKE_PROJECT_NAME})
335
336if(MSVC)
337 set(INST_PLATFORM "Visual C++")
338elseif(MINGW)
339 set(INST_PLATFORM GCC)
340 set(INST_NAME ${INST_NAME}-gcc)
341 set(INST_DEFS -DGCC)
342endif()
343
344if(64BIT)
345 set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
346 set(INST_NAME ${INST_NAME}64)
347 set(INST_DEFS ${INST_DEFS} -DWIN64)
348endif()
349
350if(MSVC_IDE)
351 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=$(OutDir)\\")
352else()
353 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
354endif()
355
356configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
357
358add_custom_target(installer
359 makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
360 DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static
361 SOURCES libjpeg-turbo.nsi)
DRC7284c9a2010-10-16 21:55:14 +0000362
DRC8569c2f2011-02-18 23:49:42 +0000363install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom jpgtest
DRC7284c9a2010-10-16 21:55:14 +0000364 ARCHIVE DESTINATION lib
365 LIBRARY DESTINATION lib
366 RUNTIME DESTINATION bin
367)
368
369install(FILES ${CMAKE_SOURCE_DIR}/LGPL.txt ${CMAKE_SOURCE_DIR}/LICENSE.txt
370 ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
371 ${CMAKE_SOURCE_DIR}/libjpeg.txt ${CMAKE_SOURCE_DIR}/usage.txt
372 DESTINATION doc)
DRCe2befde2010-10-17 07:28:08 +0000373
374install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
375 ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
376 ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)