1#
2# Setup
3#
4
5cmake_minimum_required(VERSION 2.8.8)
6# Use LINK_INTERFACE_LIBRARIES instead of INTERFACE_LINK_LIBRARIES
7if(POLICY CMP0022)
8  cmake_policy(SET CMP0022 OLD)
9endif()
10
11project(libjpeg-turbo C)
12set(VERSION 1.4.2)
13
14if(CYGWIN OR NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
15  execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
16  string(REGEX REPLACE "\n" "" BUILD ${BUILD})
17elseif(WIN32)
18  execute_process(COMMAND "wmic.exe" "os" "get" "LocalDateTime" OUTPUT_VARIABLE
19    BUILD)
20  string(REGEX REPLACE "[^0-9]" "" BUILD "${BUILD}")
21  if (BUILD STREQUAL "")
22    execute_process(COMMAND "cmd.exe" "/C" "DATE" "/T" OUTPUT_VARIABLE BUILD)
23    string(REGEX REPLACE ".*[ ]([0-9]*)[/.]([0-9]*)[/.]([0-9]*).*" "\\3\\2\\1" BUILD "${BUILD}")
24  else()
25    string(SUBSTRING "${BUILD}" 0 8 BUILD)
26  endif()
27else()
28  message(FATAL_ERROR "Platform not supported by this build system.  Use autotools instead.")
29endif()
30
31# This does nothing except when using MinGW.  CMAKE_BUILD_TYPE has no meaning
32# in Visual Studio, and it always defaults to Debug when using NMake.
33if(NOT CMAKE_BUILD_TYPE)
34  set(CMAKE_BUILD_TYPE Release)
35endif()
36
37message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
38
39# This only works if building from the command line.  There is currently no way
40# to set a variable's value based on the build type when using Visual Studio.
41if(CMAKE_BUILD_TYPE STREQUAL "Debug")
42  set(BUILD "${BUILD}d")
43endif()
44
45message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
46
47option(WITH_SIMD "Include SIMD extensions" TRUE)
48option(WITH_ARITH_ENC "Include arithmetic encoding support" TRUE)
49option(WITH_ARITH_DEC "Include arithmetic decoding support" TRUE)
50option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
51option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
52option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE)
53option(WITH_TURBOJPEG "Include the TurboJPEG wrapper library and associated test programs" TRUE)
54option(WITH_JAVA "Build Java wrapper for the TurboJPEG library" FALSE)
55option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_SIMD=0 WITH_TURBOJPEG=0 WITH_ARITH_ENC=0 WITH_ARITH_DEC=0)" FALSE)
56option(ENABLE_STATIC "Build static libraries" TRUE)
57option(ENABLE_SHARED "Build shared libraries" TRUE)
58
59if(WITH_12BIT)
60  set(WITH_SIMD FALSE)
61  set(WITH_TURBOJPEG FALSE)
62  set(WITH_JAVA FALSE)
63  set(WITH_ARITH_ENC FALSE)
64  set(WITH_ARITH_DEC FALSE)
65  set(BITS_IN_JSAMPLE 12)
66  message(STATUS "12-bit JPEG support enabled")
67else()
68  set(BITS_IN_JSAMPLE 8)
69endif()
70
71if(WITH_ARITH_ENC)
72  set(C_ARITH_CODING_SUPPORTED 1)
73  message(STATUS "Arithmetic encoding support enabled")
74else()
75  message(STATUS "Arithmetic encoding support disabled")
76endif()
77
78if(WITH_ARITH_DEC)
79  set(D_ARITH_CODING_SUPPORTED 1)
80  message(STATUS "Arithmetic decoding support enabled")
81else()
82  message(STATUS "Arithmetic decoding support disabled")
83endif()
84
85if(WITH_TURBOJPEG)
86  message(STATUS "TurboJPEG C wrapper enabled")
87else()
88  message(STATUS "TurboJPEG C wrapper disabled")
89endif()
90
91if(WITH_JAVA)
92  message(STATUS "TurboJPEG Java wrapper enabled")
93else()
94  message(STATUS "TurboJPEG Java wrapper disabled")
95endif()
96
97set(SO_AGE 0)
98if(WITH_MEM_SRCDST)
99  set(SO_AGE 1)
100endif()
101
102set(JPEG_LIB_VERSION 62)
103set(DLL_VERSION ${JPEG_LIB_VERSION})
104set(FULLVERSION ${DLL_VERSION}.${SO_AGE}.0)
105if(WITH_JPEG8)
106  set(JPEG_LIB_VERSION 80)
107  set(DLL_VERSION 8)
108  set(FULLVERSION ${DLL_VERSION}.0.2)
109  message(STATUS "Emulating libjpeg v8 API/ABI")
110elseif(WITH_JPEG7)
111  set(JPEG_LIB_VERSION 70)
112  set(DLL_VERSION 7)
113  set(FULLVERSION ${DLL_VERSION}.${SO_AGE}.0)
114  message(STATUS "Emulating libjpeg v7 API/ABI")
115endif(WITH_JPEG8)
116
117if(WITH_MEM_SRCDST)
118  set(MEM_SRCDST_SUPPORTED 1)
119  message(STATUS "In-memory source/destination managers enabled")
120else()
121  message(STATUS "In-memory source/destination managers disabled")
122endif()
123
124if(MSVC)
125  option(WITH_CRT_DLL
126    "Link all libjpeg-turbo libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.)  The default is to use the C run-time DLL only with the libraries and executables that need it."
127    FALSE)
128  if(NOT WITH_CRT_DLL)
129    # Use the static C library for all build types
130    foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
131      CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
132      if(${var} MATCHES "/MD")
133        string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
134      endif()
135    endforeach()
136  endif()
137  add_definitions(-W3 -wd4996)
138endif()
139
140# Detect whether compiler is 64-bit
141if(MSVC AND CMAKE_CL_64)
142  set(SIMD_X86_64 1)
143  set(64BIT 1)
144elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
145  set(SIMD_X86_64 1)
146  set(64BIT 1)
147endif()
148
149if(64BIT)
150  message(STATUS "64-bit build")
151else()
152  message(STATUS "32-bit build")
153endif()
154
155if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
156  if(MSVC)
157    set(CMAKE_INSTALL_PREFIX_DEFAULT ${CMAKE_PROJECT_NAME})
158  else()
159    set(CMAKE_INSTALL_PREFIX_DEFAULT ${CMAKE_PROJECT_NAME}-gcc)
160  endif()
161  if(64BIT)
162    set(CMAKE_INSTALL_PREFIX_DEFAULT ${CMAKE_INSTALL_PREFIX_DEFAULT}64)
163  endif()
164  set(CMAKE_INSTALL_PREFIX "c:/${CMAKE_INSTALL_PREFIX_DEFAULT}" CACHE PATH
165    "Directory into which to install libjpeg-turbo (default: c:/${CMAKE_INSTALL_PREFIX_DEFAULT})"
166    FORCE)
167endif()
168
169message(STATUS "Install directory = ${CMAKE_INSTALL_PREFIX}")
170
171configure_file(win/jconfig.h.in jconfig.h)
172configure_file(win/jconfigint.h.in jconfigint.h)
173
174include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
175
176if(WITH_JAVA)
177  find_package(Java)
178  find_package(JNI)
179  if(DEFINED JAVACFLAGS)
180    message(STATUS "Java compiler flags = ${JAVACFLAGS}")
181  endif()
182endif()
183
184
185#
186# Targets
187#
188
189set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
190  jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
191  jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
192  jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
193  jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
194  jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
195  jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
196
197if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
198  set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
199endif()
200
201if(WITH_ARITH_ENC)
202  set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
203endif()
204
205if(WITH_ARITH_DEC)
206  set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
207endif()
208
209if(WITH_SIMD)
210  add_definitions(-DWITH_SIMD)
211  add_subdirectory(simd)
212  if(SIMD_X86_64)
213    set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
214  else()
215    set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
216  endif()
217  # This tells CMake that the "source" files haven't been generated yet
218  set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
219else()
220  set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
221  message(STATUS "Not using SIMD acceleration")
222endif()
223
224if(WITH_JAVA)
225  add_subdirectory(java)
226  set(ENABLE_SHARED TRUE)
227endif()
228
229if(ENABLE_SHARED)
230  add_subdirectory(sharedlib)
231endif()
232
233if(ENABLE_STATIC OR WITH_TURBOJPEG)
234  add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
235  if(NOT MSVC)
236    set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
237  endif()
238  if(WITH_SIMD)
239    add_dependencies(jpeg-static simd)
240  endif()
241endif()
242
243if(WITH_TURBOJPEG)
244  set(TURBOJPEG_SOURCES turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c)
245  if(WITH_JAVA)
246    set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
247    include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
248  endif()
249
250  if(ENABLE_SHARED)
251    add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
252    set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
253    if(MINGW)
254      set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
255    endif()
256    target_link_libraries(turbojpeg jpeg-static)
257    set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
258
259    add_executable(tjunittest tjunittest.c tjutil.c)
260    target_link_libraries(tjunittest turbojpeg)
261
262    add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
263      wrppm.c)
264    target_link_libraries(tjbench turbojpeg jpeg-static)
265    set_property(TARGET tjbench PROPERTY COMPILE_FLAGS
266      "-DBMP_SUPPORTED -DPPM_SUPPORTED")
267  endif()
268
269  if(ENABLE_STATIC)
270    add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
271      turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c)
272    if(NOT MSVC)
273      set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
274    endif()
275    if(WITH_SIMD)
276      add_dependencies(turbojpeg-static simd)
277    endif()
278
279    add_executable(tjunittest-static tjunittest.c tjutil.c)
280    target_link_libraries(tjunittest-static turbojpeg-static)
281
282    add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c
283      wrbmp.c wrppm.c)
284    target_link_libraries(tjbench-static turbojpeg-static jpeg-static)
285    set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS
286      "-DBMP_SUPPORTED -DPPM_SUPPORTED")
287  endif()
288endif()
289
290if(WITH_12BIT)
291  set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED -DUSE_SETMODE")
292else()
293  set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
294  set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
295  set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
296endif()
297
298if(ENABLE_STATIC)
299  add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
300    ${CJPEG_BMP_SOURCES})
301  set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
302  target_link_libraries(cjpeg-static jpeg-static)
303
304  add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
305    wrppm.c ${DJPEG_BMP_SOURCES})
306  set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
307  target_link_libraries(djpeg-static jpeg-static)
308
309  add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
310  target_link_libraries(jpegtran-static jpeg-static)
311  set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
312endif()
313
314add_executable(rdjpgcom rdjpgcom.c)
315
316add_executable(wrjpgcom wrjpgcom.c)
317
318
319#
320# Tests
321#
322
323if(MSVC_IDE)
324  set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
325else()
326  set(OBJDIR "")
327endif()
328
329enable_testing()
330
331if(WITH_12BIT)
332  set(TESTORIG testorig12.jpg)
333  set(MD5_JPEG_RGB_ISLOW 9620f424569594bb9242b48498ad801f)
334  set(MD5_PPM_RGB_ISLOW f3301d2219783b8b3d942b7239fa50c0)
335  set(MD5_JPEG_422_IFAST_OPT 7322e3bd2f127f7de4b40d4480ce60e4)
336  set(MD5_PPM_422_IFAST 79807fa552899e66a04708f533e16950)
337  set(MD5_PPM_422M_IFAST 07737bfe8a7c1c87aaa393a0098d16b0)
338  set(MD5_JPEG_420_IFAST_Q100_PROG a1da220b5604081863a504297ed59e55)
339  set(MD5_PPM_420_Q100_IFAST 1b3730122709f53d007255e8dfd3305e)
340  set(MD5_PPM_420M_Q100_IFAST 980a1a3c5bf9510022869d30b7d26566)
341  set(MD5_JPEG_GRAY_ISLOW 235c90707b16e2e069f37c888b2636d9)
342  set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca)
343  set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d)
344  set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
345  set(MD5_JPEG_3x2_FLOAT_PROG a8c17daf77b457725ec929e215b603f8)
346  set(MD5_PPM_3x2_FLOAT 42876ab9e5c2f76a87d08db5fbd57956)
347  set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0)
348  set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb)
349  set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96)
350  set(MD5_PPM_420M_ISLOW_11_8 800a16f9f4dc9b293197bfe11be10a82)
351  set(MD5_PPM_420M_ISLOW_9_8 06b7a92a9bc69f4dc36ec40f1937d55c)
352  set(MD5_PPM_420M_ISLOW_7_8 3ec444a14a4ab4eab88ffc49c48eca43)
353  set(MD5_PPM_420M_ISLOW_3_4 3e726b7ea872445b19437d1c1d4f0d93)
354  set(MD5_PPM_420M_ISLOW_5_8 a8a771abdc94301d20ffac119b2caccd)
355  set(MD5_PPM_420M_ISLOW_1_2 b419124dd5568b085787234866102866)
356  set(MD5_PPM_420M_ISLOW_3_8 343d19015531b7bbe746124127244fa8)
357  set(MD5_PPM_420M_ISLOW_1_4 35fd59d866e44659edfa3c18db2a3edb)
358  set(MD5_PPM_420M_ISLOW_1_8 ccaed48ac0aedefda5d4abe4013f4ad7)
359  set(MD5_PPM_420_ISLOW_SKIP15_31 86664cd9dc956536409e44e244d20a97)
360  set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 452a21656115a163029cfba5c04fa76a)
361  set(MD5_PPM_444_ISLOW_SKIP1_6 ef63901f71ef7a75cd78253fc0914f84)
362  set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 15b173fb5872d9575572fbcc1b05956f)
363  set(MD5_JPEG_CROP cdb35ff4b4519392690ea040c56ea99c)
364else()
365  set(TESTORIG testorig.jpg)
366  set(MD5_JPEG_RGB_ISLOW 768e970dd57b340ff1b83c9d3d47c77b)
367  set(MD5_PPM_RGB_ISLOW 00a257f5393fef8821f2b88ac7421291)
368  set(MD5_BMP_RGB_ISLOW_565 f07d2e75073e4bb10f6c6f4d36e2e3be)
369  set(MD5_BMP_RGB_ISLOW_565D 4cfa0928ef3e6bb626d7728c924cfda4)
370  set(MD5_JPEG_422_IFAST_OPT 2540287b79d913f91665e660303ab2c8)
371  set(MD5_PPM_422_IFAST 35bd6b3f833bad23de82acea847129fa)
372  set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
373  set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
374  set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
375  set(MD5_JPEG_420_IFAST_Q100_PROG 990cbe0329c882420a2094da7e5adade)
376  set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
377  set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
378  set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
379  set(MD5_PPM_GRAY_ISLOW 8d3596c56eace32f205deccc229aa5ed)
380  set(MD5_PPM_GRAY_ISLOW_RGB 116424ac07b79e5e801f00508eab48ec)
381  set(MD5_BMP_GRAY_ISLOW_565 12f78118e56a2f48b966f792fedf23cc)
382  set(MD5_BMP_GRAY_ISLOW_565D bdbbd616441a24354c98553df5dc82db)
383  set(MD5_JPEG_420S_IFAST_OPT 388708217ac46273ca33086b22827ed8)
384  if(WITH_SIMD)
385    set(MD5_JPEG_3x2_FLOAT_PROG 343e3f8caf8af5986ebaf0bdc13b5c71)
386    set(MD5_PPM_3x2_FLOAT 1a75f36e5904d6fc3a85a43da9ad89bb)
387  else()
388    set(MD5_JPEG_3x2_FLOAT_PROG 9bca803d2042bd1eb03819e2bf92b3e5)
389    set(MD5_PPM_3x2_FLOAT f6bfab038438ed8f5522fbd33595dcdc)
390  endif()
391  set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
392  set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
393  set(MD5_PPM_420M_IFAST_ARI 72b59a99bcf1de24c5b27d151bde2437)
394  set(MD5_JPEG_420_ISLOW 9a68f56bc76e466aa7e52f415d0f4a5f)
395  set(MD5_PPM_420M_ISLOW_2_1 9f9de8c0612f8d06869b960b05abf9c9)
396  set(MD5_PPM_420M_ISLOW_15_8 b6875bc070720b899566cc06459b63b7)
397  set(MD5_PPM_420M_ISLOW_13_8 bc3452573c8152f6ae552939ee19f82f)
398  set(MD5_PPM_420M_ISLOW_11_8 d8cc73c0aaacd4556569b59437ba00a5)
399  set(MD5_PPM_420M_ISLOW_9_8 d25e61bc7eac0002f5b393aa223747b6)
400  set(MD5_PPM_420M_ISLOW_7_8 ddb564b7c74a09494016d6cd7502a946)
401  set(MD5_PPM_420M_ISLOW_3_4 8ed8e68808c3fbc4ea764fc9d2968646)
402  set(MD5_PPM_420M_ISLOW_5_8 a3363274999da2366a024efae6d16c9b)
403  set(MD5_PPM_420M_ISLOW_1_2 e692a315cea26b988c8e8b29a5dbcd81)
404  set(MD5_PPM_420M_ISLOW_3_8 79eca9175652ced755155c90e785a996)
405  set(MD5_PPM_420M_ISLOW_1_4 79cd778f8bf1a117690052cacdd54eca)
406  set(MD5_PPM_420M_ISLOW_1_8 391b3d4aca640c8567d6f8745eb2142f)
407  set(MD5_BMP_420_ISLOW_256 4980185e3776e89bd931736e1cddeee6)
408  set(MD5_BMP_420_ISLOW_565 bf9d13e16c4923b92e1faa604d7922cb)
409  set(MD5_BMP_420_ISLOW_565D 6bde71526acc44bcff76f696df8638d2)
410  set(MD5_BMP_420M_ISLOW_565 8dc0185245353cfa32ad97027342216f)
411  set(MD5_BMP_420M_ISLOW_565D d1be3a3339166255e76fa50a0d70d73e)
412  set(MD5_PPM_420_ISLOW_SKIP15_31 c4c65c1e43d7275cd50328a61e6534f0)
413  set(MD5_PPM_420_ISLOW_ARI_SKIP16_139 087c6b123db16ac00cb88c5b590bb74a)
414  set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 26eb36ccc7d1f0cb80cdabb0ac8b5d99)
415  set(MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4 886c6775af22370257122f8b16207e6d)
416  set(MD5_PPM_444_ISLOW_SKIP1_6 5606f86874cf26b8fcee1117a0a436a6)
417  set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 db87dc7ce26bcdc7a6b56239ce2b9d6c)
418  set(MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0 cb57b32bd6d03e35432362f7bf184b6d)
419  set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
420endif()
421
422if(WITH_JAVA)
423  add_test(TJUnitTest
424    ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
425      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
426      TJUnitTest)
427  add_test(TJUnitTest-yuv
428    ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
429      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
430      TJUnitTest -yuv)
431  add_test(TJUnitTest-yuv-nopad
432    ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
433      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
434      TJUnitTest -yuv -noyuvpad)
435  add_test(TJUnitTest-bi
436    ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
437      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
438      TJUnitTest -bi)
439  add_test(TJUnitTest-bi-yuv
440    ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
441      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
442      TJUnitTest -bi -yuv)
443  add_test(TJUnitTest-bi-yuv-nopad
444    ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar
445      -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
446      TJUnitTest -bi -yuv -noyuvpad)
447endif()
448
449set(TEST_LIBTYPES "")
450if(ENABLE_SHARED)
451  set(TEST_LIBTYPES ${TEST_LIBTYPES} shared)
452endif()
453if(ENABLE_STATIC)
454  set(TEST_LIBTYPES ${TEST_LIBTYPES} static)
455endif()
456
457foreach(libtype ${TEST_LIBTYPES})
458  if(libtype STREQUAL "shared")
459    set(dir sharedlib/)
460  else()
461    set(dir "")
462    set(suffix -static)
463  endif()
464  if(WITH_TURBOJPEG)
465    add_test(tjunittest${suffix} tjunittest${suffix})
466    add_test(tjunittest${suffix}-alloc tjunittest${suffix} -alloc)
467    add_test(tjunittest${suffix}-yuv tjunittest${suffix} -yuv)
468    add_test(tjunittest${suffix}-yuv-alloc tjunittest${suffix} -yuv -alloc)
469    add_test(tjunittest${suffix}-yuv-nopad tjunittest${suffix} -yuv -noyuvpad)
470  endif()
471
472  # These tests are carefully chosen to provide full coverage of as many of the
473  # underlying algorithms as possible (including all of the SIMD-accelerated
474  # ones.)
475
476  # CC: null  SAMP: fullsize  FDCT: islow  ENT: huff
477  add_test(cjpeg${suffix}-rgb-islow
478    ${dir}cjpeg${suffix} -rgb -dct int -outfile testout_rgb_islow.jpg
479      ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
480  add_test(cjpeg${suffix}-rgb-islow-cmp
481    ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_RGB_ISLOW} -DFILE=testout_rgb_islow.jpg
482      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
483  # CC: null  SAMP: fullsize  IDCT: islow  ENT: huff
484  add_test(djpeg${suffix}-rgb-islow
485    ${dir}djpeg${suffix} -dct int -ppm -outfile testout_rgb_islow.ppm
486      testout_rgb_islow.jpg)
487  add_test(djpeg${suffix}-rgb-islow-cmp
488    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_RGB_ISLOW} -DFILE=testout_rgb_islow.ppm
489      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
490  if(NOT WITH_12BIT)
491    # CC: RGB->RGB565  SAMP: fullsize  IDCT: islow  ENT: huff
492    add_test(djpeg${suffix}-rgb-islow-565
493      ${dir}djpeg${suffix} -dct int -rgb565 -dither none -bmp
494        -outfile testout_rgb_islow_565.bmp testout_rgb_islow.jpg)
495    add_test(djpeg${suffix}-rgb-islow-565-cmp
496      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_RGB_ISLOW_565}
497        -DFILE=testout_rgb_islow_565.bmp
498        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
499    # CC: RGB->RGB565 (dithered)  SAMP: fullsize  IDCT: islow  ENT: huff
500    add_test(djpeg${suffix}-rgb-islow-565D
501      ${dir}djpeg${suffix} -dct int -rgb565 -bmp
502        -outfile testout_rgb_islow_565D.bmp testout_rgb_islow.jpg)
503    add_test(djpeg${suffix}-rgb-islow-565D-cmp
504      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_RGB_ISLOW_565D}
505        -DFILE=testout_rgb_islow_565D.bmp
506        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
507  endif()
508
509  # CC: RGB->YCC  SAMP: fullsize/h2v1  FDCT: ifast  ENT: 2-pass huff
510  add_test(cjpeg${suffix}-422-ifast-opt
511    ${dir}cjpeg${suffix} -sample 2x1 -dct fast -opt
512      -outfile testout_422_ifast_opt.jpg
513      ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
514  add_test(cjpeg${suffix}-422-ifast-opt-cmp
515    ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_422_IFAST_OPT}
516      -DFILE=testout_422_ifast_opt.jpg
517      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
518  # CC: YCC->RGB  SAMP: fullsize/h2v1 fancy  IDCT: ifast  ENT: huff
519  add_test(djpeg${suffix}-422-ifast
520    ${dir}djpeg${suffix} -dct fast -outfile testout_422_ifast.ppm
521      testout_422_ifast_opt.jpg)
522  add_test(djpeg${suffix}-422-ifast-cmp
523    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_422_IFAST} -DFILE=testout_422_ifast.ppm
524      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
525  # CC: YCC->RGB  SAMP: h2v1 merged  IDCT: ifast  ENT: huff
526  add_test(djpeg${suffix}-422m-ifast
527    ${dir}djpeg${suffix} -dct fast -nosmooth -outfile testout_422m_ifast.ppm
528      testout_422_ifast_opt.jpg)
529  add_test(djpeg${suffix}-422m-ifast-cmp
530    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_422M_IFAST} -DFILE=testout_422m_ifast.ppm
531      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
532  if(NOT WITH_12BIT)
533    # CC: YCC->RGB565  SAMP: h2v1 merged  IDCT: ifast  ENT: huff
534    add_test(djpeg${suffix}-422m-ifast-565
535      ${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -dither none -bmp
536        -outfile testout_422m_ifast_565.bmp testout_422_ifast_opt.jpg)
537    add_test(djpeg${suffix}-422m-ifast-565-cmp
538      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_422M_IFAST_565}
539        -DFILE=testout_422m_ifast_565.bmp
540        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
541    # CC: YCC->RGB565 (dithered)  SAMP: h2v1 merged  IDCT: ifast  ENT: huff
542    add_test(djpeg${suffix}-422m-ifast-565D
543      ${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -bmp
544        -outfile testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg)
545    add_test(djpeg${suffix}-422m-ifast-565D-cmp
546      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_422M_IFAST_565D}
547        -DFILE=testout_422m_ifast_565D.bmp
548        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
549  endif()
550
551  # CC: RGB->YCC  SAMP: fullsize/h2v2  FDCT: ifast  ENT: prog huff
552  add_test(cjpeg${suffix}-420-q100-ifast-prog
553    ${dir}cjpeg${suffix} -sample 2x2 -quality 100 -dct fast -prog
554      -outfile testout_420_q100_ifast_prog.jpg
555      ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
556  add_test(cjpeg${suffix}-420-q100-ifast-prog-cmp
557    ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_IFAST_Q100_PROG}
558      -DFILE=testout_420_q100_ifast_prog.jpg
559      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
560  # CC: YCC->RGB  SAMP: fullsize/h2v2 fancy  IDCT: ifast  ENT: prog huff
561  add_test(djpeg${suffix}-420-q100-ifast-prog
562    ${dir}djpeg${suffix} -dct fast -outfile testout_420_q100_ifast.ppm
563      testout_420_q100_ifast_prog.jpg)
564  add_test(djpeg${suffix}-420-q100-ifast-prog-cmp
565    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_Q100_IFAST}
566      -DFILE=testout_420_q100_ifast.ppm
567      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
568  # CC: YCC->RGB  SAMP: h2v2 merged  IDCT: ifast  ENT: prog huff
569  add_test(djpeg${suffix}-420m-q100-ifast-prog
570    ${dir}djpeg${suffix} -dct fast -nosmooth
571      -outfile testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg)
572  add_test(djpeg${suffix}-420m-q100-ifast-prog-cmp
573    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420M_Q100_IFAST}
574      -DFILE=testout_420m_q100_ifast.ppm
575      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
576
577  # CC: RGB->Gray  SAMP: fullsize  FDCT: islow  ENT: huff
578  add_test(cjpeg${suffix}-gray-islow
579    ${dir}cjpeg${suffix} -gray -dct int -outfile testout_gray_islow.jpg
580      ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
581  add_test(cjpeg${suffix}-gray-islow-cmp
582    ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_GRAY_ISLOW}
583      -DFILE=testout_gray_islow.jpg
584      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
585  # CC: Gray->Gray  SAMP: fullsize  IDCT: islow  ENT: huff
586  add_test(djpeg${suffix}-gray-islow
587    ${dir}djpeg${suffix} -dct int -outfile testout_gray_islow.ppm
588      testout_gray_islow.jpg)
589  add_test(djpeg${suffix}-gray-islow-cmp
590    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_GRAY_ISLOW}
591      -DFILE=testout_gray_islow.ppm
592      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
593  # CC: Gray->RGB  SAMP: fullsize  IDCT: islow  ENT: huff
594  add_test(djpeg${suffix}-gray-islow-rgb
595    ${dir}djpeg${suffix} -dct int -rgb -outfile testout_gray_islow_rgb.ppm
596      testout_gray_islow.jpg)
597  add_test(djpeg${suffix}-gray-islow-rgb-cmp
598    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_GRAY_ISLOW_RGB}
599      -DFILE=testout_gray_islow_rgb.ppm
600      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
601  if(NOT WITH_12BIT)
602    # CC: Gray->RGB565  SAMP: fullsize  IDCT: islow  ENT: huff
603    add_test(djpeg${suffix}-gray-islow-565
604      ${dir}djpeg${suffix} -dct int -rgb565 -dither none -bmp
605        -outfile testout_gray_islow_565.bmp testout_gray_islow.jpg)
606    add_test(djpeg${suffix}-gray-islow-565-cmp
607      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_GRAY_ISLOW_565}
608        -DFILE=testout_gray_islow_565.bmp
609        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
610    # CC: Gray->RGB565 (dithered)  SAMP: fullsize  IDCT: islow  ENT: huff
611    add_test(djpeg${suffix}-gray-islow-565D
612      ${dir}djpeg${suffix} -dct int -rgb565 -bmp
613        -outfile testout_gray_islow_565D.bmp testout_gray_islow.jpg)
614    add_test(djpeg${suffix}-gray-islow-565D-cmp
615      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_GRAY_ISLOW_565D}
616        -DFILE=testout_gray_islow_565D.bmp
617        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
618  endif()
619
620  # CC: RGB->YCC  SAMP: fullsize smooth/h2v2 smooth  FDCT: islow
621  # ENT: 2-pass huff
622  add_test(cjpeg${suffix}-420s-ifast-opt
623    ${dir}cjpeg${suffix} -sample 2x2 -smooth 1 -dct int -opt -outfile
624      testout_420s_ifast_opt.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
625  add_test(cjpeg${suffix}-420s-ifast-opt-cmp
626    ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420S_IFAST_OPT}
627      -DFILE=testout_420s_ifast_opt.jpg
628      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
629
630  # CC: RGB->YCC  SAMP: fullsize/int  FDCT: float  ENT: prog huff
631  add_test(cjpeg${suffix}-3x2-float-prog
632    ${dir}cjpeg${suffix} -sample 3x2 -dct float -prog
633      -outfile testout_3x2_float_prog.jpg
634      ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
635  add_test(cjpeg${suffix}-3x2-float-prog-cmp
636    ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_3x2_FLOAT_PROG}
637      -DFILE=testout_3x2_float_prog.jpg
638      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
639  # CC: YCC->RGB  SAMP: fullsize/int  IDCT: float  ENT: prog huff
640  add_test(djpeg${suffix}-3x2-float-prog
641    ${dir}djpeg${suffix} -dct float -outfile testout_3x2_float.ppm
642      testout_3x2_float_prog.jpg)
643  add_test(djpeg${suffix}-3x2-float-prog-cmp
644    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_3x2_FLOAT} -DFILE=testout_3x2_float.ppm
645      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
646
647  if(WITH_ARITH_ENC)
648    # CC: YCC->RGB  SAMP: fullsize/h2v2  FDCT: islow  ENT: arith
649    add_test(cjpeg${suffix}-420-islow-ari
650      ${dir}cjpeg${suffix} -dct int -arithmetic
651        -outfile testout_420_islow_ari.jpg
652        ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
653    add_test(cjpeg${suffix}-420-islow-ari-cmp
654      ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_ISLOW_ARI}
655        -DFILE=testout_420_islow_ari.jpg
656        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
657    add_test(jpegtran${suffix}-420-islow-ari
658      ${dir}jpegtran${suffix} -arithmetic
659        -outfile testout_420_islow_ari.jpg
660        ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg)
661    add_test(jpegtran${suffix}-420-islow-ari-cmp
662      ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_ISLOW_ARI}
663        -DFILE=testout_420_islow_ari.jpg
664        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
665    # CC: YCC->RGB  SAMP: fullsize  FDCT: islow  ENT: prog arith
666    add_test(cjpeg${suffix}-444-islow-progari
667      ${dir}cjpeg${suffix} -sample 1x1 -dct int -prog -arithmetic
668        -outfile testout_444_islow_progari.jpg
669        ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
670    add_test(cjpeg${suffix}-444-islow-progari-cmp
671      ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_444_ISLOW_PROGARI}
672        -DFILE=testout_444_islow_progari.jpg
673        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
674  endif()
675  if(WITH_ARITH_DEC)
676    # CC: RGB->YCC  SAMP: h2v2 merged  IDCT: ifast  ENT: arith
677    add_test(djpeg${suffix}-420m-ifast-ari
678      ${dir}djpeg${suffix} -fast -ppm -outfile testout_420m_ifast_ari.ppm
679        ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
680    add_test(djpeg${suffix}-420m-ifast-ari-cmp
681      ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420M_IFAST_ARI}
682        -DFILE=testout_420m_ifast_ari.ppm
683        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
684    add_test(jpegtran${suffix}-420-islow
685      ${dir}jpegtran${suffix} -outfile testout_420_islow.jpg
686        ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
687    add_test(jpegtran${suffix}-420-islow-cmp
688      ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_420_ISLOW}
689        -DFILE=testout_420_islow.jpg
690        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
691  endif()
692
693  # 2/1--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 16x16 islow  ENT: huff
694  # 15/8--  CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 15x15 islow  ENT: huff
695  # 13/8--  CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 13x13 islow  ENT: huff
696  # 11/8--  CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 11x11 islow  ENT: huff
697  # 9/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 9x9 islow  ENT: huff
698  # 7/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 7x7 islow/14x14 islow
699  #         ENT: huff
700  # 3/4--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 6x6 islow/12x12 islow
701  #         ENT: huff
702  # 5/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 5x5 islow/10x10 islow
703  #         ENT: huff
704  # 1/2--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 4x4 islow/8x8 islow
705  #         ENT: huff
706  # 3/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 3x3 islow/6x6 islow
707  #         ENT: huff
708  # 1/4--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 2x2 islow/4x4 islow
709  #         ENT: huff
710  # 1/8--   CC: YCC->RGB  SAMP: h2v2 merged  IDCT: 1x1 islow/2x2 islow
711  #         ENT: huff
712  foreach(scale 2_1 15_8 13_8 11_8 9_8 7_8 3_4 5_8 1_2 3_8 1_4 1_8)
713    string(REGEX REPLACE "_" "/" scalearg ${scale})
714    add_test(djpeg${suffix}-420m-islow-${scale}
715      ${dir}djpeg${suffix} -dct int -scale ${scalearg} -nosmooth -ppm
716        -outfile testout_420m_islow_${scale}.ppm
717        ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
718    add_test(djpeg${suffix}-420m-islow-${scale}-cmp
719      ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420M_ISLOW_${scale}}
720        -DFILE=testout_420m_islow_${scale}.ppm
721        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
722  endforeach()
723
724  if(NOT WITH_12BIT)
725    # CC: YCC->RGB (dithered)  SAMP: h2v2 fancy  IDCT: islow  ENT: huff
726    add_test(djpeg${suffix}-420-islow-256
727      ${dir}djpeg${suffix} -dct int -colors 256 -bmp
728        -outfile testout_420_islow_256.bmp
729        ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
730    add_test(djpeg${suffix}-420-islow-256-cmp
731      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_420_ISLOW_256}
732        -DFILE=testout_420_islow_256.bmp
733        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
734    # CC: YCC->RGB565  SAMP: h2v2 fancy  IDCT: islow  ENT: huff
735    add_test(djpeg${suffix}-420-islow-565
736      ${dir}djpeg${suffix} -dct int -rgb565 -dither none -bmp
737        -outfile testout_420_islow_565.bmp
738        ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
739    add_test(djpeg${suffix}-420-islow-565-cmp
740      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_420_ISLOW_565}
741        -DFILE=testout_420_islow_565.bmp
742        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
743    # CC: YCC->RGB565 (dithered)  SAMP: h2v2 fancy  IDCT: islow  ENT: huff
744    add_test(djpeg${suffix}-420-islow-565D
745      ${dir}djpeg${suffix} -dct int -rgb565 -bmp
746        -outfile testout_420_islow_565D.bmp
747        ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
748    add_test(djpeg${suffix}-420-islow-565D-cmp
749      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_420_ISLOW_565D}
750        -DFILE=testout_420_islow_565D.bmp
751        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
752    # CC: YCC->RGB565  SAMP: h2v2 merged  IDCT: islow  ENT: huff
753    add_test(djpeg${suffix}-420m-islow-565
754      ${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -dither none -bmp
755        -outfile testout_420m_islow_565.bmp
756        ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
757    add_test(djpeg${suffix}-420m-islow-565-cmp
758      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_420M_ISLOW_565}
759        -DFILE=testout_420m_islow_565.bmp
760        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
761    # CC: YCC->RGB565 (dithered)  SAMP: h2v2 merged  IDCT: islow  ENT: huff
762    add_test(djpeg${suffix}-420m-islow-565D
763      ${dir}djpeg${suffix} -dct int -nosmooth -rgb565 -bmp
764        -outfile testout_420m_islow_565D.bmp
765        ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
766    add_test(djpeg${suffix}-420m-islow-565D-cmp
767      ${CMAKE_COMMAND} -DMD5=${MD5_BMP_420M_ISLOW_565D}
768        -DFILE=testout_420m_islow_565D.bmp
769        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
770  endif()
771
772  # Partial decode tests.  These tests are designed to cover all of the
773  # possible code paths in jpeg_skip_scanlines().
774
775  # Context rows: Yes  Intra-iMCU row: Yes  iMCU row prefetch: No   ENT: huff
776  add_test(djpeg${suffix}-420-islow-skip15_31
777    ${dir}djpeg${suffix} -dct int -skip 15,31 -ppm
778      -outfile testout_420_islow_skip15,31.ppm
779      ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
780  add_test(djpeg${suffix}-420-islow-skip15_31-cmp
781    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_ISLOW_SKIP15_31}
782      -DFILE=testout_420_islow_skip15,31.ppm
783      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
784  # Context rows: Yes  Intra-iMCU row: No   iMCU row prefetch: Yes  ENT: arith
785  if(WITH_ARITH_DEC)
786    add_test(djpeg${suffix}-420-islow-ari-skip16_139
787      ${dir}djpeg${suffix} -dct int -skip 16,139 -ppm
788        -outfile testout_420_islow_ari_skip16,139.ppm
789        ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
790    add_test(djpeg${suffix}-420-islow-ari_skip16_139-cmp
791      ${CMAKE_COMMAND} -DMD5=${MD5_PPM_420_ISLOW_ARI_SKIP16_139}
792        -DFILE=testout_420_islow_ari_skip16,139.ppm
793        -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
794  endif()
795  # Context rows: Yes  Intra-iMCU row: No   iMCU row prefetch: No   ENT: prog huff
796  add_test(cjpeg${suffix}-420-islow-prog
797    ${dir}cjpeg${suffix} -dct int -prog
798      -outfile testout_420_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
799  add_test(djpeg${suffix}-420-islow-prog-crop62x62_71_71
800    ${dir}djpeg${suffix} -dct int -crop 62x62+71+71 -ppm
801      -outfile testout_420_islow_prog_crop62x62,71,71.ppm
802      testout_420_islow_prog.jpg)
803  add_test(djpeg${suffix}-420-islow-prog-crop62x62_71_71-cmp
804    ${MD5CMP} ${MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71}
805      testout_420_islow_prog_crop62x62,71,71.ppm)
806
807  # Context rows: Yes  Intra-iMCU row: No   iMCU row prefetch: No   ENT: arith
808  if(WITH_ARITH_DEC)
809    add_test(djpeg${suffix}-420-islow-ari-crop53x53_4_4
810      ${dir}djpeg${suffix} -dct int -crop 53x53+4+4 -ppm
811        -outfile testout_420_islow_ari_crop53x53,4,4.ppm
812        ${TESTIMAGES}/testimgari.jpg)
813    add_test(djpeg${suffix}-420-islow-ari-crop53x53_4_4-cmp
814      ${MD5CMP} ${MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4}
815        testout_420_islow_ari_crop53x53,4,4.ppm)
816  endif()
817  # Context rows: No   Intra-iMCU row: Yes  ENT: huff
818  add_test(cjpeg${suffix}-444-islow
819    ${dir}cjpeg${suffix} -dct int -sample 1x1 -outfile testout_444_islow.jpg
820      ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
821  add_test(djpeg${suffix}-444-islow-skip1_6
822    ${dir}djpeg${suffix} -dct int -skip 1,6 -ppm
823      -outfile testout_444_islow_skip1,6.ppm testout_444_islow.jpg)
824  add_test(djpeg${suffix}-444-islow-skip1_6-cmp
825    ${CMAKE_COMMAND} -DMD5=${MD5_PPM_444_ISLOW_SKIP1_6}
826      -DFILE=testout_444_islow_skip1,6.ppm
827      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
828  # Context rows: No   Intra-iMCU row: No   ENT: prog huff
829  add_test(cjpeg${suffix}-444-islow-prog
830    ${dir}cjpeg${suffix} -dct int -prog -sample 1x1
831      -outfile testout_444_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
832  add_test(djpeg${suffix}-444-islow-prog-crop98x98_13_13
833    ${dir}djpeg${suffix} -dct int -crop 98x98+13+13 -ppm
834      -outfile testout_444_islow_prog_crop98x98,13,13.ppm
835      testout_444_islow_prog.jpg)
836  add_test(djpeg${suffix}-444-islow-prog_crop98x98_13_13-cmp
837    ${MD5CMP} ${MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13}
838      testout_444_islow_prog_crop98x98,13,13.ppm)
839
840  # Context rows: No   Intra-iMCU row: No   ENT: arith
841  if(WITH_ARITH_ENC)
842    add_test(cjpeg${suffix}-444-islow-ari
843      ${dir}cjpeg${suffix} -dct int -arithmetic -sample 1x1
844        -outfile testout_444_islow_ari.jpg
845        ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
846    if(WITH_ARITH_DEC)
847      add_test(djpeg${suffix}-444-islow-ari-crop37x37_0_0
848        ${dir}djpeg${suffix} -dct int -crop 37x37+0+0 -ppm
849          -outfile testout_444_islow_ari_crop37x37,0,0.ppm
850          testout_444_islow_ari.jpg)
851      add_test(djpeg${suffix}-444-islow-ari-crop37x37_0_0-cmp
852        ${MD5CMP} ${MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0}
853          testout_444_islow_ari_crop37x37,0,0.ppm)
854    endif()
855  endif()
856
857  add_test(jpegtran${suffix}-crop
858    ${dir}jpegtran${suffix} -crop 120x90+20+50 -transpose -perfect
859      -outfile testout_crop.jpg ${CMAKE_SOURCE_DIR}/testimages/${TESTORIG})
860  add_test(jpegtran${suffix}-crop-cmp
861    ${CMAKE_COMMAND} -DMD5=${MD5_JPEG_CROP} -DFILE=testout_crop.jpg
862      -P ${CMAKE_SOURCE_DIR}/cmakescripts/md5cmp.cmake)
863
864endforeach()
865
866add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
867  ${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
868
869
870#
871# Installer
872#
873
874if(MSVC)
875  set(INST_PLATFORM "Visual C++")
876  set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-vc)
877  set(INST_REG_NAME ${CMAKE_PROJECT_NAME})
878elseif(MINGW)
879  set(INST_PLATFORM GCC)
880  set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-gcc)
881  set(INST_REG_NAME ${CMAKE_PROJECT_NAME}-gcc)
882  set(INST_DEFS -DGCC)
883endif()
884
885if(64BIT)
886  set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
887  set(INST_NAME ${INST_NAME}64)
888  set(INST_REG_NAME ${INST_DIR}64)
889  set(INST_DEFS ${INST_DEFS} -DWIN64)
890endif()
891
892if(WITH_JAVA)
893  set(INST_DEFS ${INST_DEFS} -DJAVA)
894endif()
895
896if(MSVC_IDE)
897  set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
898else()
899  set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
900endif()
901
902STRING(REGEX REPLACE "/" "\\\\" INST_DIR ${CMAKE_INSTALL_PREFIX})
903
904configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
905
906if(WITH_JAVA)
907  set(JAVA_DEPEND java)
908endif()
909add_custom_target(installer
910  makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
911  DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
912    cjpeg djpeg jpegtran tjbench ${JAVA_DEPEND}
913  SOURCES libjpeg-turbo.nsi)
914
915if(WITH_TURBOJPEG)
916  if(ENABLE_SHARED)
917    install(TARGETS turbojpeg tjbench
918      ARCHIVE DESTINATION lib
919      LIBRARY DESTINATION lib
920      RUNTIME DESTINATION bin)
921  endif()
922  if(ENABLE_STATIC)
923    install(TARGETS turbojpeg-static ARCHIVE DESTINATION lib)
924    if(NOT ENABLE_SHARED)
925      install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static.exe
926        DESTINATION bin RENAME tjbench.exe)
927    endif()
928  endif()
929  install(FILES ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)
930endif()
931
932if(ENABLE_STATIC)
933  install(TARGETS jpeg-static ARCHIVE DESTINATION lib)
934  if(NOT ENABLE_SHARED)
935    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static.exe
936      DESTINATION bin RENAME cjpeg.exe)
937    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static.exe
938      DESTINATION bin RENAME djpeg.exe)
939    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jpegtran-static.exe
940      DESTINATION bin RENAME jpegtran.exe)
941  endif()
942endif()
943
944install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION bin)
945
946install(FILES ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
947  ${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt
948  ${CMAKE_SOURCE_DIR}/structure.txt ${CMAKE_SOURCE_DIR}/usage.txt
949  ${CMAKE_SOURCE_DIR}/wizard.txt
950  DESTINATION doc)
951
952install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
953  ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
954  DESTINATION include)
955