blob: 37d8a7532255af6fb589021d223e8ca454cfcb81 [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
DRC2ffcb8e2011-04-04 04:56:24 +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
DRC2ffcb8e2011-04-04 04:56:24 +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
DRCddcd5a12011-04-15 00:24:02 +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)
42option(WITH_JAVA "Build Java wrapper for the TurboJPEG/OSS library" FALSE)
DRC245cfdf2010-11-23 17:11:06 +000043
44if(WITH_ARITH_ENC)
45 set(C_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000046 message(STATUS "Arithmetic encoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000047else()
DRC990e28d2011-01-04 21:40:11 +000048 message(STATUS "Arithmetic encoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000049endif()
50
51if(WITH_ARITH_DEC)
52 set(D_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000053 message(STATUS "Arithmetic decoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000054else()
DRC990e28d2011-01-04 21:40:11 +000055 message(STATUS "Arithmetic decoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000056endif()
57
DRC957d6232011-04-01 11:13:11 +000058if(WITH_JAVA)
59 message(STATUS "TurboJPEG/OSS Java wrapper enabled")
DRC218c0c12011-02-05 06:01:18 +000060else()
DRC957d6232011-04-01 11:13:11 +000061 message(STATUS "TurboJPEG/OSS Java wrapper disabled")
DRC218c0c12011-02-05 06:01:18 +000062endif()
63
DRC84697032010-10-15 03:43:24 +000064set(JPEG_LIB_VERSION 62)
65set(DLL_VERSION ${JPEG_LIB_VERSION})
DRCa9d5b252010-10-15 06:42:45 +000066set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000067if(WITH_JPEG8)
68 set(JPEG_LIB_VERSION 80)
69 set(DLL_VERSION 8)
DRCa9d5b252010-10-15 06:42:45 +000070 set(FULLVERSION ${DLL_VERSION}.0.2)
DRCf38eee02011-02-18 07:00:38 +000071 message(STATUS "Emulating libjpeg v8 API/ABI")
DRC84697032010-10-15 03:43:24 +000072elseif(WITH_JPEG7)
73 set(JPEG_LIB_VERSION 70)
74 set(DLL_VERSION 7)
DRCa9d5b252010-10-15 06:42:45 +000075 set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000076 message(STATUS "Emulating libjpeg v7 API/ABI")
77endif(WITH_JPEG8)
78
79if(MSVC)
80 # Use the static C library for all build types
81 foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
DRC2e4d0442011-02-08 01:18:37 +000082 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
DRC84697032010-10-15 03:43:24 +000083 if(${var} MATCHES "/MD")
84 string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
85 endif()
86 endforeach()
87
88 add_definitions(-W3 -wd4996)
89endif()
90
91# Detect whether compiler is 64-bit
92if(MSVC AND CMAKE_CL_64)
93 set(SIMD_X86_64 1)
94 set(64BIT 1)
95elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
96 set(SIMD_X86_64 1)
97 set(64BIT 1)
98endif()
99
100if(64BIT)
101 message(STATUS "64-bit build")
102else()
103 message(STATUS "32-bit build")
104endif()
105
106configure_file(win/jconfig.h.in jconfig.h)
107configure_file(win/config.h.in config.h)
108
109include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
110
DRC957d6232011-04-01 11:13:11 +0000111if(WITH_JAVA)
112 find_package(Java)
113 find_package(JNI)
DRCdb425062011-04-03 06:10:18 +0000114 if(DEFINED JAVACFLAGS)
115 message(STATUS "Java compiler flags = ${JAVACFLAGS}")
116 endif()
DRC218c0c12011-02-05 06:01:18 +0000117endif()
118
DRC84697032010-10-15 03:43:24 +0000119
120#
121# Targets
122#
123
DRC245cfdf2010-11-23 17:11:06 +0000124set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
125 jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
126 jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
127 jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
128 jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
129 jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
130 jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
131
132if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
133 set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
134endif()
135
136if(WITH_ARITH_ENC)
137 set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
138endif()
139
140if(WITH_ARITH_DEC)
141 set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
142endif()
DRC84697032010-10-15 03:43:24 +0000143
144if(WITH_SIMD)
145 add_definitions(-DWITH_SIMD)
146 add_subdirectory(simd)
147 if(SIMD_X86_64)
148 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
149 else()
150 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
151 endif()
152 # This tells CMake that the "source" files haven't been generated yet
153 set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
154else()
155 set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
DRC6f4ba612010-10-16 21:27:38 +0000156 message(STATUS "Not using SIMD acceleration")
DRC84697032010-10-15 03:43:24 +0000157endif()
158
DRC957d6232011-04-01 11:13:11 +0000159if(WITH_JAVA)
160 add_subdirectory(java)
161endif()
162
DRC84697032010-10-15 03:43:24 +0000163add_subdirectory(sharedlib)
164
165add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
DRC84697032010-10-15 03:43:24 +0000166if(NOT MSVC)
167 set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
168endif()
169if(WITH_SIMD)
170 add_dependencies(jpeg-static simd)
171endif()
172
DRCda5220a2011-03-02 02:17:30 +0000173set(TURBOJPEG_SOURCES turbojpegl.c transupp.c)
DRC957d6232011-04-01 11:13:11 +0000174if(WITH_JAVA)
DRC218c0c12011-02-05 06:01:18 +0000175 set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
DRC957d6232011-04-01 11:13:11 +0000176 include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
DRC218c0c12011-02-05 06:01:18 +0000177endif()
178
179add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
DRC84697032010-10-15 03:43:24 +0000180set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
DRC389c4722011-02-06 18:48:13 +0000181if(MINGW)
182 set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
183endif()
DRC84697032010-10-15 03:43:24 +0000184target_link_libraries(turbojpeg jpeg-static)
185set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
186
187add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
DRCda5220a2011-03-02 02:17:30 +0000188 turbojpegl.c transupp.c)
DRC84697032010-10-15 03:43:24 +0000189if(NOT MSVC)
190 set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
191endif()
192if(WITH_SIMD)
193 add_dependencies(turbojpeg-static simd)
194endif()
195
196add_executable(jpegut jpegut.c)
197target_link_libraries(jpegut turbojpeg)
198
199add_executable(jpegut-static jpegut.c)
200target_link_libraries(jpegut-static turbojpeg-static)
201
DRC2e4d0442011-02-08 01:18:37 +0000202add_executable(jpgtest jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000203target_link_libraries(jpgtest turbojpeg)
204
DRC2e4d0442011-02-08 01:18:37 +0000205add_executable(jpgtest-static jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000206target_link_libraries(jpgtest-static turbojpeg-static)
207
208add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
209 rdtarga.c)
210set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
211 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
212target_link_libraries(cjpeg-static jpeg-static)
213
214add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
215 wrppm.c wrtarga.c)
216set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
217 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
218target_link_libraries(djpeg-static jpeg-static)
219
220add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
221target_link_libraries(jpegtran-static jpeg-static)
222
223add_executable(rdjpgcom rdjpgcom.c)
224
225add_executable(wrjpgcom rdjpgcom.c)
226
227
228#
229# Tests
230#
231
DRC957d6232011-04-01 11:13:11 +0000232if(MSVC_IDE)
233 set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
234else()
235 set(OBJDIR "")
236endif()
237
DRC84697032010-10-15 03:43:24 +0000238enable_testing()
DRC957d6232011-04-01 11:13:11 +0000239if(WITH_JAVA)
240add_test(TJUnitTest ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest)
241add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv)
242add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi)
243add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv)
244endif()
DRC84697032010-10-15 03:43:24 +0000245add_test(jpegut jpegut)
DRCfbb67472010-11-24 04:02:37 +0000246add_test(jpegut-yuv jpegut -yuv)
DRC84697032010-10-15 03:43:24 +0000247add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000248add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000249add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000250add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000251add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
252add_test(cjpeg-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000253add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
254if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000255add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000256else()
DRCb42a48c2010-10-18 01:06:36 +0000257add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000258endif()
DRCda5220a2011-03-02 02:17:30 +0000259add_test(cjpeg-int-gray sharedlib/cjpeg -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
260add_test(cjpeg-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimggray.jpg testoutgray.jpg)
DRC84697032010-10-15 03:43:24 +0000261add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000262add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000263add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000264add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000265add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
266if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000267add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000268else()
DRCb42a48c2010-10-18 01:06:36 +0000269add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000270endif()
DRC4852d282011-04-25 23:56:40 +0000271add_test(djpeg-int-1_2 sharedlib/djpeg -dct int -scale 1/2 -ppm -outfile testoutint1_2.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
272add_test(djpeg-int-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint1_2.ppm testoutint1_2.ppm)
273add_test(djpeg-fast-1_2 sharedlib/djpeg -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
274add_test(djpeg-fast-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst1_2.ppm testoutfst1_2.ppm)
275add_test(djpeg-int-1_4 sharedlib/djpeg -dct int -scale 1/4 -ppm -outfile testoutint1_4.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
276add_test(djpeg-int-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint1_4.ppm testoutint1_4.ppm)
277add_test(djpeg-fast-1_4 sharedlib/djpeg -dct fast -scale 1/4 -ppm -outfile testoutfst1_4.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
278add_test(djpeg-fast-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst1_4.ppm testoutfst1_4.ppm)
279add_test(djpeg-int-1_8 sharedlib/djpeg -dct int -scale 1/8 -ppm -outfile testoutint1_8.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
280add_test(djpeg-int-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint1_8.ppm testoutint1_8.ppm)
281add_test(djpeg-fast-1_8 sharedlib/djpeg -dct fast -scale 1/8 -ppm -outfile testoutfst1_8.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
282add_test(djpeg-fast-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst1_8.ppm testoutfst1_8.ppm)
DRC84697032010-10-15 03:43:24 +0000283add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000284add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000285add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000286add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000287add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000288add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000289if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000290add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
291add_test(cjpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000292add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
293add_test(jpegtran-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
294endif()
295if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000296add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
297add_test(djpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000298add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000299add_test(jpegtran-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000300endif()
DRC84697032010-10-15 03:43:24 +0000301add_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 +0000302add_test(jpegtran-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC84697032010-10-15 03:43:24 +0000303
304add_test(jpegut-static jpegut-static)
DRCfbb67472010-11-24 04:02:37 +0000305add_test(jpegut-static-yuv jpegut-static -yuv)
DRC84697032010-10-15 03:43:24 +0000306add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000307add_test(cjpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000308add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000309add_test(cjpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000310add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
311add_test(cjpeg-static-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000312add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
313if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000314add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000315else()
DRCb42a48c2010-10-18 01:06:36 +0000316add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000317endif()
DRCda5220a2011-03-02 02:17:30 +0000318add_test(cjpeg-static-int-gray cjpeg-static -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
319add_test(cjpeg-static-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimggray.jpg testoutgray.jpg)
DRC84697032010-10-15 03:43:24 +0000320add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000321add_test(djpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000322add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000323add_test(djpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000324add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
325if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000326add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000327else()
DRCb42a48c2010-10-18 01:06:36 +0000328add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000329endif()
DRC4852d282011-04-25 23:56:40 +0000330add_test(djpeg-static-int-1_2 djpeg-static -dct int -scale 1/2 -ppm -outfile testoutint1_2.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
331add_test(djpeg-static-int-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint1_2.ppm testoutint1_2.ppm)
332add_test(djpeg-static-fast-1_2 djpeg-static -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
333add_test(djpeg-static-fast-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst1_2.ppm testoutfst1_2.ppm)
334add_test(djpeg-static-int-1_4 djpeg-static -dct int -scale 1/4 -ppm -outfile testoutint1_4.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
335add_test(djpeg-static-int-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint1_4.ppm testoutint1_4.ppm)
336add_test(djpeg-static-fast-1_4 djpeg-static -dct fast -scale 1/4 -ppm -outfile testoutfst1_4.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
337add_test(djpeg-static-fast-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst1_4.ppm testoutfst1_4.ppm)
338add_test(djpeg-static-int-1_8 djpeg-static -dct int -scale 1/8 -ppm -outfile testoutint1_8.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
339add_test(djpeg-static-int-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint1_8.ppm testoutint1_8.ppm)
340add_test(djpeg-static-fast-1_8 djpeg-static -dct fast -scale 1/8 -ppm -outfile testoutfst1_8.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
341add_test(djpeg-static-fast-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst1_8.ppm testoutfst1_8.ppm)
DRC84697032010-10-15 03:43:24 +0000342add_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 +0000343add_test(djpeg-static-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000344add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000345add_test(cjpeg-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000346add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000347add_test(jpegtran-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000348if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000349add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
350add_test(cjpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000351add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
352add_test(jpegtran-static-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
353endif()
354if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000355add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
356add_test(djpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000357add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000358add_test(jpegtran-static-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000359endif()
DRC84697032010-10-15 03:43:24 +0000360add_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 +0000361add_test(jpegtran-static-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC2c0a4e12010-10-16 08:51:43 +0000362
DRCa0f878a2011-04-02 04:43:14 +0000363add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
364 ${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
365
DRC2c0a4e12010-10-16 08:51:43 +0000366
367#
368# Installer
369#
370
DRC2c0a4e12010-10-16 08:51:43 +0000371if(MSVC)
372 set(INST_PLATFORM "Visual C++")
DRCb94f2de2011-03-22 09:31:25 +0000373 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-vc)
374 set(INST_DIR ${CMAKE_PROJECT_NAME})
DRC2c0a4e12010-10-16 08:51:43 +0000375elseif(MINGW)
376 set(INST_PLATFORM GCC)
DRCb94f2de2011-03-22 09:31:25 +0000377 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-gcc)
378 set(INST_DIR ${CMAKE_PROJECT_NAME}-gcc)
DRC2c0a4e12010-10-16 08:51:43 +0000379 set(INST_DEFS -DGCC)
380endif()
381
382if(64BIT)
383 set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
384 set(INST_NAME ${INST_NAME}64)
DRCb94f2de2011-03-22 09:31:25 +0000385 set(INST_DIR ${INST_DIR}64)
DRC2c0a4e12010-10-16 08:51:43 +0000386 set(INST_DEFS ${INST_DEFS} -DWIN64)
387endif()
388
DRC957d6232011-04-01 11:13:11 +0000389if(WITH_JAVA)
390 set(INST_DEFS ${INST_DEFS} -DJAVA)
391endif()
392
DRC2c0a4e12010-10-16 08:51:43 +0000393if(MSVC_IDE)
DRC926e01f2011-04-06 06:35:38 +0000394 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
DRC2c0a4e12010-10-16 08:51:43 +0000395else()
396 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
397endif()
398
399configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
400
401add_custom_target(installer
402 makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
DRCb94f2de2011-03-22 09:31:25 +0000403 DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
404 cjpeg djpeg jpegtran jpgtest
DRC2c0a4e12010-10-16 08:51:43 +0000405 SOURCES libjpeg-turbo.nsi)
DRC7284c9a2010-10-16 21:55:14 +0000406
DRC8569c2f2011-02-18 23:49:42 +0000407install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom jpgtest
DRC7284c9a2010-10-16 21:55:14 +0000408 ARCHIVE DESTINATION lib
409 LIBRARY DESTINATION lib
410 RUNTIME DESTINATION bin
411)
412
413install(FILES ${CMAKE_SOURCE_DIR}/LGPL.txt ${CMAKE_SOURCE_DIR}/LICENSE.txt
414 ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
415 ${CMAKE_SOURCE_DIR}/libjpeg.txt ${CMAKE_SOURCE_DIR}/usage.txt
416 DESTINATION doc)
DRCe2befde2010-10-17 07:28:08 +0000417
418install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
419 ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
420 ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)