blob: 8448eeb7c6bbcaf54fa7871ad367c25e8f7cd73e [file] [log] [blame]
DRC84697032010-10-15 03:43:24 +00001#
2# Setup
3#
4
5cmake_minimum_required(VERSION 2.6)
6
DRC5d6f8582011-02-18 23:08:58 +00007project(libjpeg-turbo C)
DRC3367f402012-07-03 20:00:35 +00008set(VERSION 1.2.2)
DRC84697032010-10-15 03:43:24 +00009
DRC378da4d2010-10-15 19:11:11 +000010if(MINGW OR CYGWIN)
DRC84697032010-10-15 03:43:24 +000011 execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
12 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
13elseif(WIN32)
DRC5e3bb3e2012-10-12 10:19:09 +000014 execute_process(COMMAND "wmic.exe" "os" "get" "LocalDateTime" OUTPUT_VARIABLE
15 BUILD)
16 string(REGEX REPLACE "[^0-9]" "" BUILD "${BUILD}")
17 if (BUILD STREQUAL "")
18 execute_process(COMMAND "cmd.exe" "/C" "DATE" "/T" OUTPUT_VARIABLE BUILD)
19 string(REGEX REPLACE ".*[ ]([0-9]*)[/.]([0-9]*)[/.]([0-9]*).*" "\\3\\2\\1" BUILD "${BUILD}")
20 else()
21 string(SUBSTRING "${BUILD}" 0 8 BUILD)
22 endif()
DRC84697032010-10-15 03:43:24 +000023else()
DRC378da4d2010-10-15 19:11:11 +000024 message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
DRC84697032010-10-15 03:43:24 +000025endif()
26
DRC2ffcb8e2011-04-04 04:56:24 +000027# This does nothing except when using MinGW. CMAKE_BUILD_TYPE has no meaning
28# in Visual Studio, and it always defaults to Debug when using NMake.
DRC84697032010-10-15 03:43:24 +000029if(NOT CMAKE_BUILD_TYPE)
30 set(CMAKE_BUILD_TYPE Release)
31endif()
32
33message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
34
35# This only works if building from the command line. There is currently no way
DRC2ffcb8e2011-04-04 04:56:24 +000036# to set a variable's value based on the build type when using Visual Studio.
DRC84697032010-10-15 03:43:24 +000037if(CMAKE_BUILD_TYPE STREQUAL "Debug")
38 set(BUILD "${BUILD}d")
39endif()
40
DRCeb2b9d62010-10-15 04:55:13 +000041message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
42
DRCddcd5a12011-04-15 00:24:02 +000043option(WITH_SIMD "Include SIMD extensions" TRUE)
44option(WITH_ARITH_ENC "Include arithmetic encoding support" TRUE)
45option(WITH_ARITH_DEC "Include arithmetic decoding support" TRUE)
46option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
47option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward incompatible with libjpeg v6b)" FALSE)
48option(WITH_JAVA "Build Java wrapper for the TurboJPEG/OSS library" FALSE)
DRC245cfdf2010-11-23 17:11:06 +000049
50if(WITH_ARITH_ENC)
51 set(C_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000052 message(STATUS "Arithmetic encoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000053else()
DRC990e28d2011-01-04 21:40:11 +000054 message(STATUS "Arithmetic encoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000055endif()
56
57if(WITH_ARITH_DEC)
58 set(D_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000059 message(STATUS "Arithmetic decoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000060else()
DRC990e28d2011-01-04 21:40:11 +000061 message(STATUS "Arithmetic decoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000062endif()
63
DRC957d6232011-04-01 11:13:11 +000064if(WITH_JAVA)
65 message(STATUS "TurboJPEG/OSS Java wrapper enabled")
DRC218c0c12011-02-05 06:01:18 +000066else()
DRC957d6232011-04-01 11:13:11 +000067 message(STATUS "TurboJPEG/OSS Java wrapper disabled")
DRC218c0c12011-02-05 06:01:18 +000068endif()
69
DRC84697032010-10-15 03:43:24 +000070set(JPEG_LIB_VERSION 62)
71set(DLL_VERSION ${JPEG_LIB_VERSION})
DRCa9d5b252010-10-15 06:42:45 +000072set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000073if(WITH_JPEG8)
74 set(JPEG_LIB_VERSION 80)
75 set(DLL_VERSION 8)
DRCa9d5b252010-10-15 06:42:45 +000076 set(FULLVERSION ${DLL_VERSION}.0.2)
DRCf38eee02011-02-18 07:00:38 +000077 message(STATUS "Emulating libjpeg v8 API/ABI")
DRC84697032010-10-15 03:43:24 +000078elseif(WITH_JPEG7)
79 set(JPEG_LIB_VERSION 70)
80 set(DLL_VERSION 7)
DRCa9d5b252010-10-15 06:42:45 +000081 set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000082 message(STATUS "Emulating libjpeg v7 API/ABI")
83endif(WITH_JPEG8)
84
85if(MSVC)
86 # Use the static C library for all build types
87 foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
DRC2e4d0442011-02-08 01:18:37 +000088 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
DRC84697032010-10-15 03:43:24 +000089 if(${var} MATCHES "/MD")
90 string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
91 endif()
92 endforeach()
93
94 add_definitions(-W3 -wd4996)
95endif()
96
97# Detect whether compiler is 64-bit
98if(MSVC AND CMAKE_CL_64)
99 set(SIMD_X86_64 1)
100 set(64BIT 1)
101elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
102 set(SIMD_X86_64 1)
103 set(64BIT 1)
104endif()
105
106if(64BIT)
107 message(STATUS "64-bit build")
108else()
109 message(STATUS "32-bit build")
110endif()
111
112configure_file(win/jconfig.h.in jconfig.h)
113configure_file(win/config.h.in config.h)
114
115include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
116
DRC957d6232011-04-01 11:13:11 +0000117if(WITH_JAVA)
118 find_package(Java)
119 find_package(JNI)
DRCdb425062011-04-03 06:10:18 +0000120 if(DEFINED JAVACFLAGS)
121 message(STATUS "Java compiler flags = ${JAVACFLAGS}")
122 endif()
DRC218c0c12011-02-05 06:01:18 +0000123endif()
124
DRC84697032010-10-15 03:43:24 +0000125
126#
127# Targets
128#
129
DRC245cfdf2010-11-23 17:11:06 +0000130set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
131 jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
132 jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
133 jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
134 jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
135 jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
136 jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
137
138if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
139 set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
140endif()
141
142if(WITH_ARITH_ENC)
143 set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
144endif()
145
146if(WITH_ARITH_DEC)
147 set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
148endif()
DRC84697032010-10-15 03:43:24 +0000149
150if(WITH_SIMD)
151 add_definitions(-DWITH_SIMD)
152 add_subdirectory(simd)
153 if(SIMD_X86_64)
154 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
155 else()
156 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
157 endif()
158 # This tells CMake that the "source" files haven't been generated yet
159 set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
160else()
161 set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
DRC6f4ba612010-10-16 21:27:38 +0000162 message(STATUS "Not using SIMD acceleration")
DRC84697032010-10-15 03:43:24 +0000163endif()
164
DRC957d6232011-04-01 11:13:11 +0000165if(WITH_JAVA)
166 add_subdirectory(java)
167endif()
168
DRC84697032010-10-15 03:43:24 +0000169add_subdirectory(sharedlib)
170
171add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
DRC84697032010-10-15 03:43:24 +0000172if(NOT MSVC)
173 set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
174endif()
175if(WITH_SIMD)
176 add_dependencies(jpeg-static simd)
177endif()
178
DRC418dbdf2011-05-26 10:45:06 +0000179set(TURBOJPEG_SOURCES turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c)
DRC957d6232011-04-01 11:13:11 +0000180if(WITH_JAVA)
DRC218c0c12011-02-05 06:01:18 +0000181 set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
DRC957d6232011-04-01 11:13:11 +0000182 include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
DRC218c0c12011-02-05 06:01:18 +0000183endif()
184
185add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
DRC84697032010-10-15 03:43:24 +0000186set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
DRC389c4722011-02-06 18:48:13 +0000187if(MINGW)
188 set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
189endif()
DRC84697032010-10-15 03:43:24 +0000190target_link_libraries(turbojpeg jpeg-static)
191set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
192
193add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
DRC418dbdf2011-05-26 10:45:06 +0000194 turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c)
DRC84697032010-10-15 03:43:24 +0000195if(NOT MSVC)
196 set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
197endif()
198if(WITH_SIMD)
199 add_dependencies(turbojpeg-static simd)
200endif()
201
DRC3185cb92011-05-25 03:52:22 +0000202add_executable(tjunittest tjunittest.c tjutil.c)
203target_link_libraries(tjunittest turbojpeg)
DRC84697032010-10-15 03:43:24 +0000204
DRC3185cb92011-05-25 03:52:22 +0000205add_executable(tjunittest-static tjunittest.c tjutil.c)
206target_link_libraries(tjunittest-static turbojpeg-static)
DRC84697032010-10-15 03:43:24 +0000207
DRC3185cb92011-05-25 03:52:22 +0000208add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
DRC43484642011-05-24 17:03:51 +0000209 wrppm.c)
DRC4ad60032011-09-20 05:41:54 +0000210target_link_libraries(tjbench turbojpeg jpeg-static)
DRC3185cb92011-05-25 03:52:22 +0000211set_property(TARGET tjbench PROPERTY COMPILE_FLAGS
DRC43484642011-05-24 17:03:51 +0000212 "-DBMP_SUPPORTED -DPPM_SUPPORTED")
DRC84697032010-10-15 03:43:24 +0000213
DRC3185cb92011-05-25 03:52:22 +0000214add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
DRC43484642011-05-24 17:03:51 +0000215 wrppm.c)
DRC3185cb92011-05-25 03:52:22 +0000216target_link_libraries(tjbench-static turbojpeg-static jpeg-static)
217set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS
DRC43484642011-05-24 17:03:51 +0000218 "-DBMP_SUPPORTED -DPPM_SUPPORTED")
DRC84697032010-10-15 03:43:24 +0000219
220add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
221 rdtarga.c)
222set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
DRC5ee81f42011-05-02 00:35:50 +0000223 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000224target_link_libraries(cjpeg-static jpeg-static)
225
226add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
227 wrppm.c wrtarga.c)
228set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
DRC5ee81f42011-05-02 00:35:50 +0000229 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000230target_link_libraries(djpeg-static jpeg-static)
231
232add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
233target_link_libraries(jpegtran-static jpeg-static)
DRC7e3fd2f2011-05-25 06:04:43 +0000234set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
DRC84697032010-10-15 03:43:24 +0000235
236add_executable(rdjpgcom rdjpgcom.c)
237
DRCa81f5422014-06-22 20:50:14 +0000238add_executable(wrjpgcom wrjpgcom.c)
DRC84697032010-10-15 03:43:24 +0000239
240
241#
242# Tests
243#
244
DRC957d6232011-04-01 11:13:11 +0000245if(MSVC_IDE)
246 set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
247else()
248 set(OBJDIR "")
249endif()
250
DRC84697032010-10-15 03:43:24 +0000251enable_testing()
DRC957d6232011-04-01 11:13:11 +0000252if(WITH_JAVA)
253add_test(TJUnitTest ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest)
254add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv)
255add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi)
256add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv)
257endif()
DRC3185cb92011-05-25 03:52:22 +0000258add_test(tjunittest tjunittest)
259add_test(tjunittest-alloc tjunittest -alloc)
260add_test(tjunittest-yuv tjunittest -yuv)
DRC6ebf1102012-01-31 04:58:26 +0000261add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
262add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutint.jpg)
263add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
264add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.jpg testoutfst.jpg)
265add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
266add_test(cjpeg-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst100.jpg testoutfst100.jpg)
267add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
DRC84697032010-10-15 03:43:24 +0000268if(WITH_SIMD)
DRC6ebf1102012-01-31 04:58:26 +0000269add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000270else()
DRC6ebf1102012-01-31 04:58:26 +0000271add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000272endif()
DRC6ebf1102012-01-31 04:58:26 +0000273add_test(cjpeg-int-gray sharedlib/cjpeg -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
274add_test(cjpeg-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimggray.jpg testoutgray.jpg)
275add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
276add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.ppm testoutint.ppm)
277add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
278add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.ppm testoutfst.ppm)
279add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
DRC84697032010-10-15 03:43:24 +0000280if(WITH_SIMD)
DRC6ebf1102012-01-31 04:58:26 +0000281add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000282else()
DRC6ebf1102012-01-31 04:58:26 +0000283add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000284endif()
DRC6ebf1102012-01-31 04:58:26 +0000285add_test(djpeg-int-1_2 sharedlib/djpeg -dct int -scale 1/2 -ppm -outfile testoutint1_2.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
286add_test(djpeg-int-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint1_2.ppm testoutint1_2.ppm)
287add_test(djpeg-fast-1_2 sharedlib/djpeg -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
288add_test(djpeg-fast-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_2.ppm testoutfst1_2.ppm)
289add_test(djpeg-int-1_4 sharedlib/djpeg -dct int -scale 1/4 -ppm -outfile testoutint1_4.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
290add_test(djpeg-int-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint1_4.ppm testoutint1_4.ppm)
291add_test(djpeg-fast-1_4 sharedlib/djpeg -dct fast -scale 1/4 -ppm -outfile testoutfst1_4.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
292add_test(djpeg-fast-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_4.ppm testoutfst1_4.ppm)
293add_test(djpeg-int-1_8 sharedlib/djpeg -dct int -scale 1/8 -ppm -outfile testoutint1_8.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
294add_test(djpeg-int-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint1_8.ppm testoutint1_8.ppm)
295add_test(djpeg-fast-1_8 sharedlib/djpeg -dct fast -scale 1/8 -ppm -outfile testoutfst1_8.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
296add_test(djpeg-fast-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_8.ppm testoutfst1_8.ppm)
297add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
298add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimg.bmp testout.bmp)
299add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
300add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000301add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg)
DRC6ebf1102012-01-31 04:58:26 +0000302add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000303if(WITH_ARITH_ENC)
DRC6ebf1102012-01-31 04:58:26 +0000304add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
305add_test(cjpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testoutari.jpg)
306add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg)
307add_test(jpegtran-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testouta.jpg)
DRCe1636532013-11-06 07:45:39 +0000308add_test(cjpeg-prog-ari sharedlib/cjpeg -dct int -progressive -arithmetic -sample 1x1 -outfile testoutpa.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
309add_test(cjpeg-prog-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgpa.jpg testoutpa.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000310endif()
311if(WITH_ARITH_DEC)
DRC6ebf1102012-01-31 04:58:26 +0000312add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
313add_test(djpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.ppm testoutari.ppm)
314add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
315add_test(jpegtran-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000316endif()
DRC6ebf1102012-01-31 04:58:26 +0000317add_test(jpegtran-crop sharedlib/jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
318add_test(jpegtran-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgcrop.jpg testoutcrop.jpg)
DRC84697032010-10-15 03:43:24 +0000319
DRC3185cb92011-05-25 03:52:22 +0000320add_test(tjunittest-static tjunittest-static)
321add_test(tjunittest-static-alloc tjunittest-static -alloc)
322add_test(tjunittest-static-yuv tjunittest-static -yuv)
DRC6ebf1102012-01-31 04:58:26 +0000323add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
324add_test(cjpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutint.jpg)
325add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
326add_test(cjpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.jpg testoutfst.jpg)
327add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
328add_test(cjpeg-static-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst100.jpg testoutfst100.jpg)
329add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
DRC84697032010-10-15 03:43:24 +0000330if(WITH_SIMD)
DRC6ebf1102012-01-31 04:58:26 +0000331add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000332else()
DRC6ebf1102012-01-31 04:58:26 +0000333add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000334endif()
DRC6ebf1102012-01-31 04:58:26 +0000335add_test(cjpeg-static-int-gray cjpeg-static -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
336add_test(cjpeg-static-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimggray.jpg testoutgray.jpg)
337add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
338add_test(djpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.ppm testoutint.ppm)
339add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
340add_test(djpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst.ppm testoutfst.ppm)
341add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
DRC84697032010-10-15 03:43:24 +0000342if(WITH_SIMD)
DRC6ebf1102012-01-31 04:58:26 +0000343add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000344else()
DRC6ebf1102012-01-31 04:58:26 +0000345add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000346endif()
DRC6ebf1102012-01-31 04:58:26 +0000347add_test(djpeg-static-int-1_2 djpeg-static -dct int -scale 1/2 -ppm -outfile testoutint1_2.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
348add_test(djpeg-static-int-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint1_2.ppm testoutint1_2.ppm)
349add_test(djpeg-static-fast-1_2 djpeg-static -dct fast -scale 1/2 -ppm -outfile testoutfst1_2.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
350add_test(djpeg-static-fast-1_2-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_2.ppm testoutfst1_2.ppm)
351add_test(djpeg-static-int-1_4 djpeg-static -dct int -scale 1/4 -ppm -outfile testoutint1_4.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
352add_test(djpeg-static-int-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint1_4.ppm testoutint1_4.ppm)
353add_test(djpeg-static-fast-1_4 djpeg-static -dct fast -scale 1/4 -ppm -outfile testoutfst1_4.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
354add_test(djpeg-static-fast-1_4-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_4.ppm testoutfst1_4.ppm)
355add_test(djpeg-static-int-1_8 djpeg-static -dct int -scale 1/8 -ppm -outfile testoutint1_8.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
356add_test(djpeg-static-int-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint1_8.ppm testoutint1_8.ppm)
357add_test(djpeg-static-fast-1_8 djpeg-static -dct fast -scale 1/8 -ppm -outfile testoutfst1_8.ppm ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
358add_test(djpeg-static-fast-1_8-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgfst1_8.ppm testoutfst1_8.ppm)
359add_test(djpeg-static-256 djpeg-static -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
360add_test(djpeg-static-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimg.bmp testout.bmp)
361add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
362add_test(cjpeg-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000363add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg)
DRC6ebf1102012-01-31 04:58:26 +0000364add_test(jpegtran-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000365if(WITH_ARITH_ENC)
DRC6ebf1102012-01-31 04:58:26 +0000366add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
367add_test(cjpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testoutari.jpg)
368add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg)
369add_test(jpegtran-static-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg testouta.jpg)
DRCe1636532013-11-06 07:45:39 +0000370add_test(cjpeg-static-prog-ari cjpeg-static -dct int -progressive -arithmetic -sample 1x1 -outfile testoutpa.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.ppm)
371add_test(cjpeg-static-prog-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgpa.jpg testoutpa.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000372endif()
373if(WITH_ARITH_DEC)
DRC6ebf1102012-01-31 04:58:26 +0000374add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
375add_test(djpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgari.ppm testoutari.ppm)
376add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimages/testimgari.jpg)
377add_test(jpegtran-static-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000378endif()
DRC6ebf1102012-01-31 04:58:26 +0000379add_test(jpegtran-static-crop jpegtran-static -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testimages/testorig.jpg)
380add_test(jpegtran-static-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimages/testimgcrop.jpg testoutcrop.jpg)
DRC2c0a4e12010-10-16 08:51:43 +0000381
DRCa0f878a2011-04-02 04:43:14 +0000382add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
383 ${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
384
DRC2c0a4e12010-10-16 08:51:43 +0000385
386#
387# Installer
388#
389
DRC2c0a4e12010-10-16 08:51:43 +0000390if(MSVC)
391 set(INST_PLATFORM "Visual C++")
DRCb94f2de2011-03-22 09:31:25 +0000392 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-vc)
393 set(INST_DIR ${CMAKE_PROJECT_NAME})
DRC2c0a4e12010-10-16 08:51:43 +0000394elseif(MINGW)
395 set(INST_PLATFORM GCC)
DRCb94f2de2011-03-22 09:31:25 +0000396 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-gcc)
397 set(INST_DIR ${CMAKE_PROJECT_NAME}-gcc)
DRC2c0a4e12010-10-16 08:51:43 +0000398 set(INST_DEFS -DGCC)
399endif()
400
401if(64BIT)
402 set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
403 set(INST_NAME ${INST_NAME}64)
DRCb94f2de2011-03-22 09:31:25 +0000404 set(INST_DIR ${INST_DIR}64)
DRC2c0a4e12010-10-16 08:51:43 +0000405 set(INST_DEFS ${INST_DEFS} -DWIN64)
406endif()
407
DRC957d6232011-04-01 11:13:11 +0000408if(WITH_JAVA)
409 set(INST_DEFS ${INST_DEFS} -DJAVA)
410endif()
411
DRC2c0a4e12010-10-16 08:51:43 +0000412if(MSVC_IDE)
DRC926e01f2011-04-06 06:35:38 +0000413 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
DRC2c0a4e12010-10-16 08:51:43 +0000414else()
415 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
416endif()
417
418configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
419
420add_custom_target(installer
421 makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
DRCb94f2de2011-03-22 09:31:25 +0000422 DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
DRC3185cb92011-05-25 03:52:22 +0000423 cjpeg djpeg jpegtran tjbench
DRC2c0a4e12010-10-16 08:51:43 +0000424 SOURCES libjpeg-turbo.nsi)
DRC7284c9a2010-10-16 21:55:14 +0000425
DRC3185cb92011-05-25 03:52:22 +0000426install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom tjbench
DRC7284c9a2010-10-16 21:55:14 +0000427 ARCHIVE DESTINATION lib
428 LIBRARY DESTINATION lib
429 RUNTIME DESTINATION bin
430)
431
DRCa1647c82012-02-10 00:39:05 +0000432install(FILES ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
433 ${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt
434 ${CMAKE_SOURCE_DIR}/structure.txt ${CMAKE_SOURCE_DIR}/usage.txt
435 ${CMAKE_SOURCE_DIR}/wizard.txt
DRC7284c9a2010-10-16 21:55:14 +0000436 DESTINATION doc)
DRCe2befde2010-10-17 07:28:08 +0000437
438install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
439 ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
440 ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)