CMakeLists.txt 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453
  1. cmake_minimum_required(VERSION 2.8.12)
  2. if(CMAKE_EXECUTABLE_SUFFIX)
  3. set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX})
  4. endif()
  5. project(libjpeg-turbo C)
  6. set(VERSION 2.0.6)
  7. string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
  8. list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
  9. list(GET VERSION_TRIPLET 1 VERSION_MINOR)
  10. list(GET VERSION_TRIPLET 2 VERSION_REVISION)
  11. function(pad_number NUMBER OUTPUT_LEN)
  12. string(LENGTH "${${NUMBER}}" INPUT_LEN)
  13. if(INPUT_LEN LESS OUTPUT_LEN)
  14. math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1")
  15. set(NUM ${${NUMBER}})
  16. foreach(C RANGE ${ZEROES})
  17. set(NUM "0${NUM}")
  18. endforeach()
  19. set(${NUMBER} ${NUM} PARENT_SCOPE)
  20. endif()
  21. endfunction()
  22. pad_number(VERSION_MINOR 3)
  23. pad_number(VERSION_REVISION 3)
  24. set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION})
  25. string(TIMESTAMP DEFAULT_BUILD "%Y%m%d")
  26. set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})")
  27. # NOTE: On Windows, this does nothing except when using MinGW or Cygwin.
  28. # CMAKE_BUILD_TYPE has no meaning in Visual Studio, and it always defaults to
  29. # Debug when using NMake.
  30. if(NOT CMAKE_BUILD_TYPE)
  31. set(CMAKE_BUILD_TYPE Release)
  32. endif()
  33. message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
  34. message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
  35. # Detect CPU type and whether we're building 64-bit or 32-bit code
  36. math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8")
  37. string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC)
  38. if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR
  39. CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR
  40. CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR
  41. CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR
  42. CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32")
  43. if(BITS EQUAL 64)
  44. set(CPU_TYPE x86_64)
  45. else()
  46. set(CPU_TYPE i386)
  47. endif()
  48. if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE})
  49. set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE})
  50. endif()
  51. elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR
  52. CMAKE_SYSTEM_PROCESSOR_LC MATCHES "arm*64*")
  53. set(CPU_TYPE arm64)
  54. elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "arm*")
  55. set(CPU_TYPE arm)
  56. elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ppc*" OR
  57. CMAKE_SYSTEM_PROCESSOR_LC MATCHES "powerpc*")
  58. set(CPU_TYPE powerpc)
  59. else()
  60. set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC})
  61. endif()
  62. message(STATUS "${BITS}-bit build (${CPU_TYPE})")
  63. ###############################################################################
  64. # INSTALL DIRECTORIES
  65. ###############################################################################
  66. # if(WIN32)
  67. # if(MSVC)
  68. # set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}")
  69. # else()
  70. # set(CMAKE_INSTALL_DEFAULT_PREFIX "c:/${CMAKE_PROJECT_NAME}-gcc")
  71. # endif()
  72. # if(BITS EQUAL 64)
  73. # set(CMAKE_INSTALL_DEFAULT_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}64")
  74. # endif()
  75. # else()
  76. # set(CMAKE_INSTALL_DEFAULT_PREFIX /opt/${CMAKE_PROJECT_NAME})
  77. # endif()
  78. # if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  79. # set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_DEFAULT_PREFIX}" CACHE PATH
  80. # "Directory into which to install ${CMAKE_PROJECT_NAME} (default: ${CMAKE_INSTALL_DEFAULT_PREFIX})"
  81. # FORCE)
  82. # endif()
  83. # message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
  84. # When the prefix is /opt/${CMAKE_PROJECT_NAME}, we assume that an "official"
  85. # build is being created, and thus we install things into specific locations.
  86. # if(CMAKE_INSTALL_PREFIX STREQUAL "${CMAKE_INSTALL_DEFAULT_PREFIX}")
  87. # set(CMAKE_INSTALL_DEFAULT_DATAROOTDIR "")
  88. # set(CMAKE_INSTALL_DEFAULT_DOCDIR "<CMAKE_INSTALL_DATAROOTDIR>/doc")
  89. # set(CMAKE_INSTALL_DEFAULT_JAVADIR "<CMAKE_INSTALL_DATAROOTDIR>/classes")
  90. # if(UNIX AND NOT APPLE)
  91. # if(BITS EQUAL 64)
  92. # set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib64")
  93. # else()
  94. # set(CMAKE_INSTALL_DEFAULT_LIBDIR "lib32")
  95. # endif()
  96. # endif()
  97. # endif()
  98. include(cmakescripts/GNUInstallDirs.cmake)
  99. macro(report_directory var)
  100. if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
  101. message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
  102. else()
  103. message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})")
  104. endif()
  105. mark_as_advanced(CLEAR CMAKE_INSTALL_${var})
  106. endmacro()
  107. # set(DIRLIST "BINDIR;DATAROOTDIR;DOCDIR;INCLUDEDIR;LIBDIR")
  108. # if(UNIX)
  109. # list(APPEND DIRLIST "MANDIR")
  110. # endif()
  111. # foreach(dir ${DIRLIST})
  112. # report_directory(${dir})
  113. # endforeach()
  114. ###############################################################################
  115. # CONFIGURATION OPTIONS
  116. ###############################################################################
  117. macro(boolean_number var)
  118. if(${var})
  119. set(${var} 1)
  120. else()
  121. set(${var} 0)
  122. endif()
  123. endmacro()
  124. option(ENABLE_SHARED "Build shared libraries" FALSE)
  125. boolean_number(ENABLE_SHARED)
  126. option(ENABLE_STATIC "Build static libraries" TRUE)
  127. boolean_number(ENABLE_STATIC)
  128. option(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)
  129. boolean_number(REQUIRE_SIMD)
  130. option(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)
  131. boolean_number(WITH_12BIT)
  132. option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" FALSE)
  133. boolean_number(WITH_ARITH_DEC)
  134. option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" FALSE)
  135. boolean_number(WITH_ARITH_ENC)
  136. option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE)
  137. boolean_number(WITH_JAVA)
  138. option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
  139. boolean_number(WITH_JPEG7)
  140. option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
  141. boolean_number(WITH_JPEG8)
  142. option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE)
  143. boolean_number(WITH_MEM_SRCDST)
  144. option(WITH_SIMD "Include SIMD extensions, if available for this platform" TRUE)
  145. boolean_number(WITH_SIMD)
  146. option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" TRUE)
  147. boolean_number(WITH_TURBOJPEG)
  148. macro(report_option var desc)
  149. if(${var})
  150. message(STATUS "${desc} enabled (${var} = ${${var}})")
  151. else()
  152. message(STATUS "${desc} disabled (${var} = ${${var}})")
  153. endif()
  154. endmacro()
  155. if(WITH_JAVA)
  156. set(ENABLE_SHARED 1)
  157. endif()
  158. # Explicitly setting CMAKE_POSITION_INDEPENDENT_CODE=FALSE disables PIC for all
  159. # targets, which will cause the shared library builds to fail. Thus, if shared
  160. # libraries are enabled and CMAKE_POSITION_INDEPENDENT_CODE is explicitly set
  161. # to FALSE, we need to unset it, thus restoring the default behavior
  162. # (automatically using PIC for shared library targets.)
  163. if(DEFINED CMAKE_POSITION_INDEPENDENT_CODE AND
  164. NOT CMAKE_POSITION_INDEPENDENT_CODE AND ENABLE_SHARED)
  165. unset(CMAKE_POSITION_INDEPENDENT_CODE CACHE)
  166. endif()
  167. report_option(ENABLE_SHARED "Shared libraries")
  168. report_option(ENABLE_STATIC "Static libraries")
  169. if(ENABLE_SHARED)
  170. set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
  171. endif()
  172. if(WITH_12BIT)
  173. set(WITH_ARITH_DEC 0)
  174. set(WITH_ARITH_ENC 0)
  175. set(WITH_JAVA 0)
  176. set(WITH_SIMD 0)
  177. set(WITH_TURBOJPEG 0)
  178. set(BITS_IN_JSAMPLE 12)
  179. else()
  180. set(BITS_IN_JSAMPLE 8)
  181. endif()
  182. report_option(WITH_12BIT "12-bit JPEG support")
  183. if(WITH_JPEG8 OR WITH_JPEG7)
  184. set(WITH_ARITH_ENC 1)
  185. set(WITH_ARITH_DEC 1)
  186. endif()
  187. if(WITH_JPEG8)
  188. set(WITH_MEM_SRCDST 0)
  189. endif()
  190. if(WITH_ARITH_DEC)
  191. set(D_ARITH_CODING_SUPPORTED 1)
  192. endif()
  193. if(NOT WITH_12BIT)
  194. report_option(WITH_ARITH_DEC "Arithmetic decoding support")
  195. endif()
  196. if(WITH_ARITH_ENC)
  197. set(C_ARITH_CODING_SUPPORTED 1)
  198. endif()
  199. if(NOT WITH_12BIT)
  200. report_option(WITH_ARITH_ENC "Arithmetic encoding support")
  201. endif()
  202. if(NOT WITH_12BIT)
  203. report_option(WITH_TURBOJPEG "TurboJPEG API library")
  204. report_option(WITH_JAVA "TurboJPEG Java wrapper")
  205. endif()
  206. if(WITH_MEM_SRCDST)
  207. set(MEM_SRCDST_SUPPORTED 1)
  208. set(MEM_SRCDST_FUNCTIONS "global: jpeg_mem_dest; jpeg_mem_src;")
  209. endif()
  210. if(NOT WITH_JPEG8)
  211. report_option(WITH_MEM_SRCDST "In-memory source/destination managers")
  212. endif()
  213. set(SO_AGE 2)
  214. if(WITH_MEM_SRCDST)
  215. set(SO_AGE 3)
  216. endif()
  217. if(WITH_JPEG8)
  218. set(JPEG_LIB_VERSION 80)
  219. elseif(WITH_JPEG7)
  220. set(JPEG_LIB_VERSION 70)
  221. else()
  222. set(JPEG_LIB_VERSION 62)
  223. endif()
  224. math(EXPR JPEG_LIB_VERSION_DIV10 "${JPEG_LIB_VERSION} / 10")
  225. math(EXPR JPEG_LIB_VERSION_MOD10 "${JPEG_LIB_VERSION} % 10")
  226. if(JPEG_LIB_VERSION STREQUAL "62")
  227. set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION})
  228. else()
  229. set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION_DIV10})
  230. endif()
  231. if(JPEG_LIB_VERSION STREQUAL "80")
  232. set(DEFAULT_SO_MINOR_VERSION 2)
  233. else()
  234. set(DEFAULT_SO_MINOR_VERSION 0)
  235. endif()
  236. # This causes SO_MAJOR_VERSION/SO_MINOR_VERSION to reset to defaults if
  237. # WITH_JPEG7 or WITH_JPEG8 has changed.
  238. if((DEFINED WITH_JPEG7_INT AND NOT WITH_JPEG7 EQUAL WITH_JPEG7_INT) OR
  239. (DEFINED WITH_JPEG8_INT AND NOT WITH_JPEG8 EQUAL WITH_JPEG8_INT))
  240. set(FORCE_SO_VERSION "FORCE")
  241. endif()
  242. set(WITH_JPEG7_INT ${WITH_JPEG7} CACHE INTERNAL "")
  243. set(WITH_JPEG8_INT ${WITH_JPEG8} CACHE INTERNAL "")
  244. set(SO_MAJOR_VERSION ${DEFAULT_SO_MAJOR_VERSION} CACHE STRING
  245. "Major version of the libjpeg API shared library (default: ${DEFAULT_SO_MAJOR_VERSION})"
  246. ${FORCE_SO_VERSION})
  247. set(SO_MINOR_VERSION ${DEFAULT_SO_MINOR_VERSION} CACHE STRING
  248. "Minor version of the libjpeg API shared library (default: ${DEFAULT_SO_MINOR_VERSION})"
  249. ${FORCE_SO_VERSION})
  250. set(JPEG_LIB_VERSION_DECIMAL "${JPEG_LIB_VERSION_DIV10}.${JPEG_LIB_VERSION_MOD10}")
  251. message(STATUS "Emulating libjpeg API/ABI v${JPEG_LIB_VERSION_DECIMAL} (WITH_JPEG7 = ${WITH_JPEG7}, WITH_JPEG8 = ${WITH_JPEG8})")
  252. message(STATUS "libjpeg API shared library version = ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION}")
  253. # Because the TurboJPEG API library uses versioned symbols and changes the
  254. # names of functions whenever they are modified in a backward-incompatible
  255. # manner, it is always backward-ABI-compatible with itself, so the major and
  256. # minor SO versions don't change. However, we increase the middle number (the
  257. # SO "age") whenever functions are added to the API.
  258. set(TURBOJPEG_SO_MAJOR_VERSION 0)
  259. set(TURBOJPEG_SO_VERSION 0.2.0)
  260. ###############################################################################
  261. # COMPILER SETTINGS
  262. ###############################################################################
  263. if(MSVC)
  264. option(WITH_CRT_DLL
  265. "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."
  266. FALSE)
  267. if(NOT WITH_CRT_DLL)
  268. # Use the static C library for all build types
  269. foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
  270. CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
  271. if(${var} MATCHES "/MD")
  272. string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
  273. endif()
  274. endforeach()
  275. endif()
  276. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /wd4996")
  277. endif()
  278. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
  279. # Use the maximum optimization level for release builds
  280. foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
  281. if(${var} MATCHES "-O2")
  282. string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}")
  283. endif()
  284. endforeach()
  285. endif()
  286. if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  287. if(CMAKE_C_COMPILER_ID MATCHES "SunPro")
  288. # Use the maximum optimization level for release builds
  289. foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
  290. if(${var} MATCHES "-xO3")
  291. string(REGEX REPLACE "-xO3" "-xO5" ${var} "${${var}}")
  292. endif()
  293. if(${var} MATCHES "-xO2")
  294. string(REGEX REPLACE "-xO2" "-xO5" ${var} "${${var}}")
  295. endif()
  296. endforeach()
  297. endif()
  298. endif()
  299. string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
  300. set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
  301. message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}")
  302. set(EFFECTIVE_LD_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
  303. message(STATUS "Linker flags = ${EFFECTIVE_LD_FLAGS}")
  304. include(CheckCSourceCompiles)
  305. include(CheckIncludeFiles)
  306. include(CheckTypeSize)
  307. check_type_size("size_t" SIZE_T)
  308. check_type_size("unsigned long" UNSIGNED_LONG)
  309. if(SIZE_T EQUAL UNSIGNED_LONG)
  310. check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }"
  311. HAVE_BUILTIN_CTZL)
  312. endif()
  313. if(MSVC)
  314. check_include_files("intrin.h" HAVE_INTRIN_H)
  315. endif()
  316. if(UNIX)
  317. # Check for headers
  318. check_include_files(locale.h HAVE_LOCALE_H)
  319. check_include_files(stddef.h HAVE_STDDEF_H)
  320. check_include_files(stdlib.h HAVE_STDLIB_H)
  321. check_include_files(sys/types.h NEED_SYS_TYPES_H)
  322. # Check for functions
  323. include(CheckSymbolExists)
  324. check_symbol_exists(memset string.h HAVE_MEMSET)
  325. check_symbol_exists(memcpy string.h HAVE_MEMCPY)
  326. if(NOT HAVE_MEMSET AND NOT HAVE_MEMCPY)
  327. set(NEED_BSD_STRINGS 1)
  328. endif()
  329. # Check for types
  330. check_type_size("unsigned char" UNSIGNED_CHAR)
  331. check_type_size("unsigned short" UNSIGNED_SHORT)
  332. # Check for compiler features
  333. check_c_source_compiles("int main(void) { typedef struct undefined_structure *undef_struct_ptr; undef_struct_ptr ptr = 0; return ptr != 0; }"
  334. INCOMPLETE_TYPES)
  335. if(INCOMPLETE_TYPES)
  336. message(STATUS "Compiler supports pointers to undefined structures.")
  337. else()
  338. set(INCOMPLETE_TYPES_BROKEN 1)
  339. message(STATUS "Compiler does not support pointers to undefined structures.")
  340. endif()
  341. if(CMAKE_CROSSCOMPILING)
  342. set(RIGHT_SHIFT_IS_UNSIGNED 0)
  343. else()
  344. include(CheckCSourceRuns)
  345. check_c_source_runs("
  346. #include <stdio.h>
  347. #include <stdlib.h>
  348. int is_shifting_signed (long arg) {
  349. long res = arg >> 4;
  350. if (res == -0x7F7E80CL)
  351. return 1; /* right shift is signed */
  352. /* see if unsigned-shift hack will fix it. */
  353. /* we can't just test exact value since it depends on width of long... */
  354. res |= (~0L) << (32-4);
  355. if (res == -0x7F7E80CL)
  356. return 0; /* right shift is unsigned */
  357. printf(\"Right shift isn't acting as I expect it to.\\\\n\");
  358. printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
  359. return 0; /* try it with unsigned anyway */
  360. }
  361. int main (void) {
  362. exit(is_shifting_signed(-0x7F7E80B1L));
  363. }" RIGHT_SHIFT_IS_UNSIGNED)
  364. endif()
  365. if(CMAKE_CROSSCOMPILING)
  366. set(__CHAR_UNSIGNED__ 0)
  367. else()
  368. check_c_source_runs("int main(void) { return ((char) -1 < 0); }"
  369. __CHAR_UNSIGNED__)
  370. endif()
  371. endif()
  372. if(MSVC)
  373. set(INLINE_OPTIONS "__inline;inline")
  374. else()
  375. set(INLINE_OPTIONS "__inline__;inline")
  376. endif()
  377. option(FORCE_INLINE "Force function inlining" TRUE)
  378. boolean_number(FORCE_INLINE)
  379. if(FORCE_INLINE)
  380. if(MSVC)
  381. list(INSERT INLINE_OPTIONS 0 "__forceinline")
  382. else()
  383. list(INSERT INLINE_OPTIONS 0 "inline __attribute__((always_inline))")
  384. list(INSERT INLINE_OPTIONS 0 "__inline__ __attribute__((always_inline))")
  385. endif()
  386. endif()
  387. foreach(inline ${INLINE_OPTIONS})
  388. check_c_source_compiles("${inline} static int foo(void) { return 0; } int main(void) { return foo(); }"
  389. INLINE_WORKS)
  390. if(INLINE_WORKS)
  391. set(INLINE ${inline})
  392. break()
  393. endif()
  394. endforeach()
  395. if(NOT INLINE_WORKS)
  396. message(FATAL_ERROR "Could not determine how to inline functions.")
  397. endif()
  398. message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})")
  399. if(WITH_TURBOJPEG)
  400. if(MSVC)
  401. set(THREAD_LOCAL "__declspec(thread)")
  402. else()
  403. set(THREAD_LOCAL "__thread")
  404. endif()
  405. check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }" HAVE_THREAD_LOCAL)
  406. if(HAVE_THREAD_LOCAL)
  407. message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}")
  408. else()
  409. message(WARNING "Thread-local storage is not available. The TurboJPEG API library's global error handler will not be thread-safe.")
  410. unset(THREAD_LOCAL)
  411. endif()
  412. endif()
  413. if(UNIX AND NOT APPLE)
  414. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };")
  415. set(CMAKE_REQUIRED_FLAGS
  416. "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
  417. check_c_source_compiles("int main(void) { return 0; }" HAVE_VERSION_SCRIPT)
  418. set(CMAKE_REQUIRED_FLAGS)
  419. file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
  420. if(HAVE_VERSION_SCRIPT)
  421. message(STATUS "Linker supports GNU-style version scripts")
  422. set(MAPFLAG "-Wl,--version-script,")
  423. set(TJMAPFLAG "-Wl,--version-script,")
  424. else()
  425. message(STATUS "Linker does not support GNU-style version scripts")
  426. if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  427. # The Solaris linker doesn't like our version script for the libjpeg API
  428. # library, but the version script for the TurboJPEG API library should
  429. # still work.
  430. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map
  431. "VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;")
  432. set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared")
  433. check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }"
  434. HAVE_MAPFILE)
  435. set(CMAKE_REQUIRED_FLAGS)
  436. file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
  437. if(HAVE_MAPFILE)
  438. message(STATUS "Linker supports mapfiles")
  439. set(TJMAPFLAG "-Wl,-M,")
  440. else()
  441. message(STATUS "Linker does not support mapfiles")
  442. endif()
  443. endif()
  444. endif()
  445. endif()
  446. # Generate files
  447. if(WIN32)
  448. configure_file(win/jconfig.h.in jconfig.h)
  449. else()
  450. configure_file(jconfig.h.in jconfig.h)
  451. endif()
  452. configure_file(jconfigint.h.in jconfigint.h)
  453. if(UNIX)
  454. configure_file(libjpeg.map.in libjpeg.map)
  455. endif()
  456. # Include directories and compiler definitions
  457. include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
  458. ###############################################################################
  459. # TARGETS
  460. ###############################################################################
  461. if(CMAKE_EXECUTABLE_SUFFIX_TMP)
  462. set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX_TMP})
  463. endif()
  464. message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}")
  465. set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
  466. jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c
  467. jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c
  468. jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c
  469. jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c
  470. jdtrans.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c
  471. jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
  472. if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
  473. set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
  474. endif()
  475. if(WITH_ARITH_ENC)
  476. set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
  477. endif()
  478. if(WITH_ARITH_DEC)
  479. set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
  480. endif()
  481. if(WITH_SIMD)
  482. add_subdirectory(simd)
  483. elseif(NOT WITH_12BIT)
  484. message(STATUS "SIMD extensions: None (WITH_SIMD = ${WITH_SIMD})")
  485. endif()
  486. if(WITH_SIMD)
  487. message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})")
  488. if(MSVC_IDE OR XCODE)
  489. set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
  490. endif()
  491. else()
  492. add_library(simd OBJECT jsimd_none.c)
  493. endif()
  494. if(WITH_JAVA)
  495. add_subdirectory(java)
  496. endif()
  497. if(ENABLE_SHARED)
  498. add_subdirectory(sharedlib)
  499. endif()
  500. if(ENABLE_STATIC)
  501. add_library(jpeg-static STATIC ${JPEG_SOURCES} $<TARGET_OBJECTS:simd>
  502. ${SIMD_OBJS})
  503. if(NOT MSVC)
  504. set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
  505. endif()
  506. endif()
  507. if(WITH_TURBOJPEG)
  508. if(ENABLE_SHARED)
  509. set(TURBOJPEG_SOURCES ${JPEG_SOURCES} $<TARGET_OBJECTS:simd> ${SIMD_OBJS}
  510. turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c rdppm.c
  511. wrbmp.c wrppm.c)
  512. set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile)
  513. if(WITH_JAVA)
  514. set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
  515. include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
  516. set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile.jni)
  517. endif()
  518. add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
  519. set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS
  520. "-DBMP_SUPPORTED -DPPM_SUPPORTED")
  521. if(WIN32)
  522. set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
  523. endif()
  524. if(MINGW)
  525. set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
  526. endif()
  527. if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR
  528. CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4))
  529. if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
  530. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
  531. endif()
  532. set_target_properties(turbojpeg PROPERTIES MACOSX_RPATH 1)
  533. endif()
  534. set_target_properties(turbojpeg PROPERTIES
  535. SOVERSION ${TURBOJPEG_SO_MAJOR_VERSION} VERSION ${TURBOJPEG_SO_VERSION})
  536. if(TJMAPFLAG)
  537. set_target_properties(turbojpeg PROPERTIES
  538. LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}")
  539. endif()
  540. add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c)
  541. target_link_libraries(tjunittest turbojpeg)
  542. add_executable(tjbench tjbench.c tjutil.c)
  543. target_link_libraries(tjbench turbojpeg)
  544. if(UNIX)
  545. target_link_libraries(tjbench m)
  546. endif()
  547. add_executable(tjexample tjexample.c)
  548. target_link_libraries(tjexample turbojpeg)
  549. endif()
  550. if(ENABLE_STATIC)
  551. add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $<TARGET_OBJECTS:simd>
  552. ${SIMD_OBJS} turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c
  553. rdppm.c wrbmp.c wrppm.c)
  554. set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS
  555. "-DBMP_SUPPORTED -DPPM_SUPPORTED")
  556. if(NOT MSVC)
  557. set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
  558. endif()
  559. add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c
  560. md5/md5hl.c)
  561. target_link_libraries(tjunittest-static turbojpeg-static)
  562. add_executable(tjbench-static tjbench.c tjutil.c)
  563. target_link_libraries(tjbench-static turbojpeg-static)
  564. if(UNIX)
  565. target_link_libraries(tjbench-static m)
  566. endif()
  567. endif()
  568. endif()
  569. if(WIN32)
  570. set(USE_SETMODE "-DUSE_SETMODE")
  571. endif()
  572. if(WITH_12BIT)
  573. set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}")
  574. else()
  575. set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
  576. set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
  577. set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
  578. endif()
  579. if(ENABLE_STATIC)
  580. add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
  581. ${CJPEG_BMP_SOURCES})
  582. set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
  583. target_link_libraries(cjpeg-static jpeg-static)
  584. add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
  585. wrppm.c ${DJPEG_BMP_SOURCES})
  586. set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
  587. target_link_libraries(djpeg-static jpeg-static)
  588. add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
  589. target_link_libraries(jpegtran-static jpeg-static)
  590. set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "${USE_SETMODE}")
  591. endif()
  592. add_executable(rdjpgcom rdjpgcom.c)
  593. add_executable(wrjpgcom wrjpgcom.c)
  594. ###############################################################################
  595. # TESTS
  596. ###############################################################################
  597. add_subdirectory(md5)
  598. if(MSVC_IDE OR XCODE)
  599. set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
  600. else()
  601. set(OBJDIR "")
  602. endif()
  603. enable_testing()
  604. if(WITH_12BIT)
  605. set(TESTORIG testorig12.jpg)
  606. set(MD5_JPEG_RGB_ISLOW 9d7369207c520d37f2c1cbfcb82b2964)
  607. set(MD5_JPEG_RGB_ISLOW2 a00bd20d8ae49684640ef7177d2e0b64)
  608. set(MD5_PPM_RGB_ISLOW f3301d2219783b8b3d942b7239fa50c0)
  609. set(MD5_JPEG_422_IFAST_OPT 7322e3bd2f127f7de4b40d4480ce60e4)
  610. set(MD5_PPM_422_IFAST 79807fa552899e66a04708f533e16950)
  611. set(MD5_PPM_422M_IFAST 07737bfe8a7c1c87aaa393a0098d16b0)
  612. set(MD5_JPEG_420_IFAST_Q100_PROG 008ab68d6ddbba04a8f01deee4e0f9f8)
  613. set(MD5_PPM_420_Q100_IFAST 1b3730122709f53d007255e8dfd3305e)
  614. set(MD5_PPM_420M_Q100_IFAST 980a1a3c5bf9510022869d30b7d26566)
  615. set(MD5_JPEG_GRAY_ISLOW 235c90707b16e2e069f37c888b2636d9)
  616. set(MD5_PPM_GRAY_ISLOW 7213c10af507ad467da5578ca5ee1fca)
  617. set(MD5_PPM_GRAY_ISLOW_RGB e96ee81c30a6ed422d466338bd3de65d)
  618. set(MD5_JPEG_420S_IFAST_OPT 7af8e60be4d9c227ec63ac9b6630855e)
  619. set(MD5_JPEG_3x2_FLOAT_PROG_SSE a8c17daf77b457725ec929e215b603f8)
  620. set(MD5_PPM_3x2_FLOAT_SSE 42876ab9e5c2f76a87d08db5fbd57956)
  621. set(MD5_JPEG_3x2_FLOAT_PROG_32BIT a8c17daf77b457725ec929e215b603f8)
  622. set(MD5_PPM_3x2_FLOAT_32BIT ${MD5_PPM_3x2_FLOAT_SSE})
  623. set(MD5_JPEG_3x2_FLOAT_PROG_64BIT ${MD5_JPEG_3x2_FLOAT_PROG_32BIT})
  624. set(MD5_PPM_3x2_FLOAT_64BIT ${MD5_PPM_3x2_FLOAT_SSE})
  625. set(MD5_JPEG_3x2_FLOAT_PROG_387 bc6dbbefac2872f6b9d6c4a0ae60c3c0)
  626. set(MD5_PPM_3x2_FLOAT_387 bcc5723c61560463ac60f772e742d092)
  627. set(MD5_JPEG_3x2_FLOAT_PROG_MSVC e27840755870fa849872e58aa0cd1400)
  628. set(MD5_PPM_3x2_FLOAT_MSVC 6c2880b83bb1aa41dfe330e7a9768690)
  629. set(MD5_JPEG_3x2_IFAST_PROG 1396cc2b7185cfe943d408c9d305339e)
  630. set(MD5_PPM_3x2_IFAST 3975985ef6eeb0a2cdc58daa651ccc00)
  631. set(MD5_PPM_420M_ISLOW_2_1 4ca6be2a6f326ff9eaab63e70a8259c0)
  632. set(MD5_PPM_420M_ISLOW_15_8 12aa9f9534c1b3d7ba047322226365eb)
  633. set(MD5_PPM_420M_ISLOW_13_8 f7e22817c7b25e1393e4ec101e9d4e96)
  634. set(MD5_PPM_420M_ISLOW_11_8 800a16f9f4dc9b293197bfe11be10a82)
  635. set(MD5_PPM_420M_ISLOW_9_8 06b7a92a9bc69f4dc36ec40f1937d55c)
  636. set(MD5_PPM_420M_ISLOW_7_8 3ec444a14a4ab4eab88ffc49c48eca43)
  637. set(MD5_PPM_420M_ISLOW_3_4 3e726b7ea872445b19437d1c1d4f0d93)
  638. set(MD5_PPM_420M_ISLOW_5_8 a8a771abdc94301d20ffac119b2caccd)
  639. set(MD5_PPM_420M_ISLOW_1_2 b419124dd5568b085787234866102866)
  640. set(MD5_PPM_420M_ISLOW_3_8 343d19015531b7bbe746124127244fa8)
  641. set(MD5_PPM_420M_ISLOW_1_4 35fd59d866e44659edfa3c18db2a3edb)
  642. set(MD5_PPM_420M_ISLOW_1_8 ccaed48ac0aedefda5d4abe4013f4ad7)
  643. set(MD5_PPM_420_ISLOW_SKIP15_31 86664cd9dc956536409e44e244d20a97)
  644. set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 452a21656115a163029cfba5c04fa76a)
  645. set(MD5_PPM_444_ISLOW_SKIP1_6 ef63901f71ef7a75cd78253fc0914f84)
  646. set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 15b173fb5872d9575572fbcc1b05956f)
  647. set(MD5_JPEG_CROP cdb35ff4b4519392690ea040c56ea99c)
  648. else()
  649. set(TESTORIG testorig.jpg)
  650. set(MD5_JPEG_RGB_ISLOW 1d44a406f61da743b5fd31c0a9abdca3)
  651. set(MD5_JPEG_RGB_ISLOW2 31d121e57b6c2934c890a7fc7763bcd4)
  652. set(MD5_PPM_RGB_ISLOW 00a257f5393fef8821f2b88ac7421291)
  653. set(MD5_BMP_RGB_ISLOW_565 f07d2e75073e4bb10f6c6f4d36e2e3be)
  654. set(MD5_BMP_RGB_ISLOW_565D 4cfa0928ef3e6bb626d7728c924cfda4)
  655. set(MD5_JPEG_422_IFAST_OPT 2540287b79d913f91665e660303ab2c8)
  656. set(MD5_PPM_422_IFAST 35bd6b3f833bad23de82acea847129fa)
  657. set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
  658. set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
  659. set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
  660. set(MD5_JPEG_420_IFAST_Q100_PROG e59bb462016a8d9a748c330a3474bb55)
  661. set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
  662. set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
  663. set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
  664. set(MD5_PPM_GRAY_ISLOW 8d3596c56eace32f205deccc229aa5ed)
  665. set(MD5_PPM_GRAY_ISLOW_RGB 116424ac07b79e5e801f00508eab48ec)
  666. set(MD5_BMP_GRAY_ISLOW_565 12f78118e56a2f48b966f792fedf23cc)
  667. set(MD5_BMP_GRAY_ISLOW_565D bdbbd616441a24354c98553df5dc82db)
  668. set(MD5_JPEG_420S_IFAST_OPT 388708217ac46273ca33086b22827ed8)
  669. set(MD5_JPEG_3x2_FLOAT_PROG_SSE 343e3f8caf8af5986ebaf0bdc13b5c71)
  670. set(MD5_PPM_3x2_FLOAT_SSE 1a75f36e5904d6fc3a85a43da9ad89bb)
  671. set(MD5_JPEG_3x2_FLOAT_PROG_32BIT 9bca803d2042bd1eb03819e2bf92b3e5)
  672. set(MD5_PPM_3x2_FLOAT_32BIT f6bfab038438ed8f5522fbd33595dcdc)
  673. set(MD5_JPEG_3x2_FLOAT_PROG_64BIT ${MD5_JPEG_3x2_FLOAT_PROG_32BIT})
  674. set(MD5_PPM_3x2_FLOAT_64BIT 0e917a34193ef976b679a6b069b1be26)
  675. set(MD5_JPEG_3x2_FLOAT_PROG_387 1657664a410e0822c924b54f6f65e6e9)
  676. set(MD5_PPM_3x2_FLOAT_387 cb0a1f027f3d2917c902b5640214e025)
  677. set(MD5_JPEG_3x2_FLOAT_PROG_MSVC 7999ce9cd0ee9b6c7043b7351ab7639d)
  678. set(MD5_PPM_3x2_FLOAT_MSVC 28cdc448a6b75e97892f0e0f8d4b21f3)
  679. set(MD5_JPEG_3x2_IFAST_PROG 1ee5d2c1a77f2da495f993c8c7cceca5)
  680. set(MD5_PPM_3x2_IFAST fd283664b3b49127984af0a7f118fccd)
  681. set(MD5_JPEG_420_ISLOW_ARI e986fb0a637a8d833d96e8a6d6d84ea1)
  682. set(MD5_JPEG_444_ISLOW_PROGARI 0a8f1c8f66e113c3cf635df0a475a617)
  683. set(MD5_PPM_420M_IFAST_ARI 57251da28a35b46eecb7177d82d10e0e)
  684. set(MD5_JPEG_420_ISLOW 9a68f56bc76e466aa7e52f415d0f4a5f)
  685. set(MD5_PPM_420M_ISLOW_2_1 9f9de8c0612f8d06869b960b05abf9c9)
  686. set(MD5_PPM_420M_ISLOW_15_8 b6875bc070720b899566cc06459b63b7)
  687. set(MD5_PPM_420M_ISLOW_13_8 bc3452573c8152f6ae552939ee19f82f)
  688. set(MD5_PPM_420M_ISLOW_11_8 d8cc73c0aaacd4556569b59437ba00a5)
  689. set(MD5_PPM_420M_ISLOW_9_8 d25e61bc7eac0002f5b393aa223747b6)
  690. set(MD5_PPM_420M_ISLOW_7_8 ddb564b7c74a09494016d6cd7502a946)
  691. set(MD5_PPM_420M_ISLOW_3_4 8ed8e68808c3fbc4ea764fc9d2968646)
  692. set(MD5_PPM_420M_ISLOW_5_8 a3363274999da2366a024efae6d16c9b)
  693. set(MD5_PPM_420M_ISLOW_1_2 e692a315cea26b988c8e8b29a5dbcd81)
  694. set(MD5_PPM_420M_ISLOW_3_8 79eca9175652ced755155c90e785a996)
  695. set(MD5_PPM_420M_ISLOW_1_4 79cd778f8bf1a117690052cacdd54eca)
  696. set(MD5_PPM_420M_ISLOW_1_8 391b3d4aca640c8567d6f8745eb2142f)
  697. set(MD5_BMP_420_ISLOW_256 4980185e3776e89bd931736e1cddeee6)
  698. set(MD5_BMP_420_ISLOW_565 bf9d13e16c4923b92e1faa604d7922cb)
  699. set(MD5_BMP_420_ISLOW_565D 6bde71526acc44bcff76f696df8638d2)
  700. set(MD5_BMP_420M_ISLOW_565 8dc0185245353cfa32ad97027342216f)
  701. set(MD5_BMP_420M_ISLOW_565D ce034037d212bc403330df6f915c161b)
  702. set(MD5_PPM_420_ISLOW_SKIP15_31 c4c65c1e43d7275cd50328a61e6534f0)
  703. set(MD5_PPM_420_ISLOW_ARI_SKIP16_139 087c6b123db16ac00cb88c5b590bb74a)
  704. set(MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71 26eb36ccc7d1f0cb80cdabb0ac8b5d99)
  705. set(MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4 886c6775af22370257122f8b16207e6d)
  706. set(MD5_PPM_444_ISLOW_SKIP1_6 5606f86874cf26b8fcee1117a0a436a6)
  707. set(MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13 db87dc7ce26bcdc7a6b56239ce2b9d6c)
  708. set(MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0 cb57b32bd6d03e35432362f7bf184b6d)
  709. set(MD5_JPEG_CROP b4197f377e621c4e9b1d20471432610d)
  710. endif()
  711. if(WITH_JAVA)
  712. add_test(TJUnitTest
  713. ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
  714. -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
  715. TJUnitTest)
  716. add_test(TJUnitTest-yuv
  717. ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
  718. -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
  719. TJUnitTest -yuv)
  720. add_test(TJUnitTest-yuv-nopad
  721. ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
  722. -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
  723. TJUnitTest -yuv -noyuvpad)
  724. add_test(TJUnitTest-bi
  725. ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
  726. -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
  727. TJUnitTest -bi)
  728. add_test(TJUnitTest-bi-yuv
  729. ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
  730. -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
  731. TJUnitTest -bi -yuv)
  732. add_test(TJUnitTest-bi-yuv-nopad
  733. ${Java_JAVA_EXECUTABLE} ${JAVAARGS} -cp java/turbojpeg.jar
  734. -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR}
  735. TJUnitTest -bi -yuv -noyuvpad)
  736. endif()
  737. set(TEST_LIBTYPES "")
  738. if(ENABLE_SHARED)
  739. set(TEST_LIBTYPES ${TEST_LIBTYPES} shared)
  740. endif()
  741. if(ENABLE_STATIC)
  742. set(TEST_LIBTYPES ${TEST_LIBTYPES} static)
  743. endif()
  744. set(TESTIMAGES ${CMAKE_CURRENT_SOURCE_DIR}/testimages)
  745. set(MD5CMP ${CMAKE_CURRENT_BINARY_DIR}/md5/md5cmp)
  746. if(CMAKE_CROSSCOMPILING)
  747. file(RELATIVE_PATH TESTIMAGES ${CMAKE_CURRENT_BINARY_DIR} ${TESTIMAGES})
  748. file(RELATIVE_PATH MD5CMP ${CMAKE_CURRENT_BINARY_DIR} ${MD5CMP})
  749. endif()
  750. # The output of the floating point DCT/IDCT algorithms differs depending on the
  751. # type of floating point math used, so the FLOATTEST CMake variable must be
  752. # set in order to tell the testing system which floating point results it
  753. # should expect:
  754. #
  755. # sse = validate against the expected results from the libjpeg-turbo SSE SIMD
  756. # extensions
  757. # 32bit = validate against the expected results from the C code when running on
  758. # a 32-bit FPU (or when SSE is being used for floating point math,
  759. # which is generally the default with x86-64 compilers)
  760. # 64bit = validate against the expected results from the C code when running
  761. # on a 64-bit FPU
  762. # 387 = validate against the expected results from the C code when the 387 FPU
  763. # is being used for floating point math (which is generally the default
  764. # with x86 compilers)
  765. # msvc = validate against the expected results from the C code when compiled
  766. # with a 32-bit version of Visual C++
  767. if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
  768. if(WITH_SIMD)
  769. set(DEFAULT_FLOATTEST sse)
  770. elseif(CPU_TYPE STREQUAL "x86_64")
  771. set(DEFAULT_FLOATTEST 32bit)
  772. elseif(CPU_TYPE STREQUAL "i386" AND MSVC)
  773. set(DEFAULT_FLOATTEST msvc)
  774. endif()
  775. else()
  776. if(BITS EQUAL 64)
  777. set(DEFAULT_FLOATTEST 64bit)
  778. elseif(BITS EQUAL 32)
  779. set(DEFAULT_FLOATTEST 32bit)
  780. endif()
  781. endif()
  782. # This causes FLOATTEST to reset to the default value if WITH_SIMD has
  783. # changed.
  784. if(DEFINED WITH_SIMD_INT AND NOT WITH_SIMD EQUAL WITH_SIMD_INT)
  785. set(FORCE_FLOATTEST "FORCE")
  786. endif()
  787. set(WITH_SIMD_INT ${WITH_SIMD} CACHE INTERNAL "")
  788. set(FLOATTEST ${DEFAULT_FLOATTEST} CACHE STRING
  789. "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})"
  790. ${FORCE_FLOATTEST})
  791. message(STATUS "FLOATTEST = ${FLOATTEST}")
  792. if(FLOATTEST)
  793. string(TOUPPER ${FLOATTEST} FLOATTEST_UC)
  794. string(TOLOWER ${FLOATTEST} FLOATTEST)
  795. if(NOT FLOATTEST STREQUAL "sse" AND NOT FLOATTEST STREQUAL "32bit" AND
  796. NOT FLOATTEST STREQUAL "64bit" AND NOT FLOATTEST STREQUAL "387" AND
  797. NOT FLOATTEST STREQUAL "msvc")
  798. message(FATAL_ERROR "\"${FLOATTEST}\" is not a valid value for FLOATTEST.")
  799. endif()
  800. endif()
  801. foreach(libtype ${TEST_LIBTYPES})
  802. if(libtype STREQUAL "static")
  803. set(suffix -static)
  804. endif()
  805. if(WITH_TURBOJPEG)
  806. add_test(tjunittest-${libtype}
  807. ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix})
  808. add_test(tjunittest-${libtype}-alloc
  809. ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -alloc)
  810. add_test(tjunittest-${libtype}-yuv
  811. ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv)
  812. add_test(tjunittest-${libtype}-yuv-alloc
  813. ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -alloc)
  814. add_test(tjunittest-${libtype}-yuv-nopad
  815. ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -noyuvpad)
  816. add_test(tjunittest-${libtype}-bmp
  817. ${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -bmp)
  818. set(MD5_PPM_GRAY_TILE 89d3ca21213d9d864b50b4e4e7de4ca6)
  819. set(MD5_PPM_420_8x8_TILE 847fceab15c5b7b911cb986cf0f71de3)
  820. set(MD5_PPM_420_16x16_TILE ca45552a93687e078f7137cc4126a7b0)
  821. set(MD5_PPM_420_32x32_TILE d8676f1d6b68df358353bba9844f4a00)
  822. set(MD5_PPM_420_64x64_TILE 4e4c1a3d7ea4bace4f868bcbe83b7050)
  823. set(MD5_PPM_420_128x128_TILE f24c3429c52265832beab9df72a0ceae)
  824. set(MD5_PPM_420M_8x8_TILE bc25320e1f4c31ce2e610e43e9fd173c)
  825. set(MD5_PPM_420M_TILE 75ffdf14602258c5c189522af57fa605)
  826. set(MD5_PPM_422_8x8_TILE d83dacd9fc73b0a6f10c09acad64eb1e)
  827. set(MD5_PPM_422_16x16_TILE 35077fb610d72dd743b1eb0cbcfe10fb)
  828. set(MD5_PPM_422_32x32_TILE e6902ed8a449ecc0f0d6f2bf945f65f7)
  829. set(MD5_PPM_422_64x64_TILE 2b4502a8f316cedbde1da7bce3d2231e)
  830. set(MD5_PPM_422_128x128_TILE f0b5617d578f5e13c8eee215d64d4877)
  831. set(MD5_PPM_422M_8x8_TILE 828941d7f41cd6283abd6beffb7fd51d)
  832. set(MD5_PPM_422M_TILE e877ae1324c4a280b95376f7f018172f)
  833. set(MD5_PPM_444_TILE 7964e41e67cfb8d0a587c0aa4798f9c3)
  834. # Test compressing from/decompressing to an arbitrary subregion of a larger
  835. # image buffer
  836. add_test(tjbench-${libtype}-tile-cp
  837. ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
  838. testout_tile.ppm)
  839. add_test(tjbench-${libtype}-tile
  840. ${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} testout_tile.ppm 95
  841. -rgb -quiet -tile -benchtime 0.01 -warmup 0)
  842. set_tests_properties(tjbench-${libtype}-tile
  843. PROPERTIES DEPENDS tjbench-${libtype}-tile-cp)
  844. foreach(tile 8 16 32 64 128)
  845. add_test(tjbench-${libtype}-tile-gray-${tile}x${tile}-cmp
  846. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_GRAY_TILE}
  847. testout_tile_GRAY_Q95_${tile}x${tile}.ppm)
  848. foreach(subsamp 420 422)
  849. add_test(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
  850. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
  851. ${MD5_PPM_${subsamp}_${tile}x${tile}_TILE}
  852. testout_tile_${subsamp}_Q95_${tile}x${tile}.ppm)
  853. endforeach()
  854. add_test(tjbench-${libtype}-tile-444-${tile}x${tile}-cmp
  855. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_444_TILE}
  856. testout_tile_444_Q95_${tile}x${tile}.ppm)
  857. foreach(subsamp gray 420 422 444)
  858. set_tests_properties(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
  859. PROPERTIES DEPENDS tjbench-${libtype}-tile)
  860. endforeach()
  861. endforeach()
  862. add_test(tjbench-${libtype}-tilem-cp
  863. ${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
  864. testout_tilem.ppm)
  865. add_test(tjbench-${libtype}-tilem
  866. ${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} testout_tilem.ppm 95
  867. -rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0)
  868. set_tests_properties(tjbench-${libtype}-tilem
  869. PROPERTIES DEPENDS tjbench-${libtype}-tilem-cp)
  870. add_test(tjbench-${libtype}-tile-420m-8x8-cmp
  871. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_420M_8x8_TILE}
  872. testout_tilem_420_Q95_8x8.ppm)
  873. add_test(tjbench-${libtype}-tile-422m-8x8-cmp
  874. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_422M_8x8_TILE}
  875. testout_tilem_422_Q95_8x8.ppm)
  876. foreach(tile 16 32 64 128)
  877. foreach(subsamp 420 422)
  878. add_test(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
  879. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
  880. ${MD5_PPM_${subsamp}M_TILE}
  881. testout_tilem_${subsamp}_Q95_${tile}x${tile}.ppm)
  882. endforeach()
  883. endforeach()
  884. foreach(tile 8 16 32 64 128)
  885. foreach(subsamp 420 422)
  886. set_tests_properties(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
  887. PROPERTIES DEPENDS tjbench-${libtype}-tilem)
  888. endforeach()
  889. endforeach()
  890. endif()
  891. # These tests are carefully crafted to provide full coverage of as many of
  892. # the underlying algorithms as possible (including all of the
  893. # SIMD-accelerated ones.)
  894. macro(add_bittest PROG NAME ARGS OUTFILE INFILE MD5SUM)
  895. add_test(${PROG}-${libtype}-${NAME}
  896. ${CMAKE_CROSSCOMPILING_EMULATOR} ${PROG}${suffix} ${ARGS}
  897. -outfile ${OUTFILE} ${INFILE})
  898. add_test(${PROG}-${libtype}-${NAME}-cmp
  899. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5SUM} ${OUTFILE})
  900. set_tests_properties(${PROG}-${libtype}-${NAME}-cmp PROPERTIES
  901. DEPENDS ${PROG}-${libtype}-${NAME})
  902. if(${ARGC} GREATER 6)
  903. set(DEPENDS ${ARGN})
  904. set_tests_properties(${PROG}-${libtype}-${NAME} PROPERTIES
  905. DEPENDS ${DEPENDS})
  906. endif()
  907. endmacro()
  908. # CC: null SAMP: fullsize FDCT: islow ENT: huff
  909. add_bittest(cjpeg rgb-islow "-rgb;-dct;int;-icc;${TESTIMAGES}/test1.icc"
  910. testout_rgb_islow.jpg ${TESTIMAGES}/testorig.ppm
  911. ${MD5_JPEG_RGB_ISLOW})
  912. # CC: null SAMP: fullsize IDCT: islow ENT: huff
  913. add_bittest(djpeg rgb-islow "-dct;int;-ppm;-icc;testout_rgb_islow.icc"
  914. testout_rgb_islow.ppm testout_rgb_islow.jpg
  915. ${MD5_PPM_RGB_ISLOW} cjpeg-${libtype}-rgb-islow)
  916. add_test(djpeg-${libtype}-rgb-islow-icc-cmp
  917. ${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
  918. b06a39d730129122e85c1363ed1bbc9e testout_rgb_islow.icc)
  919. set_tests_properties(djpeg-${libtype}-rgb-islow-icc-cmp PROPERTIES
  920. DEPENDS djpeg-${libtype}-rgb-islow)
  921. add_bittest(jpegtran icc "-copy;all;-icc;${TESTIMAGES}/test2.icc"
  922. testout_rgb_islow2.jpg testout_rgb_islow.jpg
  923. ${MD5_JPEG_RGB_ISLOW2} cjpeg-${libtype}-rgb-islow)
  924. if(NOT WITH_12BIT)
  925. # CC: RGB->RGB565 SAMP: fullsize IDCT: islow ENT: huff
  926. add_bittest(djpeg rgb-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
  927. testout_rgb_islow_565.bmp testout_rgb_islow.jpg
  928. ${MD5_BMP_RGB_ISLOW_565} cjpeg-${libtype}-rgb-islow)
  929. # CC: RGB->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
  930. add_bittest(djpeg rgb-islow-565D "-dct;int;-rgb565;-bmp"
  931. testout_rgb_islow_565D.bmp testout_rgb_islow.jpg
  932. ${MD5_BMP_RGB_ISLOW_565D} cjpeg-${libtype}-rgb-islow)
  933. endif()
  934. # CC: RGB->YCC SAMP: fullsize/h2v1 FDCT: ifast ENT: 2-pass huff
  935. add_bittest(cjpeg 422-ifast-opt "-sample;2x1;-dct;fast;-opt"
  936. testout_422_ifast_opt.jpg ${TESTIMAGES}/testorig.ppm
  937. ${MD5_JPEG_422_IFAST_OPT})
  938. # CC: YCC->RGB SAMP: fullsize/h2v1 fancy IDCT: ifast ENT: huff
  939. add_bittest(djpeg 422-ifast "-dct;fast"
  940. testout_422_ifast.ppm testout_422_ifast_opt.jpg
  941. ${MD5_PPM_422_IFAST} cjpeg-${libtype}-422-ifast-opt)
  942. # CC: YCC->RGB SAMP: h2v1 merged IDCT: ifast ENT: huff
  943. add_bittest(djpeg 422m-ifast "-dct;fast;-nosmooth"
  944. testout_422m_ifast.ppm testout_422_ifast_opt.jpg
  945. ${MD5_PPM_422M_IFAST} cjpeg-${libtype}-422-ifast-opt)
  946. if(NOT WITH_12BIT)
  947. # CC: YCC->RGB565 SAMP: h2v1 merged IDCT: ifast ENT: huff
  948. add_bittest(djpeg 422m-ifast-565
  949. "-dct;int;-nosmooth;-rgb565;-dither;none;-bmp"
  950. testout_422m_ifast_565.bmp testout_422_ifast_opt.jpg
  951. ${MD5_BMP_422M_IFAST_565} cjpeg-${libtype}-422-ifast-opt)
  952. # CC: YCC->RGB565 (dithered) SAMP: h2v1 merged IDCT: ifast ENT: huff
  953. add_bittest(djpeg 422m-ifast-565D "-dct;int;-nosmooth;-rgb565;-bmp"
  954. testout_422m_ifast_565D.bmp testout_422_ifast_opt.jpg
  955. ${MD5_BMP_422M_IFAST_565D} cjpeg-${libtype}-422-ifast-opt)
  956. endif()
  957. # CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
  958. add_bittest(cjpeg 420-q100-ifast-prog
  959. "-sample;2x2;-quality;100;-dct;fast;-scans;${TESTIMAGES}/test.scan"
  960. testout_420_q100_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
  961. ${MD5_JPEG_420_IFAST_Q100_PROG})
  962. # CC: YCC->RGB SAMP: fullsize/h2v2 fancy IDCT: ifast ENT: prog huff
  963. add_bittest(djpeg 420-q100-ifast-prog "-dct;fast"
  964. testout_420_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
  965. ${MD5_PPM_420_Q100_IFAST} cjpeg-${libtype}-420-q100-ifast-prog)
  966. # CC: YCC->RGB SAMP: h2v2 merged IDCT: ifast ENT: prog huff
  967. add_bittest(djpeg 420m-q100-ifast-prog "-dct;fast;-nosmooth"
  968. testout_420m_q100_ifast.ppm testout_420_q100_ifast_prog.jpg
  969. ${MD5_PPM_420M_Q100_IFAST} cjpeg-${libtype}-420-q100-ifast-prog)
  970. # CC: RGB->Gray SAMP: fullsize FDCT: islow ENT: huff
  971. add_bittest(cjpeg gray-islow "-gray;-dct;int"
  972. testout_gray_islow.jpg ${TESTIMAGES}/testorig.ppm
  973. ${MD5_JPEG_GRAY_ISLOW})
  974. # CC: Gray->Gray SAMP: fullsize IDCT: islow ENT: huff
  975. add_bittest(djpeg gray-islow "-dct;int"
  976. testout_gray_islow.ppm testout_gray_islow.jpg
  977. ${MD5_PPM_GRAY_ISLOW} cjpeg-${libtype}-gray-islow)
  978. # CC: Gray->RGB SAMP: fullsize IDCT: islow ENT: huff
  979. add_bittest(djpeg gray-islow-rgb "-dct;int;-rgb"
  980. testout_gray_islow_rgb.ppm testout_gray_islow.jpg
  981. ${MD5_PPM_GRAY_ISLOW_RGB} cjpeg-${libtype}-gray-islow)
  982. if(NOT WITH_12BIT)
  983. # CC: Gray->RGB565 SAMP: fullsize IDCT: islow ENT: huff
  984. add_bittest(djpeg gray-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
  985. testout_gray_islow_565.bmp testout_gray_islow.jpg
  986. ${MD5_BMP_GRAY_ISLOW_565} cjpeg-${libtype}-gray-islow)
  987. # CC: Gray->RGB565 (dithered) SAMP: fullsize IDCT: islow ENT: huff
  988. add_bittest(djpeg gray-islow-565D "-dct;int;-rgb565;-bmp"
  989. testout_gray_islow_565D.bmp testout_gray_islow.jpg
  990. ${MD5_BMP_GRAY_ISLOW_565D} cjpeg-${libtype}-gray-islow)
  991. endif()
  992. # CC: RGB->YCC SAMP: fullsize smooth/h2v2 smooth FDCT: islow
  993. # ENT: 2-pass huff
  994. add_bittest(cjpeg 420s-ifast-opt "-sample;2x2;-smooth;1;-dct;int;-opt"
  995. testout_420s_ifast_opt.jpg ${TESTIMAGES}/testorig.ppm
  996. ${MD5_JPEG_420S_IFAST_OPT})
  997. if(FLOATTEST)
  998. # CC: RGB->YCC SAMP: fullsize/int FDCT: float ENT: prog huff
  999. add_bittest(cjpeg 3x2-float-prog "-sample;3x2;-dct;float;-prog"
  1000. testout_3x2_float_prog.jpg ${TESTIMAGES}/testorig.ppm
  1001. ${MD5_JPEG_3x2_FLOAT_PROG_${FLOATTEST_UC}})
  1002. # CC: YCC->RGB SAMP: fullsize/int IDCT: float ENT: prog huff
  1003. add_bittest(djpeg 3x2-float-prog "-dct;float"
  1004. testout_3x2_float.ppm testout_3x2_float_prog.jpg
  1005. ${MD5_PPM_3x2_FLOAT_${FLOATTEST_UC}} cjpeg-${libtype}-3x2-float-prog)
  1006. endif()
  1007. # CC: RGB->YCC SAMP: fullsize/int FDCT: ifast ENT: prog huff
  1008. add_bittest(cjpeg 3x2-ifast-prog "-sample;3x2;-dct;fast;-prog"
  1009. testout_3x2_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
  1010. ${MD5_JPEG_3x2_IFAST_PROG})
  1011. # CC: YCC->RGB SAMP: fullsize/int IDCT: ifast ENT: prog huff
  1012. add_bittest(djpeg 3x2-ifast-prog "-dct;fast"
  1013. testout_3x2_ifast.ppm testout_3x2_ifast_prog.jpg
  1014. ${MD5_PPM_3x2_IFAST} cjpeg-${libtype}-3x2-ifast-prog)
  1015. if(WITH_ARITH_ENC)
  1016. # CC: YCC->RGB SAMP: fullsize/h2v2 FDCT: islow ENT: arith
  1017. add_bittest(cjpeg 420-islow-ari "-dct;int;-arithmetic"
  1018. testout_420_islow_ari.jpg ${TESTIMAGES}/testorig.ppm
  1019. ${MD5_JPEG_420_ISLOW_ARI})
  1020. add_bittest(jpegtran 420-islow-ari "-arithmetic"
  1021. testout_420_islow_ari2.jpg ${TESTIMAGES}/testimgint.jpg
  1022. ${MD5_JPEG_420_ISLOW_ARI})
  1023. # CC: YCC->RGB SAMP: fullsize FDCT: islow ENT: prog arith
  1024. add_bittest(cjpeg 444-islow-progari
  1025. "-sample;1x1;-dct;int;-prog;-arithmetic"
  1026. testout_444_islow_progari.jpg ${TESTIMAGES}/testorig.ppm
  1027. ${MD5_JPEG_444_ISLOW_PROGARI})
  1028. endif()
  1029. if(WITH_ARITH_DEC)
  1030. # CC: RGB->YCC SAMP: h2v2 merged IDCT: ifast ENT: arith
  1031. add_bittest(djpeg 420m-ifast-ari "-fast;-skip;1,20;-ppm"
  1032. testout_420m_ifast_ari.ppm ${TESTIMAGES}/testimgari.jpg
  1033. ${MD5_PPM_420M_IFAST_ARI})
  1034. add_bittest(jpegtran 420-islow ""
  1035. testout_420_islow.jpg ${TESTIMAGES}/testimgari.jpg
  1036. ${MD5_JPEG_420_ISLOW})
  1037. endif()
  1038. # 2/1-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 16x16 islow ENT: huff
  1039. # 15/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 15x15 islow ENT: huff
  1040. # 13/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 13x13 islow ENT: huff
  1041. # 11/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 11x11 islow ENT: huff
  1042. # 9/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 9x9 islow ENT: huff
  1043. # 7/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 7x7 islow/14x14 islow
  1044. # ENT: huff
  1045. # 3/4-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 6x6 islow/12x12 islow
  1046. # ENT: huff
  1047. # 5/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 5x5 islow/10x10 islow
  1048. # ENT: huff
  1049. # 1/2-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 4x4 islow/8x8 islow
  1050. # ENT: huff
  1051. # 3/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 3x3 islow/6x6 islow
  1052. # ENT: huff
  1053. # 1/4-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 2x2 islow/4x4 islow
  1054. # ENT: huff
  1055. # 1/8-- CC: YCC->RGB SAMP: h2v2 merged IDCT: 1x1 islow/2x2 islow
  1056. # ENT: huff
  1057. 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)
  1058. string(REGEX REPLACE "_" "/" scalearg ${scale})
  1059. add_bittest(djpeg 420m-islow-${scale}
  1060. "-dct;int;-scale;${scalearg};-nosmooth;-ppm"
  1061. testout_420m_islow_${scale}.ppm ${TESTIMAGES}/${TESTORIG}
  1062. ${MD5_PPM_420M_ISLOW_${scale}})
  1063. endforeach()
  1064. if(NOT WITH_12BIT)
  1065. # CC: YCC->RGB (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
  1066. add_bittest(djpeg 420-islow-256 "-dct;int;-colors;256;-bmp"
  1067. testout_420_islow_256.bmp ${TESTIMAGES}/${TESTORIG}
  1068. ${MD5_BMP_420_ISLOW_256})
  1069. # CC: YCC->RGB565 SAMP: h2v2 fancy IDCT: islow ENT: huff
  1070. add_bittest(djpeg 420-islow-565 "-dct;int;-rgb565;-dither;none;-bmp"
  1071. testout_420_islow_565.bmp ${TESTIMAGES}/${TESTORIG}
  1072. ${MD5_BMP_420_ISLOW_565})
  1073. # CC: YCC->RGB565 (dithered) SAMP: h2v2 fancy IDCT: islow ENT: huff
  1074. add_bittest(djpeg 420-islow-565D "-dct;int;-rgb565;-bmp"
  1075. testout_420_islow_565D.bmp ${TESTIMAGES}/${TESTORIG}
  1076. ${MD5_BMP_420_ISLOW_565D})
  1077. # CC: YCC->RGB565 SAMP: h2v2 merged IDCT: islow ENT: huff
  1078. add_bittest(djpeg 420m-islow-565
  1079. "-dct;int;-nosmooth;-rgb565;-dither;none;-bmp"
  1080. testout_420m_islow_565.bmp ${TESTIMAGES}/${TESTORIG}
  1081. ${MD5_BMP_420M_ISLOW_565})
  1082. # CC: YCC->RGB565 (dithered) SAMP: h2v2 merged IDCT: islow ENT: huff
  1083. add_bittest(djpeg 420m-islow-565D "-dct;int;-nosmooth;-rgb565;-bmp"
  1084. testout_420m_islow_565D.bmp ${TESTIMAGES}/${TESTORIG}
  1085. ${MD5_BMP_420M_ISLOW_565D})
  1086. endif()
  1087. # Partial decode tests. These tests are designed to cover all of the
  1088. # possible code paths in jpeg_skip_scanlines().
  1089. # Context rows: Yes Intra-iMCU row: Yes iMCU row prefetch: No ENT: huff
  1090. add_bittest(djpeg 420-islow-skip15_31 "-dct;int;-skip;15,31;-ppm"
  1091. testout_420_islow_skip15,31.ppm ${TESTIMAGES}/${TESTORIG}
  1092. ${MD5_PPM_420_ISLOW_SKIP15_31})
  1093. # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: Yes ENT: arith
  1094. if(WITH_ARITH_DEC)
  1095. add_bittest(djpeg 420-islow-ari-skip16_139 "-dct;int;-skip;16,139;-ppm"
  1096. testout_420_islow_ari_skip16,139.ppm ${TESTIMAGES}/testimgari.jpg
  1097. ${MD5_PPM_420_ISLOW_ARI_SKIP16_139})
  1098. endif()
  1099. # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff
  1100. add_test(cjpeg-${libtype}-420-islow-prog
  1101. ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog
  1102. -outfile testout_420_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
  1103. add_bittest(djpeg 420-islow-prog-crop62x62_71_71
  1104. "-dct;int;-crop;62x62+71+71;-ppm"
  1105. testout_420_islow_prog_crop62x62,71,71.ppm testout_420_islow_prog.jpg
  1106. ${MD5_PPM_420_ISLOW_PROG_CROP62x62_71_71} cjpeg-${libtype}-420-islow-prog)
  1107. # Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: arith
  1108. if(WITH_ARITH_DEC)
  1109. add_bittest(djpeg 420-islow-ari-crop53x53_4_4
  1110. "-dct;int;-crop;53x53+4+4;-ppm"
  1111. testout_420_islow_ari_crop53x53,4,4.ppm ${TESTIMAGES}/testimgari.jpg
  1112. ${MD5_PPM_420_ISLOW_ARI_CROP53x53_4_4})
  1113. endif()
  1114. # Context rows: No Intra-iMCU row: Yes ENT: huff
  1115. add_test(cjpeg-${libtype}-444-islow
  1116. ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -sample 1x1
  1117. -outfile testout_444_islow.jpg ${TESTIMAGES}/testorig.ppm)
  1118. add_bittest(djpeg 444-islow-skip1_6 "-dct;int;-skip;1,6;-ppm"
  1119. testout_444_islow_skip1,6.ppm testout_444_islow.jpg
  1120. ${MD5_PPM_444_ISLOW_SKIP1_6} cjpeg-${libtype}-444-islow)
  1121. # Context rows: No Intra-iMCU row: No ENT: prog huff
  1122. add_test(cjpeg-${libtype}-444-islow-prog
  1123. ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog -sample 1x1
  1124. -outfile testout_444_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
  1125. add_bittest(djpeg 444-islow-prog-crop98x98_13_13
  1126. "-dct;int;-crop;98x98+13+13;-ppm"
  1127. testout_444_islow_prog_crop98x98,13,13.ppm testout_444_islow_prog.jpg
  1128. ${MD5_PPM_444_ISLOW_PROG_CROP98x98_13_13} cjpeg-${libtype}-444-islow-prog)
  1129. # Context rows: No Intra-iMCU row: No ENT: arith
  1130. if(WITH_ARITH_ENC)
  1131. add_test(cjpeg-${libtype}-444-islow-ari
  1132. ${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -arithmetic
  1133. -sample 1x1 -outfile testout_444_islow_ari.jpg
  1134. ${TESTIMAGES}/testorig.ppm)
  1135. if(WITH_ARITH_DEC)
  1136. add_bittest(djpeg 444-islow-ari-crop37x37_0_0
  1137. "-dct;int;-crop;37x37+0+0;-ppm"
  1138. testout_444_islow_ari_crop37x37,0,0.ppm testout_444_islow_ari.jpg
  1139. ${MD5_PPM_444_ISLOW_ARI_CROP37x37_0_0} cjpeg-${libtype}-444-islow-ari)
  1140. endif()
  1141. endif()
  1142. add_bittest(jpegtran crop "-crop;120x90+20+50;-transpose;-perfect"
  1143. testout_crop.jpg ${TESTIMAGES}/${TESTORIG}
  1144. ${MD5_JPEG_CROP})
  1145. endforeach()
  1146. add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
  1147. ${CMAKE_CURRENT_SOURCE_DIR}/cmakescripts/testclean.cmake)
  1148. configure_file(croptest.in croptest @ONLY)
  1149. add_custom_target(croptest
  1150. COMMAND echo croptest
  1151. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/croptest)
  1152. if(WITH_TURBOJPEG)
  1153. configure_file(tjbenchtest.in tjbenchtest @ONLY)
  1154. configure_file(tjexampletest.in tjexampletest @ONLY)
  1155. if(WIN32)
  1156. set(BASH bash)
  1157. endif()
  1158. if(WITH_JAVA)
  1159. configure_file(tjbenchtest.java.in tjbenchtest.java @ONLY)
  1160. configure_file(tjexampletest.java.in tjexampletest.java @ONLY)
  1161. add_custom_target(tjtest
  1162. COMMAND echo tjbenchtest
  1163. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
  1164. COMMAND echo tjbenchtest -alloc
  1165. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -alloc
  1166. COMMAND echo tjbenchtest -yuv
  1167. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
  1168. COMMAND echo tjbenchtest -yuv -alloc
  1169. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
  1170. COMMAND echo tjbenchtest -progressive
  1171. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
  1172. COMMAND echo tjbenchtest -progressive -yuv
  1173. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
  1174. COMMAND echo tjexampletest
  1175. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
  1176. COMMAND echo tjbenchtest.java
  1177. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
  1178. COMMAND echo tjbenchtest.java -yuv
  1179. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -yuv
  1180. COMMAND echo tjbenchtest.java -progressive
  1181. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -progressive
  1182. COMMAND echo tjexampletest.java -progressive -yuv
  1183. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
  1184. -progressive -yuv
  1185. COMMAND echo tjexampletest.java
  1186. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java
  1187. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
  1188. ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
  1189. ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest)
  1190. else()
  1191. add_custom_target(tjtest
  1192. COMMAND echo tjbenchtest
  1193. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
  1194. COMMAND echo tjbenchtest -alloc
  1195. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -alloc
  1196. COMMAND echo tjbenchtest -yuv
  1197. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
  1198. COMMAND echo tjbenchtest -yuv -alloc
  1199. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
  1200. COMMAND echo tjbenchtest -progressive
  1201. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
  1202. COMMAND echo tjbenchtest -progressive -yuv
  1203. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
  1204. COMMAND echo tjexampletest
  1205. COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
  1206. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
  1207. endif()
  1208. endif()
  1209. ###############################################################################
  1210. # INSTALLATION
  1211. ###############################################################################
  1212. set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
  1213. if(WITH_TURBOJPEG)
  1214. if(ENABLE_SHARED)
  1215. # install(TARGETS turbojpeg tjbench
  1216. # ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1217. # LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  1218. # RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
  1219. # if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
  1220. # CMAKE_C_LINKER_SUPPORTS_PDB)
  1221. # install(FILES "$<TARGET_PDB_FILE:turbojpeg>"
  1222. # DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
  1223. # endif()
  1224. endif()
  1225. if(ENABLE_STATIC)
  1226. # install(TARGETS turbojpeg-static ARCHIVE
  1227. # DESTINATION ${CMAKE_INSTALL_LIBDIR})
  1228. # if(NOT ENABLE_SHARED)
  1229. # if(MSVC_IDE OR XCODE)
  1230. # set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
  1231. # else()
  1232. # set(DIR ${CMAKE_CURRENT_BINARY_DIR})
  1233. # endif()
  1234. # install(PROGRAMS ${DIR}/tjbench-static${EXE}
  1235. # DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
  1236. # endif()
  1237. endif()
  1238. # install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h
  1239. # DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
  1240. endif()
  1241. if(ENABLE_STATIC)
  1242. # install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
  1243. # if(NOT ENABLE_SHARED)
  1244. # if(MSVC_IDE OR XCODE)
  1245. # set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
  1246. # else()
  1247. # set(DIR ${CMAKE_CURRENT_BINARY_DIR})
  1248. # endif()
  1249. # install(PROGRAMS ${DIR}/cjpeg-static${EXE}
  1250. # DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
  1251. # install(PROGRAMS ${DIR}/djpeg-static${EXE}
  1252. # DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
  1253. # install(PROGRAMS ${DIR}/jpegtran-static${EXE}
  1254. # DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
  1255. # endif()
  1256. endif()
  1257. # install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
  1258. #install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
  1259. # ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt
  1260. # ${CMAKE_CURRENT_SOURCE_DIR}/tjexample.c
  1261. # ${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt
  1262. # ${CMAKE_CURRENT_SOURCE_DIR}/structure.txt
  1263. # ${CMAKE_CURRENT_SOURCE_DIR}/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/wizard.txt
  1264. # ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
  1265. if(WITH_JAVA)
  1266. # install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java
  1267. # DESTINATION ${CMAKE_INSTALL_DOCDIR})
  1268. endif()
  1269. if(UNIX OR MINGW)
  1270. # install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cjpeg.1
  1271. # ${CMAKE_CURRENT_SOURCE_DIR}/djpeg.1 ${CMAKE_CURRENT_SOURCE_DIR}/jpegtran.1
  1272. # ${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
  1273. # ${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
  1274. # DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
  1275. endif()
  1276. # install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
  1277. # ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
  1278. # DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  1279. # install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
  1280. # ${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
  1281. # ${CMAKE_CURRENT_SOURCE_DIR}/jpeglib.h
  1282. # DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
  1283. # include(cmakescripts/BuildPackages.cmake)
  1284. # configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmakescripts/cmake_uninstall.cmake.in"
  1285. # "cmake_uninstall.cmake" IMMEDIATE @ONLY)
  1286. # add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P cmake_uninstall.cmake)