blob: 112d30c950514ebb8933ce3dadad010586ff9922 [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)
DRCbf0bdac2012-01-27 22:12:49 +00008set(VERSION 1.2.80)
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
DRC418dbdf2011-05-26 10:45:06 +0000173set(TURBOJPEG_SOURCES turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.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}
DRC418dbdf2011-05-26 10:45:06 +0000188 turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.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
DRC3185cb92011-05-25 03:52:22 +0000196add_executable(tjunittest tjunittest.c tjutil.c)
197target_link_libraries(tjunittest turbojpeg)
DRC84697032010-10-15 03:43:24 +0000198
DRC3185cb92011-05-25 03:52:22 +0000199add_executable(tjunittest-static tjunittest.c tjutil.c)
200target_link_libraries(tjunittest-static turbojpeg-static)
DRC84697032010-10-15 03:43:24 +0000201
DRC3185cb92011-05-25 03:52:22 +0000202add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
DRC43484642011-05-24 17:03:51 +0000203 wrppm.c)
DRC4ad60032011-09-20 05:41:54 +0000204target_link_libraries(tjbench turbojpeg jpeg-static)
DRC3185cb92011-05-25 03:52:22 +0000205set_property(TARGET tjbench PROPERTY COMPILE_FLAGS
DRC43484642011-05-24 17:03:51 +0000206 "-DBMP_SUPPORTED -DPPM_SUPPORTED")
DRC84697032010-10-15 03:43:24 +0000207
DRC3185cb92011-05-25 03:52:22 +0000208add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
DRC43484642011-05-24 17:03:51 +0000209 wrppm.c)
DRC3185cb92011-05-25 03:52:22 +0000210target_link_libraries(tjbench-static turbojpeg-static jpeg-static)
211set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS
DRC43484642011-05-24 17:03:51 +0000212 "-DBMP_SUPPORTED -DPPM_SUPPORTED")
DRC84697032010-10-15 03:43:24 +0000213
214add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
215 rdtarga.c)
216set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
DRC5ee81f42011-05-02 00:35:50 +0000217 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000218target_link_libraries(cjpeg-static jpeg-static)
219
220add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
221 wrppm.c wrtarga.c)
222set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
DRC5ee81f42011-05-02 00:35:50 +0000223 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000224target_link_libraries(djpeg-static jpeg-static)
225
226add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
227target_link_libraries(jpegtran-static jpeg-static)
DRC7e3fd2f2011-05-25 06:04:43 +0000228set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000229
230add_executable(rdjpgcom rdjpgcom.c)
231
232add_executable(wrjpgcom rdjpgcom.c)
233
234
235#
236# Tests
237#
238
DRC957d6232011-04-01 11:13:11 +0000239if(MSVC_IDE)
240 set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
241else()
242 set(OBJDIR "")
243endif()
244
DRC84697032010-10-15 03:43:24 +0000245enable_testing()
DRC957d6232011-04-01 11:13:11 +0000246if(WITH_JAVA)
247add_test(TJUnitTest ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest)
248add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv)
249add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi)
250add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv)
251endif()
DRC3185cb92011-05-25 03:52:22 +0000252add_test(tjunittest tjunittest)
253add_test(tjunittest-alloc tjunittest -alloc)
254add_test(tjunittest-yuv tjunittest -yuv)
DRC7ab03642012-01-31 05:47:07 +0000255add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
256add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutint.jpg)
257add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
258add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.jpg testoutfst.jpg)
259add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
260add_test(cjpeg-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst100.jpg testoutfst100.jpg)
261add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
DRC84697032010-10-15 03:43:24 +0000262if(WITH_SIMD)
DRC7ab03642012-01-31 05:47:07 +0000263add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000264else()
DRC7ab03642012-01-31 05:47:07 +0000265add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000266endif()
DRC7ab03642012-01-31 05:47:07 +0000267add_test(cjpeg-int-gray sharedlib/cjpeg -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
268add_test(cjpeg-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimggray.jpg testoutgray.jpg)
269add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
270add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.ppm testoutint.ppm)
271add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
272add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.ppm testoutfst.ppm)
273add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
DRC84697032010-10-15 03:43:24 +0000274if(WITH_SIMD)
DRC7ab03642012-01-31 05:47:07 +0000275add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000276else()
DRC7ab03642012-01-31 05:47:07 +0000277add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000278endif()
DRC0af8d672012-01-31 11:09:11 +0000279foreach(scale 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8)
280string(REGEX REPLACE "_" "/" scalearg ${scale})
281add_test(djpeg-int-${scale} sharedlib/djpeg -dct int -scale ${scalearg} -ppm -outfile testoutint${scale}.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
282add_test(djpeg-int-${scale}-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint${scale}.ppm testoutint${scale}.ppm)
283endforeach()
DRC7ab03642012-01-31 05:47:07 +0000284add_test(djpeg-fast-1_2 sharedlib/djpeg -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
285add_test(djpeg-fast-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_2.ppm testoutfst1_2.ppm)
DRC7ab03642012-01-31 05:47:07 +0000286add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
287add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimg.bmp testout.bmp)
288add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
289add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000290add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg)
DRC7ab03642012-01-31 05:47:07 +0000291add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000292if(WITH_ARITH_ENC)
DRC7ab03642012-01-31 05:47:07 +0000293add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
294add_test(cjpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testoutari.jpg)
295add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg)
296add_test(jpegtran-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000297endif()
298if(WITH_ARITH_DEC)
DRC7ab03642012-01-31 05:47:07 +0000299add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
300add_test(djpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.ppm testoutari.ppm)
301add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
302add_test(jpegtran-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000303endif()
DRC7ab03642012-01-31 05:47:07 +0000304add_test(jpegtran-crop sharedlib/jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
305add_test(jpegtran-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgcrop.jpg testoutcrop.jpg)
DRC84697032010-10-15 03:43:24 +0000306
DRC3185cb92011-05-25 03:52:22 +0000307add_test(tjunittest-static tjunittest-static)
308add_test(tjunittest-static-alloc tjunittest-static -alloc)
309add_test(tjunittest-static-yuv tjunittest-static -yuv)
DRC7ab03642012-01-31 05:47:07 +0000310add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
311add_test(cjpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutint.jpg)
312add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
313add_test(cjpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.jpg testoutfst.jpg)
314add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
315add_test(cjpeg-static-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst100.jpg testoutfst100.jpg)
316add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
DRC84697032010-10-15 03:43:24 +0000317if(WITH_SIMD)
DRC7ab03642012-01-31 05:47:07 +0000318add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000319else()
DRC7ab03642012-01-31 05:47:07 +0000320add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000321endif()
DRC7ab03642012-01-31 05:47:07 +0000322add_test(cjpeg-static-int-gray cjpeg-static -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
323add_test(cjpeg-static-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimggray.jpg testoutgray.jpg)
324add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
325add_test(djpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.ppm testoutint.ppm)
326add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
327add_test(djpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.ppm testoutfst.ppm)
328add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
DRC84697032010-10-15 03:43:24 +0000329if(WITH_SIMD)
DRC7ab03642012-01-31 05:47:07 +0000330add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000331else()
DRC7ab03642012-01-31 05:47:07 +0000332add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000333endif()
DRC0af8d672012-01-31 11:09:11 +0000334foreach(scale 2_1 15_8 7_4 13_8 3_2 11_8 5_4 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8)
335string(REGEX REPLACE "_" "/" scalearg ${scale})
336add_test(djpeg-static-int-${scale} djpeg-static -dct int -scale ${scalearg} -ppm -outfile testoutint${scale}.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
337add_test(djpeg-static-int-${scale}-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint${scale}.ppm testoutint${scale}.ppm)
338endforeach()
DRC7ab03642012-01-31 05:47:07 +0000339add_test(djpeg-static-fast-1_2 djpeg-static -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
340add_test(djpeg-static-fast-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_2.ppm testoutfst1_2.ppm)
DRC7ab03642012-01-31 05:47:07 +0000341add_test(djpeg-static-256 djpeg-static -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
342add_test(djpeg-static-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimg.bmp testout.bmp)
343add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
344add_test(cjpeg-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000345add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg)
DRC7ab03642012-01-31 05:47:07 +0000346add_test(jpegtran-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000347if(WITH_ARITH_ENC)
DRC7ab03642012-01-31 05:47:07 +0000348add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
349add_test(cjpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testoutari.jpg)
350add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg)
351add_test(jpegtran-static-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000352endif()
353if(WITH_ARITH_DEC)
DRC7ab03642012-01-31 05:47:07 +0000354add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
355add_test(djpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.ppm testoutari.ppm)
356add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
357add_test(jpegtran-static-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000358endif()
DRC7ab03642012-01-31 05:47:07 +0000359add_test(jpegtran-static-crop jpegtran-static -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
360add_test(jpegtran-static-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgcrop.jpg testoutcrop.jpg)
DRC2c0a4e12010-10-16 08:51:43 +0000361
DRCa0f878a2011-04-02 04:43:14 +0000362add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
363 ${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
364
DRC2c0a4e12010-10-16 08:51:43 +0000365
366#
367# Installer
368#
369
DRC2c0a4e12010-10-16 08:51:43 +0000370if(MSVC)
371 set(INST_PLATFORM "Visual C++")
DRCb94f2de2011-03-22 09:31:25 +0000372 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-vc)
373 set(INST_DIR ${CMAKE_PROJECT_NAME})
DRC2c0a4e12010-10-16 08:51:43 +0000374elseif(MINGW)
375 set(INST_PLATFORM GCC)
DRCb94f2de2011-03-22 09:31:25 +0000376 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-gcc)
377 set(INST_DIR ${CMAKE_PROJECT_NAME}-gcc)
DRC2c0a4e12010-10-16 08:51:43 +0000378 set(INST_DEFS -DGCC)
379endif()
380
381if(64BIT)
382 set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
383 set(INST_NAME ${INST_NAME}64)
DRCb94f2de2011-03-22 09:31:25 +0000384 set(INST_DIR ${INST_DIR}64)
DRC2c0a4e12010-10-16 08:51:43 +0000385 set(INST_DEFS ${INST_DEFS} -DWIN64)
386endif()
387
DRC957d6232011-04-01 11:13:11 +0000388if(WITH_JAVA)
389 set(INST_DEFS ${INST_DEFS} -DJAVA)
390endif()
391
DRC2c0a4e12010-10-16 08:51:43 +0000392if(MSVC_IDE)
DRC926e01f2011-04-06 06:35:38 +0000393 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
DRC2c0a4e12010-10-16 08:51:43 +0000394else()
395 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
396endif()
397
398configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
399
400add_custom_target(installer
401 makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
DRCb94f2de2011-03-22 09:31:25 +0000402 DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
DRC3185cb92011-05-25 03:52:22 +0000403 cjpeg djpeg jpegtran tjbench
DRC2c0a4e12010-10-16 08:51:43 +0000404 SOURCES libjpeg-turbo.nsi)
DRC7284c9a2010-10-16 21:55:14 +0000405
DRC3185cb92011-05-25 03:52:22 +0000406install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom tjbench
DRC7284c9a2010-10-16 21:55:14 +0000407 ARCHIVE DESTINATION lib
408 LIBRARY DESTINATION lib
409 RUNTIME DESTINATION bin
410)
411
412install(FILES ${CMAKE_SOURCE_DIR}/LGPL.txt ${CMAKE_SOURCE_DIR}/LICENSE.txt
413 ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
414 ${CMAKE_SOURCE_DIR}/libjpeg.txt ${CMAKE_SOURCE_DIR}/usage.txt
415 DESTINATION doc)
DRCe2befde2010-10-17 07:28:08 +0000416
417install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
418 ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
419 ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)