blob: 28fd443d653547d58b297d392b582b3a0250b132 [file] [log] [blame]
DRC6abd3912016-11-15 08:47:43 -06001cmake_minimum_required(VERSION 2.8.12)
DRC84697032010-10-15 03:43:24 +00002
DRC0fa78502018-07-20 11:30:04 -05003if(CMAKE_EXECUTABLE_SUFFIX)
4 set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX})
5endif()
6
DRC5d6f8582011-02-18 23:08:58 +00007project(libjpeg-turbo C)
DRC58a39752019-04-10 14:35:45 -05008set(VERSION 2.0.3)
DRCf06cc122016-05-10 19:36:34 -05009string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
10list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
11list(GET VERSION_TRIPLET 1 VERSION_MINOR)
12list(GET VERSION_TRIPLET 2 VERSION_REVISION)
13function(pad_number NUMBER OUTPUT_LEN)
14 string(LENGTH "${${NUMBER}}" INPUT_LEN)
15 if(INPUT_LEN LESS OUTPUT_LEN)
16 math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1")
17 set(NUM ${${NUMBER}})
18 foreach(C RANGE ${ZEROES})
19 set(NUM "0${NUM}")
20 endforeach()
21 set(${NUMBER} ${NUM} PARENT_SCOPE)
22 endif()
23endfunction()
24pad_number(VERSION_MINOR 3)
25pad_number(VERSION_REVISION 3)
26set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION})
DRC84697032010-10-15 03:43:24 +000027
DRC6abd3912016-11-15 08:47:43 -060028string(TIMESTAMP DEFAULT_BUILD "%Y%m%d")
29set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})")
DRC84697032010-10-15 03:43:24 +000030
DRC6abd3912016-11-15 08:47:43 -060031# NOTE: On Windows, this does nothing except when using MinGW or Cygwin.
32# CMAKE_BUILD_TYPE has no meaning in Visual Studio, and it always defaults to
33# Debug when using NMake.
DRC84697032010-10-15 03:43:24 +000034if(NOT CMAKE_BUILD_TYPE)
35 set(CMAKE_BUILD_TYPE Release)
36endif()
DRC84697032010-10-15 03:43:24 +000037message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
38
DRCeb2b9d62010-10-15 04:55:13 +000039message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
40
DRC6abd3912016-11-15 08:47:43 -060041# Detect CPU type and whether we're building 64-bit or 32-bit code
42math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8")
43string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC)
44if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR
45 CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR
46 CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR
47 CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR
48 CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32")
49 if(BITS EQUAL 64)
50 set(CPU_TYPE x86_64)
51 else()
52 set(CPU_TYPE i386)
53 endif()
54 if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE})
55 set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE})
56 endif()
57elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR
58 CMAKE_SYSTEM_PROCESSOR_LC MATCHES "arm*64*")
59 set(CPU_TYPE arm64)
60elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "arm*")
61 set(CPU_TYPE arm)
62elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ppc*" OR
63 CMAKE_SYSTEM_PROCESSOR_LC MATCHES "powerpc*")
64 set(CPU_TYPE powerpc)
65else()
66 set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC})
67endif()
68message(STATUS "${BITS}-bit build (${CPU_TYPE})")
69
70
71###############################################################################
72# INSTALL DIRECTORIES
73###############################################################################
74
75if(WIN32)
76 if(MSVC)
DRCd681fa72016-12-07 10:54:54 -060077 set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}")
DRC6abd3912016-11-15 08:47:43 -060078 else()
DRCd681fa72016-12-07 10:54:54 -060079 set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}-gcc")
DRC6abd3912016-11-15 08:47:43 -060080 endif()
81 if(BITS EQUAL 64)
DRCd681fa72016-12-07 10:54:54 -060082 set(CMAKE_INSTALL_DEFAULT_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}64")
DRC6abd3912016-11-15 08:47:43 -060083 endif()
84else()
DRCd681fa72016-12-07 10:54:54 -060085 set(CMAKE_INSTALL_DEFAULT_PREFIX /opt/${CMAKE_PROJECT_NAME})
DRC6abd3912016-11-15 08:47:43 -060086endif()
87if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
DRCd681fa72016-12-07 10:54:54 -060088 set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}" CACHE PATH
89 "Directory into which to install ${CMAKE_PROJECT_NAME} (default: ${CMAKE_INSTALL_DEFAULT_PREFIX})"
DRC6abd3912016-11-15 08:47:43 -060090 FORCE)
91endif()
DRCd681fa72016-12-07 10:54:54 -060092message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
DRC6abd3912016-11-15 08:47:43 -060093
94# When the prefix is /opt/${CMAKE_PROJECT_NAME}, we assume that an "official"
95# build is being created, and thus we install things into specific locations.
DRCd681fa72016-12-07 10:54:54 -060096
DRCc8358fc2016-12-08 14:43:59 -060097if(CMAKE_INSTALL_PREFIX STREQUAL "${CMAKE_INSTALL_DEFAULT_PREFIX}")
DRCd681fa72016-12-07 10:54:54 -060098 set(CMAKE_INSTALL_DEFAULT_DATAROOTDIR "")
DRCc8358fc2016-12-08 14:43:59 -060099 set(CMAKE_INSTALL_DEFAULT_DOCDIR "<CMAKE_INSTALL_DATAROOTDIR>/doc")
100 set(CMAKE_INSTALL_DEFAULT_JAVADIR "<CMAKE_INSTALL_DATAROOTDIR>/classes")
101 if(UNIX AND NOT APPLE)
DRCd681fa72016-12-07 10:54:54 -0600102 if(BITS EQUAL 64)
103 set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib64")
104 else()
105 set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib32")
106 endif()
DRC6abd3912016-11-15 08:47:43 -0600107 endif()
DRC6abd3912016-11-15 08:47:43 -0600108endif()
DRC6abd3912016-11-15 08:47:43 -0600109
DRCd681fa72016-12-07 10:54:54 -0600110include(cmakescripts/GNUInstallDirs.cmake)
DRC6abd3912016-11-15 08:47:43 -0600111
DRC65302032016-12-09 10:21:29 -0600112macro(report_directory var)
DRCd681fa72016-12-07 10:54:54 -0600113 if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
114 message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
115 else()
116 message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})")
117 endif()
118 mark_as_advanced(CLEAR CMAKE_INSTALL_${var})
DRC65302032016-12-09 10:21:29 -0600119endmacro()
120
121set(DIRLIST "BINDIR;DATAROOTDIR;DOCDIR;INCLUDEDIR;LIBDIR")
122if(UNIX)
123 list(APPEND DIRLIST "MANDIR")
124endif()
125foreach(dir ${DIRLIST})
126 report_directory(${dir})
DRCd681fa72016-12-07 10:54:54 -0600127endforeach()
DRC6abd3912016-11-15 08:47:43 -0600128
129
130###############################################################################
131# CONFIGURATION OPTIONS
132###############################################################################
133
134macro(boolean_number var)
135 if(${var})
136 set(${var} 1)
137 else()
138 set(${var} 0)
139 endif()
140endmacro()
141
DRC665c96e2015-05-15 22:08:21 +0000142option(ENABLE_SHARED "Build shared libraries" TRUE)
DRC6abd3912016-11-15 08:47:43 -0600143boolean_number(ENABLE_SHARED)
144option(ENABLE_STATIC "Build static libraries" TRUE)
145boolean_number(ENABLE_STATIC)
146option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE)
147boolean_number(REQUIRE_SIMD)
148option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE)
149boolean_number(WITH_12BIT)
150option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE)
151boolean_number(WITH_ARITH_DEC)
152option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE)
153boolean_number(WITH_ARITH_ENC)
154option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE)
155boolean_number(WITH_JAVA)
156option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
157boolean_number(WITH_JPEG7)
158option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
159boolean_number(WITH_JPEG8)
160option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE)
161boolean_number(WITH_MEM_SRCDST)
162option(WITH_SIMD "Include SIMD extensions, if available for this platform" TRUE)
163boolean_number(WITH_SIMD)
164option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" TRUE)
165boolean_number(WITH_TURBOJPEG)
166
167macro(report_option var desc)
168 if(${var})
169 message(STATUS "${desc} enabled (${var} = ${${var}})")
170 else()
171 message(STATUS "${desc} disabled (${var} = ${${var}})")
172 endif()
173endmacro()
174
175if(WITH_JAVA)
176 set(ENABLE_SHARED 1)
177endif()
178
179# Explicitly setting CMAKE_POSITION_INDEPENDENT_CODE=FALSE disables PIC for all
180# targets, which will cause the shared library builds to fail. Thus, if shared
181# libraries are enabled and CMAKE_POSITION_INDEPENDENT_CODE is explicitly set
182# to FALSE, we need to unset it, thus restoring the default behavior
183# (automatically using PIC for shared library targets.)
184if(DEFINED CMAKE_POSITION_INDEPENDENT_CODE AND
185 NOT CMAKE_POSITION_INDEPENDENT_CODE AND ENABLE_SHARED)
186 unset(CMAKE_POSITION_INDEPENDENT_CODE CACHE)
187endif()
188
189report_option(ENABLE_SHARED "Shared libraries")
190report_option(ENABLE_STATIC "Static libraries")
DRCaee4f722014-08-09 23:06:07 +0000191
DRCc868e412019-01-01 14:26:48 -0600192if(ENABLE_SHARED)
193 set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
194endif()
195
DRCaee4f722014-08-09 23:06:07 +0000196if(WITH_12BIT)
DRC6abd3912016-11-15 08:47:43 -0600197 set(WITH_ARITH_DEC 0)
198 set(WITH_ARITH_ENC 0)
199 set(WITH_JAVA 0)
200 set(WITH_SIMD 0)
201 set(WITH_TURBOJPEG 0)
DRCaee4f722014-08-09 23:06:07 +0000202 set(BITS_IN_JSAMPLE 12)
DRCaee4f722014-08-09 23:06:07 +0000203else()
204 set(BITS_IN_JSAMPLE 8)
205endif()
DRC6abd3912016-11-15 08:47:43 -0600206report_option(WITH_12BIT "12-bit JPEG support")
DRC245cfdf2010-11-23 17:11:06 +0000207
DRC5c064de2016-05-09 20:00:46 -0500208if(WITH_JPEG8 OR WITH_JPEG7)
209 set(WITH_ARITH_ENC 1)
210 set(WITH_ARITH_DEC 1)
211endif()
212if(WITH_JPEG8)
DRC6abd3912016-11-15 08:47:43 -0600213 set(WITH_MEM_SRCDST 0)
DRC245cfdf2010-11-23 17:11:06 +0000214endif()
215
216if(WITH_ARITH_DEC)
217 set(D_ARITH_CODING_SUPPORTED 1)
DRC6abd3912016-11-15 08:47:43 -0600218endif()
219if(NOT WITH_12BIT)
220 report_option(WITH_ARITH_DEC "Arithmetic decoding support")
DRC245cfdf2010-11-23 17:11:06 +0000221endif()
222
DRC6abd3912016-11-15 08:47:43 -0600223if(WITH_ARITH_ENC)
224 set(C_ARITH_CODING_SUPPORTED 1)
225endif()
226if(NOT WITH_12BIT)
227 report_option(WITH_ARITH_ENC "Arithmetic encoding support")
DRCaee4f722014-08-09 23:06:07 +0000228endif()
229
DRC6abd3912016-11-15 08:47:43 -0600230if(NOT WITH_12BIT)
231 report_option(WITH_TURBOJPEG "TurboJPEG API library")
232 report_option(WITH_JAVA "TurboJPEG Java wrapper")
DRC218c0c12011-02-05 06:01:18 +0000233endif()
234
DRCab706232013-01-18 23:42:31 +0000235if(WITH_MEM_SRCDST)
236 set(MEM_SRCDST_SUPPORTED 1)
DRC6abd3912016-11-15 08:47:43 -0600237 set(MEM_SRCDST_FUNCTIONS "global: jpeg_mem_dest; jpeg_mem_src;")
DRCab706232013-01-18 23:42:31 +0000238endif()
DRC6abd3912016-11-15 08:47:43 -0600239if(NOT WITH_JPEG8)
240 report_option(WITH_MEM_SRCDST "In-memory source/destination managers")
241endif()
242
DRC44b23992017-01-19 15:18:57 -0600243set(SO_AGE 2)
DRC6abd3912016-11-15 08:47:43 -0600244if(WITH_MEM_SRCDST)
DRC44b23992017-01-19 15:18:57 -0600245 set(SO_AGE 3)
DRC6abd3912016-11-15 08:47:43 -0600246endif()
247
248if(WITH_JPEG8)
249 set(JPEG_LIB_VERSION 80)
250elseif(WITH_JPEG7)
251 set(JPEG_LIB_VERSION 70)
252else()
253 set(JPEG_LIB_VERSION 62)
254endif()
255
256math(EXPR JPEG_LIB_VERSION_DIV10 "${JPEG_LIB_VERSION} / 10")
257math(EXPR JPEG_LIB_VERSION_MOD10 "${JPEG_LIB_VERSION} % 10")
258if(JPEG_LIB_VERSION STREQUAL "62")
259 set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION})
260else()
261 set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION_DIV10})
262endif()
263if(JPEG_LIB_VERSION STREQUAL "80")
264 set(DEFAULT_SO_MINOR_VERSION 2)
265else()
266 set(DEFAULT_SO_MINOR_VERSION 0)
267endif()
268
269# This causes SO_MAJOR_VERSION/SO_MINOR_VERSION to reset to defaults if
270# WITH_JPEG7 or WITH_JPEG8 has changed.
271if((DEFINED WITH_JPEG7_INT AND NOT WITH_JPEG7 EQUAL WITH_JPEG7_INT) OR
272 (DEFINED WITH_JPEG8_INT AND NOT WITH_JPEG8 EQUAL WITH_JPEG8_INT))
273 set(FORCE_SO_VERSION "FORCE")
274endif()
275set(WITH_JPEG7_INT ${WITH_JPEG7} CACHE INTERNAL "")
276set(WITH_JPEG8_INT ${WITH_JPEG8} CACHE INTERNAL "")
277
278set(SO_MAJOR_VERSION ${DEFAULT_SO_MAJOR_VERSION} CACHE STRING
279 "Major version of the libjpeg API shared library (default: ${DEFAULT_SO_MAJOR_VERSION})"
280 ${FORCE_SO_VERSION})
281set(SO_MINOR_VERSION ${DEFAULT_SO_MINOR_VERSION} CACHE STRING
282 "Minor version of the libjpeg API shared library (default: ${DEFAULT_SO_MINOR_VERSION})"
283 ${FORCE_SO_VERSION})
284
285set(JPEG_LIB_VERSION_DECIMAL "${JPEG_LIB_VERSION_DIV10}.${JPEG_LIB_VERSION_MOD10}")
286message(STATUS "Emulating libjpeg API/ABI v${JPEG_LIB_VERSION_DECIMAL} (WITH_JPEG7 = ${WITH_JPEG7}, WITH_JPEG8 = ${WITH_JPEG8})")
287message(STATUS "libjpeg API shared library version = ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION}")
288
289# Because the TurboJPEG API library uses versioned symbols and changes the
290# names of functions whenever they are modified in a backward-incompatible
291# manner, it is always backward-ABI-compatible with itself, so the major and
292# minor SO versions don't change. However, we increase the middle number (the
293# SO "age") whenever functions are added to the API.
294set(TURBOJPEG_SO_MAJOR_VERSION 0)
DRCb9ab64d2017-05-11 21:02:29 -0500295set(TURBOJPEG_SO_VERSION 0.2.0)
DRC6abd3912016-11-15 08:47:43 -0600296
297
298###############################################################################
299# COMPILER SETTINGS
300###############################################################################
DRCab706232013-01-18 23:42:31 +0000301
DRC84697032010-10-15 03:43:24 +0000302if(MSVC)
DRC89a3f972015-03-19 19:27:40 +0000303 option(WITH_CRT_DLL
DRC6abd3912016-11-15 08:47:43 -0600304 "Link all ${CMAKE_PROJECT_NAME} 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."
DRC89a3f972015-03-19 19:27:40 +0000305 FALSE)
306 if(NOT WITH_CRT_DLL)
307 # Use the static C library for all build types
308 foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
309 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
310 if(${var} MATCHES "/MD")
311 string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
312 endif()
313 endforeach()
314 endif()
DRC6abd3912016-11-15 08:47:43 -0600315 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /wd4996")
DRC84697032010-10-15 03:43:24 +0000316endif()
317
DRC6abd3912016-11-15 08:47:43 -0600318if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
319 # Use the maximum optimization level for release builds
320 foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
321 if(${var} MATCHES "-O2")
322 string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}")
323 endif()
324 endforeach()
DRC84697032010-10-15 03:43:24 +0000325endif()
326
DRC6abd3912016-11-15 08:47:43 -0600327if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
328 if(CMAKE_C_COMPILER_ID MATCHES "SunPro")
329 # Use the maximum optimization level for release builds
330 foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
331 if(${var} MATCHES "-xO3")
332 string(REGEX REPLACE "-xO3" "-xO5" ${var} "${${var}}")
333 endif()
334 if(${var} MATCHES "-xO2")
335 string(REGEX REPLACE "-xO2" "-xO5" ${var} "${${var}}")
336 endif()
337 endforeach()
DRC7175e512013-04-23 22:29:00 +0000338 endif()
DRC7175e512013-04-23 22:29:00 +0000339endif()
340
DRC03841e62016-02-09 18:27:27 -0600341string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
342
343set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
344message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}")
345
346set(EFFECTIVE_LD_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
347message(STATUS "Linker flags = ${EFFECTIVE_LD_FLAGS}")
348
DRC6abd3912016-11-15 08:47:43 -0600349include(CheckCSourceCompiles)
mayeut16bd9842018-03-02 22:33:19 +0100350include(CheckIncludeFiles)
351include(CheckTypeSize)
352
353check_type_size("size_t" SIZE_T)
354check_type_size("unsigned long" UNSIGNED_LONG)
355
356if(SIZE_T EQUAL UNSIGNED_LONG)
357 check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }"
358 HAVE_BUILTIN_CTZL)
359endif()
DRCa74655a2018-03-31 15:34:23 -0500360if(MSVC)
361 check_include_files("intrin.h" HAVE_INTRIN_H)
362endif()
DRC6abd3912016-11-15 08:47:43 -0600363
364if(UNIX)
365 # Check for headers
DRC6abd3912016-11-15 08:47:43 -0600366 check_include_files(locale.h HAVE_LOCALE_H)
367 check_include_files(stddef.h HAVE_STDDEF_H)
368 check_include_files(stdlib.h HAVE_STDLIB_H)
369 check_include_files(sys/types.h NEED_SYS_TYPES_H)
370
371 # Check for functions
DRC13e48032018-03-31 16:19:01 -0500372 include(CheckSymbolExists)
373 check_symbol_exists(memset string.h HAVE_MEMSET)
374 check_symbol_exists(memcpy string.h HAVE_MEMCPY)
DRC6abd3912016-11-15 08:47:43 -0600375 if(NOT HAVE_MEMSET AND NOT HAVE_MEMCPY)
376 set(NEED_BSD_STRINGS 1)
377 endif()
378
379 # Check for types
DRC6abd3912016-11-15 08:47:43 -0600380 check_type_size("unsigned char" UNSIGNED_CHAR)
381 check_type_size("unsigned short" UNSIGNED_SHORT)
DRC6abd3912016-11-15 08:47:43 -0600382
383 # Check for compiler features
DRC13e48032018-03-31 16:19:01 -0500384 check_c_source_compiles("int main(void) { typedef struct undefined_structure *undef_struct_ptr; undef_struct_ptr ptr = 0; return ptr != 0; }"
DRC6abd3912016-11-15 08:47:43 -0600385 INCOMPLETE_TYPES)
386 if(INCOMPLETE_TYPES)
387 message(STATUS "Compiler supports pointers to undefined structures.")
388 else()
389 set(INCOMPLETE_TYPES_BROKEN 1)
390 message(STATUS "Compiler does not support pointers to undefined structures.")
391 endif()
392
393 if(CMAKE_CROSSCOMPILING)
394 set(RIGHT_SHIFT_IS_UNSIGNED 0)
395 else()
396 include(CheckCSourceRuns)
397 check_c_source_runs("
398 #include <stdio.h>
399 #include <stdlib.h>
400 int is_shifting_signed (long arg) {
401 long res = arg >> 4;
402 if (res == -0x7F7E80CL)
403 return 1; /* right shift is signed */
404 /* see if unsigned-shift hack will fix it. */
405 /* we can't just test exact value since it depends on width of long... */
406 res |= (~0L) << (32-4);
407 if (res == -0x7F7E80CL)
408 return 0; /* right shift is unsigned */
409 printf(\"Right shift isn't acting as I expect it to.\\\\n\");
410 printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
411 return 0; /* try it with unsigned anyway */
412 }
413 int main (void) {
414 exit(is_shifting_signed(-0x7F7E80B1L));
415 }" RIGHT_SHIFT_IS_UNSIGNED)
416 endif()
417
418 if(CMAKE_CROSSCOMPILING)
419 set(__CHAR_UNSIGNED__ 0)
420 else()
421 check_c_source_runs("int main(void) { return ((char) -1 < 0); }"
422 __CHAR_UNSIGNED__)
DRCdb425062011-04-03 06:10:18 +0000423 endif()
DRC218c0c12011-02-05 06:01:18 +0000424endif()
425
DRC2af2fe42016-12-05 16:52:54 -0600426if(MSVC)
427 set(INLINE_OPTIONS "__inline;inline")
428else()
429 set(INLINE_OPTIONS "__inline__;inline")
430endif()
DRC6abd3912016-11-15 08:47:43 -0600431option(FORCE_INLINE "Force function inlining" TRUE)
432boolean_number(FORCE_INLINE)
433if(FORCE_INLINE)
434 if(MSVC)
DRC2af2fe42016-12-05 16:52:54 -0600435 list(INSERT INLINE_OPTIONS 0 "__forceinline")
DRC6abd3912016-11-15 08:47:43 -0600436 else()
DRC2af2fe42016-12-05 16:52:54 -0600437 list(INSERT INLINE_OPTIONS 0 "inline __attribute__((always_inline))")
438 list(INSERT INLINE_OPTIONS 0 "__inline__ __attribute__((always_inline))")
DRC6abd3912016-11-15 08:47:43 -0600439 endif()
440endif()
DRC2af2fe42016-12-05 16:52:54 -0600441foreach(inline ${INLINE_OPTIONS})
DRC13e48032018-03-31 16:19:01 -0500442 check_c_source_compiles("${inline} static int foo(void) { return 0; } int main(void) { return foo(); }"
DRC2af2fe42016-12-05 16:52:54 -0600443 INLINE_WORKS)
444 if(INLINE_WORKS)
445 set(INLINE ${inline})
446 break()
DRC6abd3912016-11-15 08:47:43 -0600447 endif()
DRC2af2fe42016-12-05 16:52:54 -0600448endforeach()
449if(NOT INLINE_WORKS)
450 message(FATAL_ERROR "Could not determine how to inline functions.")
DRC6abd3912016-11-15 08:47:43 -0600451endif()
452message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})")
DRC84697032010-10-15 03:43:24 +0000453
DRC6abd3912016-11-15 08:47:43 -0600454if(UNIX AND NOT APPLE)
455 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };")
456 set(CMAKE_REQUIRED_FLAGS
457 "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
458 check_c_source_compiles("int main(void) { return 0; }" HAVE_VERSION_SCRIPT)
459 set(CMAKE_REQUIRED_FLAGS)
460 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
461 if(HAVE_VERSION_SCRIPT)
462 message(STATUS "Linker supports GNU-style version scripts")
463 set(MAPFLAG "-Wl,--version-script,")
464 set(TJMAPFLAG "-Wl,--version-script,")
465 else()
466 message(STATUS "Linker does not support GNU-style version scripts")
467 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
468 # The Solaris linker doesn't like our version script for the libjpeg API
469 # library, but the version script for the TurboJPEG API library should
470 # still work.
471 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map
472 "VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;")
DRC43ce78e2018-11-15 11:54:20 -0600473 set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared")
474 check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }"
DRC6abd3912016-11-15 08:47:43 -0600475 HAVE_MAPFILE)
476 set(CMAKE_REQUIRED_FLAGS)
477 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
478 if(HAVE_MAPFILE)
479 message(STATUS "Linker supports mapfiles")
480 set(TJMAPFLAG "-Wl,-M,")
481 else()
482 message(STATUS "Linker does not support mapfiles")
483 endif()
484 endif()
485 endif()
486endif()
487
488# Generate files
489if(WIN32)
490 configure_file(win/jconfig.h.in jconfig.h)
491else()
492 configure_file(jconfig.h.in jconfig.h)
493endif()
494configure_file(jconfigint.h.in jconfigint.h)
495if(UNIX)
496 configure_file(libjpeg.map.in libjpeg.map)
497endif()
498
499# Include directories and compiler definitions
DRC952191d2016-12-03 14:21:11 -0600500include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
DRC6abd3912016-11-15 08:47:43 -0600501
502
503###############################################################################
504# TARGETS
505###############################################################################
DRC84697032010-10-15 03:43:24 +0000506
DRC0fa78502018-07-20 11:30:04 -0500507if(CMAKE_EXECUTABLE_SUFFIX_TMP)
508 set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX_TMP})
509endif()
510message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}")
511
DRC245cfdf2010-11-23 17:11:06 +0000512set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
DRC44b23992017-01-19 15:18:57 -0600513 jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c
514 jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c
515 jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c
516 jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c
517 jdtrans.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c
518 jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
DRC245cfdf2010-11-23 17:11:06 +0000519
520if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
521 set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
522endif()
523
524if(WITH_ARITH_ENC)
525 set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
526endif()
527
528if(WITH_ARITH_DEC)
529 set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
530endif()
DRC84697032010-10-15 03:43:24 +0000531
532if(WITH_SIMD)
DRC84697032010-10-15 03:43:24 +0000533 add_subdirectory(simd)
DRC6abd3912016-11-15 08:47:43 -0600534elseif(NOT WITH_12BIT)
535 message(STATUS "SIMD extensions: None (WITH_SIMD = ${WITH_SIMD})")
536endif()
537if(WITH_SIMD)
538 message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})")
DRCf37b7c12019-07-02 11:28:26 -0500539 if(MSVC_IDE OR XCODE)
DRC6abd3912016-11-15 08:47:43 -0600540 set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
DRC84697032010-10-15 03:43:24 +0000541 endif()
DRC84697032010-10-15 03:43:24 +0000542else()
DRC6abd3912016-11-15 08:47:43 -0600543 add_library(simd OBJECT jsimd_none.c)
DRC84697032010-10-15 03:43:24 +0000544endif()
545
DRC957d6232011-04-01 11:13:11 +0000546if(WITH_JAVA)
547 add_subdirectory(java)
548endif()
549
DRC665c96e2015-05-15 22:08:21 +0000550if(ENABLE_SHARED)
551 add_subdirectory(sharedlib)
DRC84697032010-10-15 03:43:24 +0000552endif()
DRC665c96e2015-05-15 22:08:21 +0000553
DRC6abd3912016-11-15 08:47:43 -0600554if(ENABLE_STATIC)
555 add_library(jpeg-static STATIC ${JPEG_SOURCES} $<TARGET_OBJECTS:simd>
556 ${SIMD_OBJS})
DRC665c96e2015-05-15 22:08:21 +0000557 if(NOT MSVC)
558 set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
559 endif()
DRC84697032010-10-15 03:43:24 +0000560endif()
561
DRCaee4f722014-08-09 23:06:07 +0000562if(WITH_TURBOJPEG)
DRC665c96e2015-05-15 22:08:21 +0000563 if(ENABLE_SHARED)
DRC6abd3912016-11-15 08:47:43 -0600564 set(TURBOJPEG_SOURCES ${JPEG_SOURCES} $<TARGET_OBJECTS:simd> ${SIMD_OBJS}
DRCaa745902017-11-16 18:09:07 -0600565 turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c rdppm.c
566 wrbmp.c wrppm.c)
DRC952191d2016-12-03 14:21:11 -0600567 set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile)
DRC6abd3912016-11-15 08:47:43 -0600568 if(WITH_JAVA)
569 set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
570 include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
DRC952191d2016-12-03 14:21:11 -0600571 set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile.jni)
DRC6abd3912016-11-15 08:47:43 -0600572 endif()
DRC665c96e2015-05-15 22:08:21 +0000573 add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
DRCaa745902017-11-16 18:09:07 -0600574 set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS
575 "-DBMP_SUPPORTED -DPPM_SUPPORTED")
DRC6abd3912016-11-15 08:47:43 -0600576 if(WIN32)
577 set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
578 endif()
DRC665c96e2015-05-15 22:08:21 +0000579 if(MINGW)
580 set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
581 endif()
DRC8d95be32018-07-24 21:16:00 -0500582 if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR
583 CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4))
DRCc80ddef2018-03-23 23:17:08 -0500584 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
585 set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
586 endif()
DRC27d4c5e2016-11-23 17:12:57 -0600587 set_target_properties(turbojpeg PROPERTIES MACOSX_RPATH 1)
588 endif()
DRC6abd3912016-11-15 08:47:43 -0600589 set_target_properties(turbojpeg PROPERTIES
590 SOVERSION ${TURBOJPEG_SO_MAJOR_VERSION} VERSION ${TURBOJPEG_SO_VERSION})
591 if(TJMAPFLAG)
592 set_target_properties(turbojpeg PROPERTIES
593 LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}")
594 endif()
DRCaee4f722014-08-09 23:06:07 +0000595
DRCaa745902017-11-16 18:09:07 -0600596 add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c)
DRC665c96e2015-05-15 22:08:21 +0000597 target_link_libraries(tjunittest turbojpeg)
598
DRCaa745902017-11-16 18:09:07 -0600599 add_executable(tjbench tjbench.c tjutil.c)
600 target_link_libraries(tjbench turbojpeg)
DRC6abd3912016-11-15 08:47:43 -0600601 if(UNIX)
602 target_link_libraries(tjbench m)
603 endif()
DRC8c40ac82017-11-16 18:46:01 -0600604
605 add_executable(tjexample tjexample.c)
606 target_link_libraries(tjexample turbojpeg)
DRCaee4f722014-08-09 23:06:07 +0000607 endif()
608
DRC665c96e2015-05-15 22:08:21 +0000609 if(ENABLE_STATIC)
DRC6abd3912016-11-15 08:47:43 -0600610 add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $<TARGET_OBJECTS:simd>
DRCaa745902017-11-16 18:09:07 -0600611 ${SIMD_OBJS} turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c
612 rdppm.c wrbmp.c wrppm.c)
613 set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS
614 "-DBMP_SUPPORTED -DPPM_SUPPORTED")
DRC665c96e2015-05-15 22:08:21 +0000615 if(NOT MSVC)
616 set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
617 endif()
DRCaee4f722014-08-09 23:06:07 +0000618
DRCaa745902017-11-16 18:09:07 -0600619 add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c
620 md5/md5hl.c)
DRC665c96e2015-05-15 22:08:21 +0000621 target_link_libraries(tjunittest-static turbojpeg-static)
DRCaee4f722014-08-09 23:06:07 +0000622
DRCaa745902017-11-16 18:09:07 -0600623 add_executable(tjbench-static tjbench.c tjutil.c)
624 target_link_libraries(tjbench-static turbojpeg-static)
DRC6abd3912016-11-15 08:47:43 -0600625 if(UNIX)
626 target_link_libraries(tjbench-static m)
627 endif()
DRC665c96e2015-05-15 22:08:21 +0000628 endif()
DRC218c0c12011-02-05 06:01:18 +0000629endif()
630
DRC6abd3912016-11-15 08:47:43 -0600631if(WIN32)
632 set(USE_SETMODE "-DUSE_SETMODE")
633endif()
DRCaee4f722014-08-09 23:06:07 +0000634if(WITH_12BIT)
DRC6abd3912016-11-15 08:47:43 -0600635 set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}")
DRCaee4f722014-08-09 23:06:07 +0000636else()
DRC6abd3912016-11-15 08:47:43 -0600637 set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
DRCecc58362015-06-27 07:56:29 +0000638 set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
639 set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
DRC84697032010-10-15 03:43:24 +0000640endif()
641
DRC665c96e2015-05-15 22:08:21 +0000642if(ENABLE_STATIC)
643 add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
644 ${CJPEG_BMP_SOURCES})
645 set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
646 target_link_libraries(cjpeg-static jpeg-static)
DRC84697032010-10-15 03:43:24 +0000647
DRC665c96e2015-05-15 22:08:21 +0000648 add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
649 wrppm.c ${DJPEG_BMP_SOURCES})
650 set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
651 target_link_libraries(djpeg-static jpeg-static)
DRC84697032010-10-15 03:43:24 +0000652
DRC665c96e2015-05-15 22:08:21 +0000653 add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
654 target_link_libraries(jpegtran-static jpeg-static)
DRC6abd3912016-11-15 08:47:43 -0600655 set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "${USE_SETMODE}")
DRC665c96e2015-05-15 22:08:21 +0000656endif()
DRC84697032010-10-15 03:43:24 +0000657
658add_executable(rdjpgcom rdjpgcom.c)
659
DRCa81f5422014-06-22 20:50:14 +0000660add_executable(wrjpgcom wrjpgcom.c)
DRC84697032010-10-15 03:43:24 +0000661
662
DRC6abd3912016-11-15 08:47:43 -0600663###############################################################################
664# TESTS
665###############################################################################
DRC84697032010-10-15 03:43:24 +0000666
DRCf9134382016-02-06 14:09:20 -0600667add_subdirectory(md5)
668
DRCf37b7c12019-07-02 11:28:26 -0500669if(MSVC_IDE OR XCODE)
DRC957d6232011-04-01 11:13:11 +0000670 set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
671else()
672 set(OBJDIR "")
673endif()
674
DRC84697032010-10-15 03:43:24 +0000675enable_testing()
DRC211d1e72013-01-13 11:25:20 +0000676
DRCaee4f722014-08-09 23:06:07 +0000677if(WITH_12BIT)
678 set(TESTORIG testorig12.jpg)
DRC44b23992017-01-19 15:18:57 -0600679 set(MD5_JPEG_RGB_ISLOW 9d7369207c520d37f2c1cbfcb82b2964)
680 set(MD5_JPEG_RGB_ISLOW2 a00bd20d8ae49684640ef7177d2e0b64)
DRCaee4f722014-08-09 23:06:07 +0000681 set(MD5_PPM_RGB_ISLOW f3301d2219783b8b3d942b7239fa50c0)
682 set(MD5_JPEG_422_IFAST_OPT 7322e3bd2f127f7de4b40d4480ce60e4)
683 set(MD5_PPM_422_IFAST 79807fa552899e66a04708f533e16950)
684 set(MD5_PPM_422M_IFAST 07737bfe8a7c1c87aaa393a0098d16b0)
DRCa81a8c12019-08-14 13:17:11 -0500685 set(MD5_JPEG_420_IFAST_Q100_PROG 008ab68d6ddbba04a8f01deee4e0f9f8)
DRCaee4f722014-08-09 23:06:07 +0000686 set(MD5_PPM_420_Q100_IFAST 1b3730122709f53d007255e8dfd3305e)
687 set(MD5_PPM_420M_Q100_IFAST 980a1a3c5bf9510022869d30b7d26566)
688 set(MD5_JPEG_GRAY_ISLOW 235c90707b16e2e069f37c888b2636d9)
689 set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca)
690 set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d)
691 set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
DRC6abd3912016-11-15 08:47:43 -0600692
693 set(MD5_JPEG_3x2_FLOAT_PROG_SSE a8c17daf77b457725ec929e215b603f8)
694 set(MD5_PPM_3x2_FLOAT_SSE 42876ab9e5c2f76a87d08db5fbd57956)
695 set(MD5_JPEG_3x2_FLOAT_PROG_32BIT a8c17daf77b457725ec929e215b603f8)
696 set(MD5_PPM_3x2_FLOAT_32BIT ${MD5_PPM_3x2_FLOAT_SSE})
697 set(MD5_JPEG_3x2_FLOAT_PROG_64BIT ${MD5_JPEG_3x2_FLOAT_PROG_32BIT})
698 set(MD5_PPM_3x2_FLOAT_64BIT ${MD5_PPM_3x2_FLOAT_SSE})
699 set(MD5_JPEG_3x2_FLOAT_PROG_387 bc6dbbefac2872f6b9d6c4a0ae60c3c0)
700 set(MD5_PPM_3x2_FLOAT_387 bcc5723c61560463ac60f772e742d092)
701 set(MD5_JPEG_3x2_FLOAT_PROG_MSVC e27840755870fa849872e58aa0cd1400)
702 set(MD5_PPM_3x2_FLOAT_MSVC 6c2880b83bb1aa41dfe330e7a9768690)
703
704 set(MD5_JPEG_3x2_IFAST_PROG 1396cc2b7185cfe943d408c9d305339e)
705 set(MD5_PPM_3x2_IFAST 3975985ef6eeb0a2cdc58daa651ccc00)
DRCaee4f722014-08-09 23:06:07 +0000706 set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0)
707 set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb)
708 set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96)
709 set(MD5_PPM_420M_ISLOW_11_8 800a16f9f4dc9b293197bfe11be10a82)
710 set(MD5_PPM_420M_ISLOW_9_8 06b7a92a9bc69f4dc36ec40f1937d55c)
711 set(MD5_PPM_420M_ISLOW_7_8 3ec444a14a4ab4eab88ffc49c48eca43)
712 set(MD5_PPM_420M_ISLOW_3_4 3e726b7ea872445b19437d1c1d4f0d93)
713 set(MD5_PPM_420M_ISLOW_5_8 a8a771abdc94301d20ffac119b2caccd)
714 set(MD5_PPM_420M_ISLOW_1_2 b419124dd5568b085787234866102866)
715 set(MD5_PPM_420M_ISLOW_3_8 343d19015531b7bbe746124127244fa8)
716 set(MD5_PPM_420M_ISLOW_1_4 35fd59d866e44659edfa3c18db2a3edb)
717 set(MD5_PPM_420M_ISLOW_1_8 ccaed48ac0aedefda5d4abe4013f4ad7)
DRC7a7da942015-06-27 08:10:31 +0000718 set(MD5_PPM_420_ISLOW_SKIP15_31 86664cd9dc956536409e44e244d20a97)
DRC3ab68cf2016-02-19 18:32:10 -0600719 set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 452a21656115a163029cfba5c04fa76a)
DRC7a7da942015-06-27 08:10:31 +0000720 set(MD5_PPM_444_ISLOW_SKIP1_6 ef63901f71ef7a75cd78253fc0914f84)
DRC3ab68cf2016-02-19 18:32:10 -0600721 set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 15b173fb5872d9575572fbcc1b05956f)
DRCaee4f722014-08-09 23:06:07 +0000722 set(MD5_JPEG_CROP cdb35ff4b4519392690ea040c56ea99c)
DRC35db75e2014-05-06 22:44:46 +0000723else()
DRCaee4f722014-08-09 23:06:07 +0000724 set(TESTORIG testorig.jpg)
DRC44b23992017-01-19 15:18:57 -0600725 set(MD5_JPEG_RGB_ISLOW 1d44a406f61da743b5fd31c0a9abdca3)
726 set(MD5_JPEG_RGB_ISLOW2 31d121e57b6c2934c890a7fc7763bcd4)
DRCaee4f722014-08-09 23:06:07 +0000727 set(MD5_PPM_RGB_ISLOW 00a257f5393fef8821f2b88ac7421291)
728 set(MD5_BMP_RGB_ISLOW_565 f07d2e75073e4bb10f6c6f4d36e2e3be)
729 set(MD5_BMP_RGB_ISLOW_565D 4cfa0928ef3e6bb626d7728c924cfda4)
730 set(MD5_JPEG_422_IFAST_OPT 2540287b79d913f91665e660303ab2c8)
731 set(MD5_PPM_422_IFAST 35bd6b3f833bad23de82acea847129fa)
732 set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
733 set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
734 set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
DRCa81a8c12019-08-14 13:17:11 -0500735 set(MD5_JPEG_420_IFAST_Q100_PROG e59bb462016a8d9a748c330a3474bb55)
DRCaee4f722014-08-09 23:06:07 +0000736 set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
737 set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
738 set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
739 set(MD5_PPM_GRAY_ISLOW 8d3596c56eace32f205deccc229aa5ed)
740 set(MD5_PPM_GRAY_ISLOW_RGB 116424ac07b79e5e801f00508eab48ec)
741 set(MD5_BMP_GRAY_ISLOW_565 12f78118e56a2f48b966f792fedf23cc)
742 set(MD5_BMP_GRAY_ISLOW_565D bdbbd616441a24354c98553df5dc82db)
743 set(MD5_JPEG_420S_IFAST_OPT 388708217ac46273ca33086b22827ed8)
DRC6abd3912016-11-15 08:47:43 -0600744
745 set(MD5_JPEG_3x2_FLOAT_PROG_SSE 343e3f8caf8af5986ebaf0bdc13b5c71)
746 set(MD5_PPM_3x2_FLOAT_SSE 1a75f36e5904d6fc3a85a43da9ad89bb)
747 set(MD5_JPEG_3x2_FLOAT_PROG_32BIT 9bca803d2042bd1eb03819e2bf92b3e5)
748 set(MD5_PPM_3x2_FLOAT_32BIT f6bfab038438ed8f5522fbd33595dcdc)
749 set(MD5_JPEG_3x2_FLOAT_PROG_64BIT ${MD5_JPEG_3x2_FLOAT_PROG_32BIT})
750 set(MD5_PPM_3x2_FLOAT_64BIT 0e917a34193ef976b679a6b069b1be26)
751 set(MD5_JPEG_3x2_FLOAT_PROG_387 1657664a410e0822c924b54f6f65e6e9)
752 set(MD5_PPM_3x2_FLOAT_387 cb0a1f027f3d2917c902b5640214e025)
753 set(MD5_JPEG_3x2_FLOAT_PROG_MSVC 7999ce9cd0ee9b6c7043b7351ab7639d)
754 set(MD5_PPM_3x2_FLOAT_MSVC 28cdc448a6b75e97892f0e0f8d4b21f3)
755
756 set(MD5_JPEG_3x2_IFAST_PROG 1ee5d2c1a77f2da495f993c8c7cceca5)
757 set(MD5_PPM_3x2_IFAST fd283664b3b49127984af0a7f118fccd)
DRCaee4f722014-08-09 23:06:07 +0000758 set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
759 set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
760 set(MD5_PPM_420M_IFAST_ARI 72b59a99bcf1de24c5b27d151bde2437)
761 set(MD5_JPEG_420_ISLOW 9a68f56bc76e466aa7e52f415d0f4a5f)
762 set(MD5_PPM_420M_ISLOW_2_1 9f9de8c0612f8d06869b960b05abf9c9)
763 set(MD5_PPM_420M_ISLOW_15_8 b6875bc070720b899566cc06459b63b7)
764 set(MD5_PPM_420M_ISLOW_13_8 bc3452573c8152f6ae552939ee19f82f)
765 set(MD5_PPM_420M_ISLOW_11_8 d8cc73c0aaacd4556569b59437ba00a5)
766 set(MD5_PPM_420M_ISLOW_9_8 d25e61bc7eac0002f5b393aa223747b6)
767 set(MD5_PPM_420M_ISLOW_7_8 ddb564b7c74a09494016d6cd7502a946)
768 set(MD5_PPM_420M_ISLOW_3_4 8ed8e68808c3fbc4ea764fc9d2968646)
769 set(MD5_PPM_420M_ISLOW_5_8 a3363274999da2366a024efae6d16c9b)
770 set(MD5_PPM_420M_ISLOW_1_2 e692a315cea26b988c8e8b29a5dbcd81)
771 set(MD5_PPM_420M_ISLOW_3_8 79eca9175652ced755155c90e785a996)
772 set(MD5_PPM_420M_ISLOW_1_4 79cd778f8bf1a117690052cacdd54eca)
773 set(MD5_PPM_420M_ISLOW_1_8 391b3d4aca640c8567d6f8745eb2142f)
774 set(MD5_BMP_420_ISLOW_256 4980185e3776e89bd931736e1cddeee6)
775 set(MD5_BMP_420_ISLOW_565 bf9d13e16c4923b92e1faa604d7922cb)
776 set(MD5_BMP_420_ISLOW_565D 6bde71526acc44bcff76f696df8638d2)
777 set(MD5_BMP_420M_ISLOW_565 8dc0185245353cfa32ad97027342216f)
DRCd4859552018-02-13 16:14:03 -0600778 set(MD5_BMP_420M_ISLOW_565D ce034037d212bc403330df6f915c161b)
DRC7a7da942015-06-27 08:10:31 +0000779 set(MD5_PPM_420_ISLOW_SKIP15_31 c4c65c1e43d7275cd50328a61e6534f0)
780 set(MD5_PPM_420_ISLOW_ARI_SKIP16_139 087c6b123db16ac00cb88c5b590bb74a)
DRC3ab68cf2016-02-19 18:32:10 -0600781 set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 26eb36ccc7d1f0cb80cdabb0ac8b5d99)
782 set(MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4 886c6775af22370257122f8b16207e6d)
DRC7a7da942015-06-27 08:10:31 +0000783 set(MD5_PPM_444_ISLOW_SKIP1_6 5606f86874cf26b8fcee1117a0a436a6)
DRC3ab68cf2016-02-19 18:32:10 -0600784 set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 db87dc7ce26bcdc7a6b56239ce2b9d6c)
785 set(MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0 cb57b32bd6d03e35432362f7bf184b6d)
DRCaee4f722014-08-09 23:06:07 +0000786 set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
DRC35db75e2014-05-06 22:44:46 +0000787endif()
DRC211d1e72013-01-13 11:25:20 +0000788
DRC957d6232011-04-01 11:13:11 +0000789if(WITH_JAVA)
DRC35db75e2014-05-06 22:44:46 +0000790 add_test(TJUnitTest
DRC6abd3912016-11-15 08:47:43 -0600791 ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
DRC35db75e2014-05-06 22:44:46 +0000792 -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
793 TJUnitTest)
794 add_test(TJUnitTest-yuv
DRC6abd3912016-11-15 08:47:43 -0600795 ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
DRC35db75e2014-05-06 22:44:46 +0000796 -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
797 TJUnitTest -yuv)
798 add_test(TJUnitTest-yuv-nopad
DRC6abd3912016-11-15 08:47:43 -0600799 ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
DRC35db75e2014-05-06 22:44:46 +0000800 -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
801 TJUnitTest -yuv -noyuvpad)
802 add_test(TJUnitTest-bi
DRC6abd3912016-11-15 08:47:43 -0600803 ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
DRC35db75e2014-05-06 22:44:46 +0000804 -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
805 TJUnitTest -bi)
806 add_test(TJUnitTest-bi-yuv
DRC6abd3912016-11-15 08:47:43 -0600807 ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
DRC35db75e2014-05-06 22:44:46 +0000808 -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
809 TJUnitTest -bi -yuv)
810 add_test(TJUnitTest-bi-yuv-nopad
DRC6abd3912016-11-15 08:47:43 -0600811 ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
DRC35db75e2014-05-06 22:44:46 +0000812 -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
813 TJUnitTest -bi -yuv -noyuvpad)
DRC957d6232011-04-01 11:13:11 +0000814endif()
DRC84697032010-10-15 03:43:24 +0000815
DRC665c96e2015-05-15 22:08:21 +0000816set(TEST_LIBTYPES "")
817if(ENABLE_SHARED)
818 set(TEST_LIBTYPES ${TEST_LIBTYPES} shared)
819endif()
820if(ENABLE_STATIC)
821 set(TEST_LIBTYPES ${TEST_LIBTYPES} static)
822endif()
823
DRC952191d2016-12-03 14:21:11 -0600824set(TESTIMAGES ${CMAKE_CURRENT_SOURCE_DIR}/testimages)
DRCf9134382016-02-06 14:09:20 -0600825set(MD5CMP ${CMAKE_CURRENT_BINARY_DIR}/md5/md5cmp)
826if(CMAKE_CROSSCOMPILING)
827 file(RELATIVE_PATH TESTIMAGES ${CMAKE_CURRENT_BINARY_DIR} ${TESTIMAGES})
828 file(RELATIVE_PATH MD5CMP ${CMAKE_CURRENT_BINARY_DIR} ${MD5CMP})
829endif()
830
DRC6abd3912016-11-15 08:47:43 -0600831# The output of the floating point DCT/IDCT algorithms differs depending on the
832# type of floating point math used, so the FLOATTEST CMake variable must be
833# set in order to tell the testing system which floating point results it
834# should expect:
835#
836# sse = validate against the expected results from the libjpeg-turbo SSE SIMD
837# extensions
838# 32bit = validate against the expected results from the C code when running on
839# a 32-bit FPU (or when SSE is being used for floating point math,
840# which is generally the default with x86-64 compilers)
841# 64bit = validate against the expected results from the C code when running
842# on a 64-bit FPU
843# 387 = validate against the expected results from the C code when the 387 FPU
844# is being used for floating point math (which is generally the default
845# with x86 compilers)
846# msvc = validate against the expected results from the C code when compiled
847# with a 32-bit version of Visual C++
848
849if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
850 if(WITH_SIMD)
851 set(DEFAULT_FLOATTEST sse)
852 elseif(CPU_TYPE STREQUAL "x86_64")
853 set(DEFAULT_FLOATTEST 32bit)
854 elseif(CPU_TYPE STREQUAL "i386" AND MSVC)
855 set(DEFAULT_FLOATTEST msvc)
856 endif()
857else()
858 if(BITS EQUAL 64)
859 set(DEFAULT_FLOATTEST 64bit)
860 elseif(BITS EQUAL 32)
861 set(DEFAULT_FLOATTEST 32bit)
862 endif()
863endif()
864
865# This causes FLOATTEST to reset to the default value if WITH_SIMD has
866# changed.
867if(DEFINED WITH_SIMD_INT AND NOT WITH_SIMD EQUAL WITH_SIMD_INT)
868 set(FORCE_FLOATTEST "FORCE")
869endif()
870set(WITH_SIMD_INT ${WITH_SIMD} CACHE INTERNAL "")
871set(FLOATTEST ${DEFAULT_FLOATTEST} CACHE STRING
872 "The type of floating point math used by the floating point DCT/IDCT algorithms. This tells the testing system which numerical results it should expect from those tests. [sse = libjpeg-turbo x86/x86-64 SIMD extensions, 32bit = generic 32-bit FPU or SSE, 64bit = generic 64-bit FPU, 387 = 387 FPU, msvc = 32-bit Visual Studio] (default = ${DEFAULT_FLOATTEST})"
873 ${FORCE_FLOATTEST})
874message(STATUS "FLOATTEST = ${FLOATTEST}")
875
876if(FLOATTEST)
877 string(TOUPPER ${FLOATTEST} FLOATTEST_UC)
878 string(TOLOWER ${FLOATTEST} FLOATTEST)
879 if(NOT FLOATTEST STREQUAL "sse" AND NOT FLOATTEST STREQUAL "32bit" AND
880 NOT FLOATTEST STREQUAL "64bit" AND NOT FLOATTEST STREQUAL "387" AND
881 NOT FLOATTEST STREQUAL "msvc")
882 message(FATAL_ERROR "\"${FLOATTEST}\" is not a valid value for FLOATTEST.")
883 endif()
884endif()
885
DRC665c96e2015-05-15 22:08:21 +0000886foreach(libtype ${TEST_LIBTYPES})
DRC6abd3912016-11-15 08:47:43 -0600887 if(libtype STREQUAL "static")
DRC35db75e2014-05-06 22:44:46 +0000888 set(suffix -static)
889 endif()
DRCaee4f722014-08-09 23:06:07 +0000890 if(WITH_TURBOJPEG)
DRC6abd3912016-11-15 08:47:43 -0600891 add_test(tjunittest-${libtype} tjunittest${suffix})
892 add_test(tjunittest-${libtype}-alloc tjunittest${suffix} -alloc)
893 add_test(tjunittest-${libtype}-yuv tjunittest${suffix} -yuv)
894 add_test(tjunittest-${libtype}-yuv-alloc tjunittest${suffix} -yuv -alloc)
895 add_test(tjunittest-${libtype}-yuv-nopad tjunittest${suffix} -yuv -noyuvpad)
DRCaa745902017-11-16 18:09:07 -0600896 add_test(tjunittest-${libtype}-bmp tjunittest${suffix} -bmp)
DRC6abd3912016-11-15 08:47:43 -0600897
898 set(MD5_PPM_GRAY_TILE 89d3ca21213d9d864b50b4e4e7de4ca6)
899 set(MD5_PPM_420_8x8_TILE 847fceab15c5b7b911cb986cf0f71de3)
900 set(MD5_PPM_420_16x16_TILE ca45552a93687e078f7137cc4126a7b0)
901 set(MD5_PPM_420_32x32_TILE d8676f1d6b68df358353bba9844f4a00)
902 set(MD5_PPM_420_64x64_TILE 4e4c1a3d7ea4bace4f868bcbe83b7050)
903 set(MD5_PPM_420_128x128_TILE f24c3429c52265832beab9df72a0ceae)
904 set(MD5_PPM_420M_8x8_TILE bc25320e1f4c31ce2e610e43e9fd173c)
905 set(MD5_PPM_420M_TILE 75ffdf14602258c5c189522af57fa605)
906 set(MD5_PPM_422_8x8_TILE d83dacd9fc73b0a6f10c09acad64eb1e)
907 set(MD5_PPM_422_16x16_TILE 35077fb610d72dd743b1eb0cbcfe10fb)
908 set(MD5_PPM_422_32x32_TILE e6902ed8a449ecc0f0d6f2bf945f65f7)
909 set(MD5_PPM_422_64x64_TILE 2b4502a8f316cedbde1da7bce3d2231e)
910 set(MD5_PPM_422_128x128_TILE f0b5617d578f5e13c8eee215d64d4877)
911 set(MD5_PPM_422M_8x8_TILE 828941d7f41cd6283abd6beffb7fd51d)
912 set(MD5_PPM_422M_TILE e877ae1324c4a280b95376f7f018172f)
913 set(MD5_PPM_444_TILE 7964e41e67cfb8d0a587c0aa4798f9c3)
914
915 # Test compressing from/decompressing to an arbitrary subregion of a larger
916 # image buffer
917 add_test(tjbench-${libtype}-tile-cp
918 ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
919 testout_tile.ppm)
920 add_test(tjbench-${libtype}-tile
DRCdedce662017-06-28 15:30:41 -0500921 tjbench${suffix} testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01
922 -warmup 0)
DRC6abd3912016-11-15 08:47:43 -0600923 set_tests_properties(tjbench-${libtype}-tile
924 PROPERTIES DEPENDS tjbench-${libtype}-tile-cp)
925
926 foreach(tile 8 16 32 64 128)
927 add_test(tjbench-${libtype}-tile-gray-${tile}x${tile}-cmp
928 ${MD5CMP} ${MD5_PPM_GRAY_TILE}
929 testout_tile_GRAY_Q95_${tile}x${tile}.ppm)
930 foreach(subsamp 420 422)
931 add_test(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
932 ${MD5CMP} ${MD5_PPM_${subsamp}_${tile}x${tile}_TILE}
933 testout_tile_${subsamp}_Q95_${tile}x${tile}.ppm)
934 endforeach()
935 add_test(tjbench-${libtype}-tile-444-${tile}x${tile}-cmp
936 ${MD5CMP} ${MD5_PPM_444_TILE}
937 testout_tile_444_Q95_${tile}x${tile}.ppm)
938 foreach(subsamp gray 420 422 444)
939 set_tests_properties(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
940 PROPERTIES DEPENDS tjbench-${libtype}-tile)
941 endforeach()
942 endforeach()
943
944 add_test(tjbench-${libtype}-tilem-cp
945 ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
946 testout_tilem.ppm)
947 add_test(tjbench-${libtype}-tilem
948 tjbench${suffix} testout_tilem.ppm 95 -rgb -fastupsample -quiet -tile
DRCdedce662017-06-28 15:30:41 -0500949 -benchtime 0.01 -warmup 0)
DRC6abd3912016-11-15 08:47:43 -0600950 set_tests_properties(tjbench-${libtype}-tilem
951 PROPERTIES DEPENDS tjbench-${libtype}-tilem-cp)
952
953 add_test(tjbench-${libtype}-tile-420m-8x8-cmp
954 ${MD5CMP} ${MD5_PPM_420M_8x8_TILE} testout_tilem_420_Q95_8x8.ppm)
955 add_test(tjbench-${libtype}-tile-422m-8x8-cmp
956 ${MD5CMP} ${MD5_PPM_422M_8x8_TILE} testout_tilem_422_Q95_8x8.ppm)
957 foreach(tile 16 32 64 128)
958 foreach(subsamp 420 422)
959 add_test(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
960 ${MD5CMP} ${MD5_PPM_${subsamp}M_TILE}
961 testout_tilem_${subsamp}_Q95_${tile}x${tile}.ppm)
962 endforeach()
963 endforeach()
964 foreach(tile 8 16 32 64 128)
965 foreach(subsamp 420 422)
966 set_tests_properties(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
967 PROPERTIES DEPENDS tjbench-${libtype}-tilem)
968 endforeach()
969 endforeach()
DRCaee4f722014-08-09 23:06:07 +0000970 endif()
DRC35db75e2014-05-06 22:44:46 +0000971
DRC6abd3912016-11-15 08:47:43 -0600972 # These tests are carefully crafted to provide full coverage of as many of
973 # the underlying algorithms as possible (including all of the
974 # SIMD-accelerated ones.)
975
976 macro(add_bittest PROG NAME ARGS OUTFILE INFILE MD5SUM)
977 add_test(${PROG}-${libtype}-${NAME}
978 ${PROG}${suffix} ${ARGS} -outfile ${OUTFILE} ${INFILE})
979 add_test(${PROG}-${libtype}-${NAME}-cmp
980 ${MD5CMP} ${MD5SUM} ${OUTFILE})
981 set_tests_properties(${PROG}-${libtype}-${NAME}-cmp PROPERTIES
982 DEPENDS ${PROG}-${libtype}-${NAME})
983 if(${ARGC} GREATER 6)
984 set(DEPENDS ${ARGN})
985 set_tests_properties(${PROG}-${libtype}-${NAME} PROPERTIES
986 DEPENDS ${DEPENDS})
987 endif()
988 endmacro()
DRC35db75e2014-05-06 22:44:46 +0000989
990 # CC: null SAMP: fullsize FDCT: islow ENT: huff
DRC44b23992017-01-19 15:18:57 -0600991 add_bittest(cjpeg rgb-islow "-rgb;-dct;int;-icc;${TESTIMAGES}/test1.icc"
DRC6abd3912016-11-15 08:47:43 -0600992 testout_rgb_islow.jpg ${TESTIMAGES}/testorig.ppm
993 ${MD5_JPEG_RGB_ISLOW})
DRCf9134382016-02-06 14:09:20 -0600994
DRC35db75e2014-05-06 22:44:46 +0000995 # CC: null SAMP: fullsize IDCT: islow ENT: huff
DRC44b23992017-01-19 15:18:57 -0600996 add_bittest(djpeg rgb-islow "-dct;int;-ppm;-icc;testout_rgb_islow.icc"
DRC6abd3912016-11-15 08:47:43 -0600997 testout_rgb_islow.ppm testout_rgb_islow.jpg
998 ${MD5_PPM_RGB_ISLOW} cjpeg-${libtype}-rgb-islow)
DRCf9134382016-02-06 14:09:20 -0600999
DRC44b23992017-01-19 15:18:57 -06001000 add_test(djpeg-${libtype}-rgb-islow-icc-cmp
1001 ${MD5CMP} b06a39d730129122e85c1363ed1bbc9e testout_rgb_islow.icc)
Orivej Deshce90ab52019-01-21 22:56:56 +00001002 set_tests_properties(djpeg-${libtype}-rgb-islow-icc-cmp PROPERTIES
1003 DEPENDS djpeg-${libtype}-rgb-islow)
DRC44b23992017-01-19 15:18:57 -06001004
1005 add_bittest(jpegtran icc "-copy;all;-icc;${TESTIMAGES}/test2.icc"
1006 testout_rgb_islow2.jpg testout_rgb_islow.jpg ${MD5_JPEG_RGB_ISLOW2})
1007
DRCaee4f722014-08-09 23:06:07 +00001008 if(NOT WITH_12BIT)
1009 # CC: RGB->RGB565 SAMP: fullsize IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001010 add_bittest(djpeg rgb-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
1011 testout_rgb_islow_565.bmp testout_rgb_islow.jpg
1012 ${MD5_BMP_RGB_ISLOW_565} cjpeg-${libtype}-rgb-islow)
DRCf9134382016-02-06 14:09:20 -06001013
DRCaee4f722014-08-09 23:06:07 +00001014 # CC: RGB->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001015 add_bittest(djpeg rgb-islow-565D "-dct;int;-rgb565;-bmp"
1016 testout_rgb_islow_565D.bmp testout_rgb_islow.jpg
1017 ${MD5_BMP_RGB_ISLOW_565D} cjpeg-${libtype}-rgb-islow)
DRCaee4f722014-08-09 23:06:07 +00001018 endif()
DRC35db75e2014-05-06 22:44:46 +00001019
1020 # CC: RGB->YCC SAMP: fullsize/h2v1 FDCT: ifast ENT: 2-pass huff
DRC6abd3912016-11-15 08:47:43 -06001021 add_bittest(cjpeg 422-ifast-opt "-sample;2x1;-dct;fast;-opt"
1022 testout_422_ifast_opt.jpg ${TESTIMAGES}/testorig.ppm
1023 ${MD5_JPEG_422_IFAST_OPT})
DRCf9134382016-02-06 14:09:20 -06001024
DRC35db75e2014-05-06 22:44:46 +00001025 # CC: YCC->RGB SAMP: fullsize/h2v1 fancy IDCT: ifast ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001026 add_bittest(djpeg 422-ifast "-dct;fast"
1027 testout_422_ifast.ppm testout_422_ifast_opt.jpg
1028 ${MD5_PPM_422_IFAST} cjpeg-${libtype}-422-ifast-opt)
DRCf9134382016-02-06 14:09:20 -06001029
DRC35db75e2014-05-06 22:44:46 +00001030 # CC: YCC->RGB SAMP: h2v1 merged IDCT: ifast ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001031 add_bittest(djpeg 422m-ifast "-dct;fast;-nosmooth"
1032 testout_422m_ifast.ppm testout_422_ifast_opt.jpg
1033 ${MD5_PPM_422M_IFAST} cjpeg-${libtype}-422-ifast-opt)
DRCf9134382016-02-06 14:09:20 -06001034
DRCaee4f722014-08-09 23:06:07 +00001035 if(NOT WITH_12BIT)
1036 # CC: YCC->RGB565 SAMP: h2v1 merged IDCT: ifast ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001037 add_bittest(djpeg 422m-ifast-565
1038 "-dct;int;-nosmooth;-rgb565;-dither;none;-bmp"
1039 testout_422m_ifast_565.bmp testout_422_ifast_opt.jpg
1040 ${MD5_BMP_422M_IFAST_565} cjpeg-${libtype}-422-ifast-opt)
DRCf9134382016-02-06 14:09:20 -06001041
DRCaee4f722014-08-09 23:06:07 +00001042 # CC: YCC->RGB565 (dithered) SAMP: h2v1 merged IDCT: ifast ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001043 add_bittest(djpeg 422m-ifast-565D "-dct;int;-nosmooth;-rgb565;-bmp"
1044 testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg
1045 ${MD5_BMP_422M_IFAST_565D} cjpeg-${libtype}-422-ifast-opt)
DRCaee4f722014-08-09 23:06:07 +00001046 endif()
DRC35db75e2014-05-06 22:44:46 +00001047
1048 # CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
DRC6abd3912016-11-15 08:47:43 -06001049 add_bittest(cjpeg 420-q100-ifast-prog
DRCa81a8c12019-08-14 13:17:11 -05001050 "-sample;2x2;-quality;100;-dct;fast;-scans;${TESTIMAGES}/test.scan"
DRC6abd3912016-11-15 08:47:43 -06001051 testout_420_q100_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
1052 ${MD5_JPEG_420_IFAST_Q100_PROG})
DRCf9134382016-02-06 14:09:20 -06001053
DRC35db75e2014-05-06 22:44:46 +00001054 # CC: YCC->RGB SAMP: fullsize/h2v2 fancy IDCT: ifast ENT: prog huff
DRC6abd3912016-11-15 08:47:43 -06001055 add_bittest(djpeg 420-q100-ifast-prog "-dct;fast"
1056 testout_420_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
1057 ${MD5_PPM_420_Q100_IFAST} cjpeg-${libtype}-420-q100-ifast-prog)
DRCf9134382016-02-06 14:09:20 -06001058
DRC35db75e2014-05-06 22:44:46 +00001059 # CC: YCC->RGB SAMP: h2v2 merged IDCT: ifast ENT: prog huff
DRC6abd3912016-11-15 08:47:43 -06001060 add_bittest(djpeg 420m-q100-ifast-prog "-dct;fast;-nosmooth"
1061 testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
1062 ${MD5_PPM_420M_Q100_IFAST} cjpeg-${libtype}-420-q100-ifast-prog)
DRC35db75e2014-05-06 22:44:46 +00001063
1064 # CC: RGB->Gray SAMP: fullsize FDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001065 add_bittest(cjpeg gray-islow "-gray;-dct;int"
1066 testout_gray_islow.jpg ${TESTIMAGES}/testorig.ppm
1067 ${MD5_JPEG_GRAY_ISLOW})
DRCf9134382016-02-06 14:09:20 -06001068
DRC78df2e62014-05-12 09:23:57 +00001069 # CC: Gray->Gray SAMP: fullsize IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001070 add_bittest(djpeg gray-islow "-dct;int"
1071 testout_gray_islow.ppm testout_gray_islow.jpg
1072 ${MD5_PPM_GRAY_ISLOW} cjpeg-${libtype}-gray-islow)
DRCf9134382016-02-06 14:09:20 -06001073
DRC78df2e62014-05-12 09:23:57 +00001074 # CC: Gray->RGB SAMP: fullsize IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001075 add_bittest(djpeg gray-islow-rgb "-dct;int;-rgb"
1076 testout_gray_islow_rgb.ppm testout_gray_islow.jpg
1077 ${MD5_PPM_GRAY_ISLOW_RGB} cjpeg-${libtype}-gray-islow)
DRCf9134382016-02-06 14:09:20 -06001078
DRCaee4f722014-08-09 23:06:07 +00001079 if(NOT WITH_12BIT)
1080 # CC: Gray->RGB565 SAMP: fullsize IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001081 add_bittest(djpeg gray-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
1082 testout_gray_islow_565.bmp testout_gray_islow.jpg
1083 ${MD5_BMP_GRAY_ISLOW_565} cjpeg-${libtype}-gray-islow)
DRCf9134382016-02-06 14:09:20 -06001084
DRCaee4f722014-08-09 23:06:07 +00001085 # CC: Gray->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001086 add_bittest(djpeg gray-islow-565D "-dct;int;-rgb565;-bmp"
1087 testout_gray_islow_565D.bmp testout_gray_islow.jpg
1088 ${MD5_BMP_GRAY_ISLOW_565D} cjpeg-${libtype}-gray-islow)
DRCaee4f722014-08-09 23:06:07 +00001089 endif()
DRC35db75e2014-05-06 22:44:46 +00001090
1091 # CC: RGB->YCC SAMP: fullsize smooth/h2v2 smooth FDCT: islow
1092 # ENT: 2-pass huff
DRC6abd3912016-11-15 08:47:43 -06001093 add_bittest(cjpeg 420s-ifast-opt "-sample;2x2;-smooth;1;-dct;int;-opt"
1094 testout_420s_ifast_opt.jpg ${TESTIMAGES}/testorig.ppm
1095 ${MD5_JPEG_420S_IFAST_OPT})
DRC35db75e2014-05-06 22:44:46 +00001096
DRC6abd3912016-11-15 08:47:43 -06001097 if(FLOATTEST)
1098 # CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
1099 add_bittest(cjpeg 3x2-float-prog "-sample;3x2;-dct;float;-prog"
1100 testout_3x2_float_prog.jpg ${TESTIMAGES}/testorig.ppm
1101 ${MD5_JPEG_3x2_FLOAT_PROG_${FLOATTEST_UC}})
DRCf9134382016-02-06 14:09:20 -06001102
DRC6abd3912016-11-15 08:47:43 -06001103 # CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
1104 add_bittest(djpeg 3x2-float-prog "-dct;float"
1105 testout_3x2_float.ppm testout_3x2_float_prog.jpg
1106 ${MD5_PPM_3x2_FLOAT_${FLOATTEST_UC}} cjpeg-${libtype}-3x2-float-prog)
1107 endif()
1108
1109 # CC: RGB->YCC SAMP: fullsize/int FDCT: ifast ENT: prog huff
1110 add_bittest(cjpeg 3x2-ifast-prog "-sample;3x2;-dct;fast;-prog"
1111 testout_3x2_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
1112 ${MD5_JPEG_3x2_IFAST_PROG})
1113
1114 # CC: YCC->RGB SAMP: fullsize/int IDCT: ifast ENT: prog huff
1115 add_bittest(djpeg 3x2-ifast-prog "-dct;fast"
1116 testout_3x2_ifast.ppm testout_3x2_ifast_prog.jpg
1117 ${MD5_PPM_3x2_IFAST} cjpeg-${libtype}-3x2-ifast-prog)
DRC35db75e2014-05-06 22:44:46 +00001118
1119 if(WITH_ARITH_ENC)
1120 # CC: YCC->RGB SAMP: fullsize/h2v2 FDCT: islow ENT: arith
DRC6abd3912016-11-15 08:47:43 -06001121 add_bittest(cjpeg 420-islow-ari "-dct;int;-arithmetic"
1122 testout_420_islow_ari.jpg ${TESTIMAGES}/testorig.ppm
1123 ${MD5_JPEG_420_ISLOW_ARI})
DRCf9134382016-02-06 14:09:20 -06001124
DRC6abd3912016-11-15 08:47:43 -06001125 add_bittest(jpegtran 420-islow-ari "-arithmetic"
1126 testout_420_islow_ari2.jpg ${TESTIMAGES}/testimgint.jpg
1127 ${MD5_JPEG_420_ISLOW_ARI})
DRCf9134382016-02-06 14:09:20 -06001128
DRC35db75e2014-05-06 22:44:46 +00001129 # CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith
DRC6abd3912016-11-15 08:47:43 -06001130 add_bittest(cjpeg 444-islow-progari
1131 "-sample;1x1;-dct;int;-prog;-arithmetic"
1132 testout_444_islow_progari.jpg ${TESTIMAGES}/testorig.ppm
1133 ${MD5_JPEG_444_ISLOW_PROGARI})
DRC35db75e2014-05-06 22:44:46 +00001134 endif()
DRCf9134382016-02-06 14:09:20 -06001135
DRC35db75e2014-05-06 22:44:46 +00001136 if(WITH_ARITH_DEC)
1137 # CC: RGB->YCC SAMP: h2v2 merged IDCT: ifast ENT: arith
DRC6abd3912016-11-15 08:47:43 -06001138 add_bittest(djpeg 420m-ifast-ari "-fast;-ppm"
1139 testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg
1140 ${MD5_PPM_420M_IFAST_ARI})
DRCf9134382016-02-06 14:09:20 -06001141
DRC6abd3912016-11-15 08:47:43 -06001142 add_bittest(jpegtran 420-islow ""
1143 testout_420_islow.jpg ${TESTIMAGES}/testimgari.jpg
1144 ${MD5_JPEG_420_ISLOW})
DRC35db75e2014-05-06 22:44:46 +00001145 endif()
1146
1147 # 2/1-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 16x16 islow ENT: huff
1148 # 15/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 15x15 islow ENT: huff
1149 # 13/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 13x13 islow ENT: huff
1150 # 11/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 11x11 islow ENT: huff
1151 # 9/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 9x9 islow ENT: huff
1152 # 7/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 7x7 islow/14x14 islow
1153 # ENT: huff
1154 # 3/4-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 6x6 islow/12x12 islow
1155 # ENT: huff
1156 # 5/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 5x5 islow/10x10 islow
1157 # ENT: huff
1158 # 1/2-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 4x4 islow/8x8 islow
1159 # ENT: huff
1160 # 3/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 3x3 islow/6x6 islow
1161 # ENT: huff
1162 # 1/4-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 2x2 islow/4x4 islow
1163 # ENT: huff
1164 # 1/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 1x1 islow/2x2 islow
1165 # ENT: huff
1166 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)
1167 string(REGEX REPLACE "_" "/" scalearg ${scale})
DRC6abd3912016-11-15 08:47:43 -06001168 add_bittest(djpeg 420m-islow-${scale}
1169 "-dct;int;-scale;${scalearg};-nosmooth;-ppm"
1170 testout_420m_islow_${scale}.ppm ${TESTIMAGES}/${TESTORIG}
1171 ${MD5_PPM_420M_ISLOW_${scale}})
DRC35db75e2014-05-06 22:44:46 +00001172 endforeach()
1173
DRCaee4f722014-08-09 23:06:07 +00001174 if(NOT WITH_12BIT)
1175 # CC: YCC->RGB (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001176 add_bittest(djpeg 420-islow-256 "-dct;int;-colors;256;-bmp"
1177 testout_420_islow_256.bmp ${TESTIMAGES}/${TESTORIG}
1178 ${MD5_BMP_420_ISLOW_256})
DRCf9134382016-02-06 14:09:20 -06001179
DRCaee4f722014-08-09 23:06:07 +00001180 # CC: YCC->RGB565 SAMP: h2v2 fancy IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001181 add_bittest(djpeg 420-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
1182 testout_420_islow_565.bmp ${TESTIMAGES}/${TESTORIG}
1183 ${MD5_BMP_420_ISLOW_565})
DRCf9134382016-02-06 14:09:20 -06001184
DRCaee4f722014-08-09 23:06:07 +00001185 # CC: YCC->RGB565 (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001186 add_bittest(djpeg 420-islow-565D "-dct;int;-rgb565;-bmp"
1187 testout_420_islow_565D.bmp ${TESTIMAGES}/${TESTORIG}
1188 ${MD5_BMP_420_ISLOW_565D})
DRCf9134382016-02-06 14:09:20 -06001189
DRCaee4f722014-08-09 23:06:07 +00001190 # CC: YCC->RGB565 SAMP: h2v2 merged IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001191 add_bittest(djpeg 420m-islow-565
1192 "-dct;int;-nosmooth;-rgb565;-dither;none;-bmp"
1193 testout_420m_islow_565.bmp ${TESTIMAGES}/${TESTORIG}
1194 ${MD5_BMP_420M_ISLOW_565})
DRCf9134382016-02-06 14:09:20 -06001195
DRCaee4f722014-08-09 23:06:07 +00001196 # CC: YCC->RGB565 (dithered) SAMP: h2v2 merged IDCT: islow ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001197 add_bittest(djpeg 420m-islow-565D "-dct;int;-nosmooth;-rgb565;-bmp"
1198 testout_420m_islow_565D.bmp ${TESTIMAGES}/${TESTORIG}
1199 ${MD5_BMP_420M_ISLOW_565D})
DRCaee4f722014-08-09 23:06:07 +00001200 endif()
DRC7a7da942015-06-27 08:10:31 +00001201
1202 # Partial decode tests. These tests are designed to cover all of the
1203 # possible code paths in jpeg_skip_scanlines().
1204
1205 # Context rows: Yes Intra-iMCU row: Yes iMCU row prefetch: No ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001206 add_bittest(djpeg 420-islow-skip15_31 "-dct;int;-skip;15,31;-ppm"
1207 testout_420_islow_skip15,31.ppm ${TESTIMAGES}/${TESTORIG}
1208 ${MD5_PPM_420_ISLOW_SKIP15_31})
DRCf9134382016-02-06 14:09:20 -06001209
DRC7a7da942015-06-27 08:10:31 +00001210 # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: Yes ENT: arith
1211 if(WITH_ARITH_DEC)
DRC6abd3912016-11-15 08:47:43 -06001212 add_bittest(djpeg 420-islow-ari-skip16_139 "-dct;int;-skip;16,139;-ppm"
1213 testout_420_islow_ari_skip16,139.ppm ${TESTIMAGES}/testimgari.jpg
1214 ${MD5_PPM_420_ISLOW_ARI_SKIP16_139})
DRC7a7da942015-06-27 08:10:31 +00001215 endif()
DRCf9134382016-02-06 14:09:20 -06001216
DRC7a7da942015-06-27 08:10:31 +00001217 # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff
DRC6abd3912016-11-15 08:47:43 -06001218 add_test(cjpeg-${libtype}-420-islow-prog
1219 cjpeg${suffix} -dct int -prog
DRCf9134382016-02-06 14:09:20 -06001220 -outfile testout_420_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
DRC6abd3912016-11-15 08:47:43 -06001221 add_bittest(djpeg 420-islow-prog-crop62x62_71_71
1222 "-dct;int;-crop;62x62+71+71;-ppm"
1223 testout_420_islow_prog_crop62x62,71,71.ppm testout_420_islow_prog.jpg
1224 ${MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71} cjpeg-${libtype}-420-islow-prog)
DRCf9134382016-02-06 14:09:20 -06001225
DRC7a7da942015-06-27 08:10:31 +00001226 # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: arith
1227 if(WITH_ARITH_DEC)
DRC6abd3912016-11-15 08:47:43 -06001228 add_bittest(djpeg 420-islow-ari-crop53x53_4_4
1229 "-dct;int;-crop;53x53+4+4;-ppm"
1230 testout_420_islow_ari_crop53x53,4,4.ppm ${TESTIMAGES}/testimgari.jpg
1231 ${MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4})
DRC7a7da942015-06-27 08:10:31 +00001232 endif()
DRCf9134382016-02-06 14:09:20 -06001233
DRC7a7da942015-06-27 08:10:31 +00001234 # Context rows: No Intra-iMCU row: Yes ENT: huff
DRC6abd3912016-11-15 08:47:43 -06001235 add_test(cjpeg-${libtype}-444-islow
1236 cjpeg${suffix} -dct int -sample 1x1
DRCf9134382016-02-06 14:09:20 -06001237 -outfile testout_444_islow.jpg ${TESTIMAGES}/testorig.ppm)
DRC6abd3912016-11-15 08:47:43 -06001238 add_bittest(djpeg 444-islow-skip1_6 "-dct;int;-skip;1,6;-ppm"
1239 testout_444_islow_skip1,6.ppm testout_444_islow.jpg
1240 ${MD5_PPM_444_ISLOW_SKIP1_6} cjpeg-${libtype}-444-islow)
DRCf9134382016-02-06 14:09:20 -06001241
DRC7a7da942015-06-27 08:10:31 +00001242 # Context rows: No Intra-iMCU row: No ENT: prog huff
DRC6abd3912016-11-15 08:47:43 -06001243 add_test(cjpeg-${libtype}-444-islow-prog
1244 cjpeg${suffix} -dct int -prog -sample 1x1
DRCf9134382016-02-06 14:09:20 -06001245 -outfile testout_444_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
DRC6abd3912016-11-15 08:47:43 -06001246 add_bittest(djpeg 444-islow-prog-crop98x98_13_13
1247 "-dct;int;-crop;98x98+13+13;-ppm"
1248 testout_444_islow_prog_crop98x98,13,13.ppm testout_444_islow_prog.jpg
1249 ${MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13} cjpeg-${libtype}-444-islow-prog)
DRCf9134382016-02-06 14:09:20 -06001250
DRC7a7da942015-06-27 08:10:31 +00001251 # Context rows: No Intra-iMCU row: No ENT: arith
1252 if(WITH_ARITH_ENC)
DRC6abd3912016-11-15 08:47:43 -06001253 add_test(cjpeg-${libtype}-444-islow-ari
1254 cjpeg${suffix} -dct int -arithmetic -sample 1x1
DRCf9134382016-02-06 14:09:20 -06001255 -outfile testout_444_islow_ari.jpg ${TESTIMAGES}/testorig.ppm)
DRC7a7da942015-06-27 08:10:31 +00001256 if(WITH_ARITH_DEC)
DRC6abd3912016-11-15 08:47:43 -06001257 add_bittest(djpeg 444-islow-ari-crop37x37_0_0
1258 "-dct;int;-crop;37x37+0+0;-ppm"
1259 testout_444_islow_ari_crop37x37,0,0.ppm testout_444_islow_ari.jpg
1260 ${MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0} cjpeg-${libtype}-444-islow-ari)
DRC7a7da942015-06-27 08:10:31 +00001261 endif()
1262 endif()
1263
DRC6abd3912016-11-15 08:47:43 -06001264 add_bittest(jpegtran crop "-crop;120x90+20+50;-transpose;-perfect"
1265 testout_crop.jpg ${TESTIMAGES}/${TESTORIG}
1266 ${MD5_JPEG_CROP})
DRC35db75e2014-05-06 22:44:46 +00001267
DRC0af8d672012-01-31 11:09:11 +00001268endforeach()
DRC2c0a4e12010-10-16 08:51:43 +00001269
DRC6aae0072016-11-15 08:37:04 -06001270add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
DRC952191d2016-12-03 14:21:11 -06001271 ${CMAKE_CURRENT_SOURCE_DIR}/cmakescripts/testclean.cmake)
DRCa0f878a2011-04-02 04:43:14 +00001272
DRC6abd3912016-11-15 08:47:43 -06001273if(WITH_TURBOJPEG)
1274 configure_file(tjbenchtest.in tjbenchtest @ONLY)
DRC8c40ac82017-11-16 18:46:01 -06001275 configure_file(tjexampletest.in tjexampletest @ONLY)
DRCcd8a1252017-11-15 09:19:27 -06001276 if(WIN32)
1277 set(BASH bash)
1278 endif()
DRC6abd3912016-11-15 08:47:43 -06001279 if(WITH_JAVA)
1280 configure_file(tjbenchtest.java.in tjbenchtest.java @ONLY)
DRC8c40ac82017-11-16 18:46:01 -06001281 configure_file(tjexampletest.java.in tjexampletest.java @ONLY)
DRC6abd3912016-11-15 08:47:43 -06001282 add_custom_target(tjtest
DRCcd8a1252017-11-15 09:19:27 -06001283 COMMAND echo tjbenchtest
1284 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
1285 COMMAND echo tjbenchtest -alloc
1286 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -alloc
1287 COMMAND echo tjbenchtest -yuv
1288 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
1289 COMMAND echo tjbenchtest -yuv -alloc
1290 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
DRC087ec122017-11-15 20:50:53 -06001291 COMMAND echo tjbenchtest -progressive
1292 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
DRCded5a502019-08-15 13:24:25 -05001293 COMMAND echo tjbenchtest -progressive -yuv
1294 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
DRC8c40ac82017-11-16 18:46:01 -06001295 COMMAND echo tjexampletest
1296 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
DRCcd8a1252017-11-15 09:19:27 -06001297 COMMAND echo tjbenchtest.java
1298 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
1299 COMMAND echo tjbenchtest.java -yuv
1300 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -yuv
DRC087ec122017-11-15 20:50:53 -06001301 COMMAND echo tjbenchtest.java -progressive
1302 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -progressive
DRCded5a502019-08-15 13:24:25 -05001303 COMMAND echo tjexampletest.java -progressive -yuv
1304 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
1305 -progressive -yuv
DRC8c40ac82017-11-16 18:46:01 -06001306 COMMAND echo tjexampletest.java
1307 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java
DRC952191d2016-12-03 14:21:11 -06001308 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
1309 ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
1310 ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest)
DRC6abd3912016-11-15 08:47:43 -06001311 else()
1312 add_custom_target(tjtest
DRCcd8a1252017-11-15 09:19:27 -06001313 COMMAND echo tjbenchtest
1314 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
1315 COMMAND echo tjbenchtest -alloc
1316 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -alloc
1317 COMMAND echo tjbenchtest -yuv
1318 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
1319 COMMAND echo tjbenchtest -yuv -alloc
1320 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
DRCded5a502019-08-15 13:24:25 -05001321 COMMAND echo tjbenchtest -progressive
1322 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
1323 COMMAND echo tjbenchtest -progressive -yuv
1324 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
DRC8c40ac82017-11-16 18:46:01 -06001325 COMMAND echo tjexampletest
1326 COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
DRC952191d2016-12-03 14:21:11 -06001327 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
DRC6abd3912016-11-15 08:47:43 -06001328 endif()
DRC2c0a4e12010-10-16 08:51:43 +00001329endif()
1330
DRC6abd3912016-11-15 08:47:43 -06001331
1332###############################################################################
1333# INSTALLATION
1334###############################################################################
1335
DRC0c8eb5b2018-07-19 17:01:42 -05001336set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
DRC7284c9a2010-10-16 21:55:14 +00001337
DRCaee4f722014-08-09 23:06:07 +00001338if(WITH_TURBOJPEG)
DRC665c96e2015-05-15 22:08:21 +00001339 if(ENABLE_SHARED)
1340 install(TARGETS turbojpeg tjbench
DRCd681fa72016-12-07 10:54:54 -06001341 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
1342 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1343 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
DRC75be88c2019-02-11 13:10:09 -06001344 if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
1345 CMAKE_C_LINKER_SUPPORTS_PDB)
1346 install(FILES "$<TARGET_PDB_FILE:turbojpeg>"
1347 DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
1348 endif()
DRC665c96e2015-05-15 22:08:21 +00001349 endif()
1350 if(ENABLE_STATIC)
DRCd681fa72016-12-07 10:54:54 -06001351 install(TARGETS turbojpeg-static ARCHIVE
1352 DESTINATION ${CMAKE_INSTALL_LIBDIR})
DRC665c96e2015-05-15 22:08:21 +00001353 if(NOT ENABLE_SHARED)
DRCf37b7c12019-07-02 11:28:26 -05001354 if(MSVC_IDE OR XCODE)
DRC2d0b6752019-01-25 16:46:02 -06001355 set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
1356 else()
1357 set(DIR ${CMAKE_CURRENT_BINARY_DIR})
1358 endif()
1359 install(PROGRAMS ${DIR}/tjbench-static${EXE}
DRCd681fa72016-12-07 10:54:54 -06001360 DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
DRC665c96e2015-05-15 22:08:21 +00001361 endif()
1362 endif()
DRC952191d2016-12-03 14:21:11 -06001363 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h
DRCd681fa72016-12-07 10:54:54 -06001364 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
DRCaee4f722014-08-09 23:06:07 +00001365endif()
DRC665c96e2015-05-15 22:08:21 +00001366
1367if(ENABLE_STATIC)
DRCd681fa72016-12-07 10:54:54 -06001368 install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
DRC665c96e2015-05-15 22:08:21 +00001369 if(NOT ENABLE_SHARED)
DRCf37b7c12019-07-02 11:28:26 -05001370 if(MSVC_IDE OR XCODE)
DRC2d0b6752019-01-25 16:46:02 -06001371 set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
1372 else()
1373 set(DIR ${CMAKE_CURRENT_BINARY_DIR})
1374 endif()
1375 install(PROGRAMS ${DIR}/cjpeg-static${EXE}
DRCd681fa72016-12-07 10:54:54 -06001376 DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
DRC2d0b6752019-01-25 16:46:02 -06001377 install(PROGRAMS ${DIR}/djpeg-static${EXE}
DRCd681fa72016-12-07 10:54:54 -06001378 DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
DRC2d0b6752019-01-25 16:46:02 -06001379 install(PROGRAMS ${DIR}/jpegtran-static${EXE}
DRCd681fa72016-12-07 10:54:54 -06001380 DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
DRC665c96e2015-05-15 22:08:21 +00001381 endif()
1382endif()
1383
DRCd681fa72016-12-07 10:54:54 -06001384install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
DRC7284c9a2010-10-16 21:55:14 +00001385
DRC952191d2016-12-03 14:21:11 -06001386install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
DRC8c40ac82017-11-16 18:46:01 -06001387 ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt
1388 ${CMAKE_CURRENT_SOURCE_DIR}/tjexample.c
DRC952191d2016-12-03 14:21:11 -06001389 ${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt
1390 ${CMAKE_CURRENT_SOURCE_DIR}/structure.txt
1391 ${CMAKE_CURRENT_SOURCE_DIR}/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/wizard.txt
DRCd681fa72016-12-07 10:54:54 -06001392 ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
DRC8c40ac82017-11-16 18:46:01 -06001393if(WITH_JAVA)
1394 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java
1395 DESTINATION ${CMAKE_INSTALL_DOCDIR})
1396endif()
DRC6abd3912016-11-15 08:47:43 -06001397
DRCe15a6b42018-03-23 11:14:50 -05001398if(UNIX OR MINGW)
DRC952191d2016-12-03 14:21:11 -06001399 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cjpeg.1
1400 ${CMAKE_CURRENT_SOURCE_DIR}/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/jpegtran.1
1401 ${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
DRCd681fa72016-12-07 10:54:54 -06001402 ${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
1403 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
DRC6abd3912016-11-15 08:47:43 -06001404endif()
DRC504a2952018-10-11 15:13:34 -05001405install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
1406 ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
1407 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
DRCe2befde2010-10-17 07:28:08 +00001408
DRC952191d2016-12-03 14:21:11 -06001409install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
1410 ${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
DRCd681fa72016-12-07 10:54:54 -06001411 ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h
1412 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
DRC6abd3912016-11-15 08:47:43 -06001413
1414include(cmakescripts/BuildPackages.cmake)
DRC3da94de2016-11-20 19:10:54 -06001415
DRC952191d2016-12-03 14:21:11 -06001416configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in"
DRC3da94de2016-11-20 19:10:54 -06001417 "cmake_uninstall.cmake" IMMEDIATE @ONLY)
1418
1419add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)