blob: c8850a6838e48814a3cf7457277b2911eab0577a [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)
DRC0caa0b42011-02-06 16:11:41 +00008set(VERSION 1.1.90)
DRC84697032010-10-15 03:43:24 +00009
DRC378da4d2010-10-15 19:11:11 +000010if(MINGW OR CYGWIN)
DRC84697032010-10-15 03:43:24 +000011 execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE BUILD)
12 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
13elseif(WIN32)
14 execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmakescripts/getdate.bat"
15 OUTPUT_VARIABLE BUILD)
16 string(REGEX REPLACE "\n" "" BUILD ${BUILD})
17else()
DRC378da4d2010-10-15 19:11:11 +000018 message(FATAL_ERROR "Platform not supported by this build system. Use autotools instead.")
DRC84697032010-10-15 03:43:24 +000019endif()
20
DRC2ffcb8e2011-04-04 04:56:24 +000021# This does nothing except when using MinGW. CMAKE_BUILD_TYPE has no meaning
22# in Visual Studio, and it always defaults to Debug when using NMake.
DRC84697032010-10-15 03:43:24 +000023if(NOT CMAKE_BUILD_TYPE)
24 set(CMAKE_BUILD_TYPE Release)
25endif()
26
27message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
28
29# This only works if building from the command line. There is currently no way
DRC2ffcb8e2011-04-04 04:56:24 +000030# to set a variable's value based on the build type when using Visual Studio.
DRC84697032010-10-15 03:43:24 +000031if(CMAKE_BUILD_TYPE STREQUAL "Debug")
32 set(BUILD "${BUILD}d")
33endif()
34
DRCeb2b9d62010-10-15 04:55:13 +000035message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
36
DRC84697032010-10-15 03:43:24 +000037if(NOT DEFINED WITH_SIMD)
38 set(WITH_SIMD 1)
39endif()
40
DRC245cfdf2010-11-23 17:11:06 +000041if(NOT DEFINED WITH_ARITH_ENC)
42 set(WITH_ARITH_ENC 1)
43endif()
44
45if(NOT DEFINED WITH_ARITH_DEC)
46 set(WITH_ARITH_DEC 1)
47endif()
48
49if(WITH_ARITH_ENC)
50 set(C_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000051 message(STATUS "Arithmetic encoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000052else()
DRC990e28d2011-01-04 21:40:11 +000053 message(STATUS "Arithmetic encoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000054endif()
55
56if(WITH_ARITH_DEC)
57 set(D_ARITH_CODING_SUPPORTED 1)
DRC990e28d2011-01-04 21:40:11 +000058 message(STATUS "Arithmetic decoding support enabled")
DRC245cfdf2010-11-23 17:11:06 +000059else()
DRC990e28d2011-01-04 21:40:11 +000060 message(STATUS "Arithmetic decoding support disabled")
DRC245cfdf2010-11-23 17:11:06 +000061endif()
62
DRC957d6232011-04-01 11:13:11 +000063if(NOT DEFINED WITH_JAVA)
64 set(WITH_JAVA 0)
DRC218c0c12011-02-05 06:01:18 +000065endif()
66
DRC957d6232011-04-01 11:13:11 +000067if(WITH_JAVA)
68 message(STATUS "TurboJPEG/OSS Java wrapper enabled")
DRC218c0c12011-02-05 06:01:18 +000069else()
DRC957d6232011-04-01 11:13:11 +000070 message(STATUS "TurboJPEG/OSS Java wrapper disabled")
DRC218c0c12011-02-05 06:01:18 +000071endif()
72
DRC84697032010-10-15 03:43:24 +000073set(JPEG_LIB_VERSION 62)
74set(DLL_VERSION ${JPEG_LIB_VERSION})
DRCa9d5b252010-10-15 06:42:45 +000075set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000076if(WITH_JPEG8)
77 set(JPEG_LIB_VERSION 80)
78 set(DLL_VERSION 8)
DRCa9d5b252010-10-15 06:42:45 +000079 set(FULLVERSION ${DLL_VERSION}.0.2)
DRCf38eee02011-02-18 07:00:38 +000080 message(STATUS "Emulating libjpeg v8 API/ABI")
DRC84697032010-10-15 03:43:24 +000081elseif(WITH_JPEG7)
82 set(JPEG_LIB_VERSION 70)
83 set(DLL_VERSION 7)
DRCa9d5b252010-10-15 06:42:45 +000084 set(FULLVERSION ${DLL_VERSION}.0.0)
DRC84697032010-10-15 03:43:24 +000085 message(STATUS "Emulating libjpeg v7 API/ABI")
86endif(WITH_JPEG8)
87
88if(MSVC)
89 # Use the static C library for all build types
90 foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
DRC2e4d0442011-02-08 01:18:37 +000091 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
DRC84697032010-10-15 03:43:24 +000092 if(${var} MATCHES "/MD")
93 string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
94 endif()
95 endforeach()
96
97 add_definitions(-W3 -wd4996)
98endif()
99
100# Detect whether compiler is 64-bit
101if(MSVC AND CMAKE_CL_64)
102 set(SIMD_X86_64 1)
103 set(64BIT 1)
104elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
105 set(SIMD_X86_64 1)
106 set(64BIT 1)
107endif()
108
109if(64BIT)
110 message(STATUS "64-bit build")
111else()
112 message(STATUS "32-bit build")
113endif()
114
115configure_file(win/jconfig.h.in jconfig.h)
116configure_file(win/config.h.in config.h)
117
118include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
119
DRC957d6232011-04-01 11:13:11 +0000120if(WITH_JAVA)
121 find_package(Java)
122 find_package(JNI)
DRCdb425062011-04-03 06:10:18 +0000123 if(DEFINED JAVACFLAGS)
124 message(STATUS "Java compiler flags = ${JAVACFLAGS}")
125 endif()
DRC218c0c12011-02-05 06:01:18 +0000126endif()
127
DRC84697032010-10-15 03:43:24 +0000128
129#
130# Targets
131#
132
DRC245cfdf2010-11-23 17:11:06 +0000133set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
134 jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
135 jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
136 jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
137 jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
138 jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
139 jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
140
141if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
142 set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
143endif()
144
145if(WITH_ARITH_ENC)
146 set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
147endif()
148
149if(WITH_ARITH_DEC)
150 set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
151endif()
DRC84697032010-10-15 03:43:24 +0000152
153if(WITH_SIMD)
154 add_definitions(-DWITH_SIMD)
155 add_subdirectory(simd)
156 if(SIMD_X86_64)
157 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
158 else()
159 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
160 endif()
161 # This tells CMake that the "source" files haven't been generated yet
162 set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
163else()
164 set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
DRC6f4ba612010-10-16 21:27:38 +0000165 message(STATUS "Not using SIMD acceleration")
DRC84697032010-10-15 03:43:24 +0000166endif()
167
DRC957d6232011-04-01 11:13:11 +0000168if(WITH_JAVA)
169 add_subdirectory(java)
170endif()
171
DRC84697032010-10-15 03:43:24 +0000172add_subdirectory(sharedlib)
173
174add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
DRC84697032010-10-15 03:43:24 +0000175if(NOT MSVC)
176 set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
177endif()
178if(WITH_SIMD)
179 add_dependencies(jpeg-static simd)
180endif()
181
DRCda5220a2011-03-02 02:17:30 +0000182set(TURBOJPEG_SOURCES turbojpegl.c transupp.c)
DRC957d6232011-04-01 11:13:11 +0000183if(WITH_JAVA)
DRC218c0c12011-02-05 06:01:18 +0000184 set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
DRC957d6232011-04-01 11:13:11 +0000185 include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
DRC218c0c12011-02-05 06:01:18 +0000186endif()
187
188add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
DRC84697032010-10-15 03:43:24 +0000189set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
DRC389c4722011-02-06 18:48:13 +0000190if(MINGW)
191 set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
192endif()
DRC84697032010-10-15 03:43:24 +0000193target_link_libraries(turbojpeg jpeg-static)
194set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
195
196add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
DRCda5220a2011-03-02 02:17:30 +0000197 turbojpegl.c transupp.c)
DRC84697032010-10-15 03:43:24 +0000198if(NOT MSVC)
199 set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
200endif()
201if(WITH_SIMD)
202 add_dependencies(turbojpeg-static simd)
203endif()
204
205add_executable(jpegut jpegut.c)
206target_link_libraries(jpegut turbojpeg)
207
208add_executable(jpegut-static jpegut.c)
209target_link_libraries(jpegut-static turbojpeg-static)
210
DRC2e4d0442011-02-08 01:18:37 +0000211add_executable(jpgtest jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000212target_link_libraries(jpgtest turbojpeg)
213
DRC2e4d0442011-02-08 01:18:37 +0000214add_executable(jpgtest-static jpgtest.c bmp.c)
DRC84697032010-10-15 03:43:24 +0000215target_link_libraries(jpgtest-static turbojpeg-static)
216
217add_executable(cjpeg-static cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
218 rdtarga.c)
219set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS
220 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
221target_link_libraries(cjpeg-static jpeg-static)
222
223add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
224 wrppm.c wrtarga.c)
225set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS
226 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
227target_link_libraries(djpeg-static jpeg-static)
228
229add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
230target_link_libraries(jpegtran-static jpeg-static)
231
232add_executable(rdjpgcom rdjpgcom.c)
233
234add_executable(wrjpgcom rdjpgcom.c)
235
236
237#
238# Tests
239#
240
DRC957d6232011-04-01 11:13:11 +0000241if(MSVC_IDE)
242 set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
243else()
244 set(OBJDIR "")
245endif()
246
DRC84697032010-10-15 03:43:24 +0000247enable_testing()
DRC957d6232011-04-01 11:13:11 +0000248if(WITH_JAVA)
249add_test(TJUnitTest ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest)
250add_test(TJUnitTest-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -yuv)
251add_test(TJUnitTest-bi ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi)
252add_test(TJUnitTest-bi-yuv ${JAVA_RUNTIME} -cp java/${OBJDIR}turbojpeg.jar -Djava.library.path=${CMAKE_CURRENT_BINARY_DIR}/${OBJDIR} TJUnitTest -bi -yuv)
253endif()
DRC84697032010-10-15 03:43:24 +0000254add_test(jpegut jpegut)
DRCfbb67472010-11-24 04:02:37 +0000255add_test(jpegut-yuv jpegut -yuv)
DRC84697032010-10-15 03:43:24 +0000256add_test(cjpeg-int sharedlib/cjpeg -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000257add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000258add_test(cjpeg-fast sharedlib/cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000259add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000260add_test(cjpeg-fast-100 sharedlib/cjpeg -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
261add_test(cjpeg-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000262add_test(cjpeg-float sharedlib/cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
263if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000264add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000265else()
DRCb42a48c2010-10-18 01:06:36 +0000266add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000267endif()
DRCda5220a2011-03-02 02:17:30 +0000268add_test(cjpeg-int-gray sharedlib/cjpeg -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
269add_test(cjpeg-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimggray.jpg testoutgray.jpg)
DRC84697032010-10-15 03:43:24 +0000270add_test(djpeg-int sharedlib/djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000271add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000272add_test(djpeg-fast sharedlib/djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000273add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000274add_test(djpeg-float sharedlib/djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
275if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000276add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000277else()
DRCb42a48c2010-10-18 01:06:36 +0000278add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000279endif()
280add_test(djpeg-256 sharedlib/djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000281add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000282add_test(cjpeg-prog sharedlib/cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000283add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000284add_test(jpegtran-prog sharedlib/jpegtran -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000285add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000286if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000287add_test(cjpeg-ari sharedlib/cjpeg -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
288add_test(cjpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000289add_test(jpegtran-toari sharedlib/jpegtran -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
290add_test(jpegtran-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
291endif()
292if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000293add_test(djpeg-ari sharedlib/djpeg -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
294add_test(djpeg-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000295add_test(jpegtran-fromari sharedlib/jpegtran -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000296add_test(jpegtran-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000297endif()
DRC84697032010-10-15 03:43:24 +0000298add_test(jpegtran-crop sharedlib/jpegtran -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000299add_test(jpegtran-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC84697032010-10-15 03:43:24 +0000300
301add_test(jpegut-static jpegut-static)
DRCfbb67472010-11-24 04:02:37 +0000302add_test(jpegut-static-yuv jpegut-static -yuv)
DRC84697032010-10-15 03:43:24 +0000303add_test(cjpeg-static-int cjpeg-static -dct int -outfile testoutint.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000304add_test(cjpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
DRC84697032010-10-15 03:43:24 +0000305add_test(cjpeg-static-fast cjpeg-static -dct fast -opt -outfile testoutfst.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000306add_test(cjpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
DRCc4ef01f2011-02-18 05:06:58 +0000307add_test(cjpeg-static-fast-100 cjpeg-static -dct fast -quality 100 -opt -outfile testoutfst100.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
308add_test(cjpeg-static-fast-100-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst100.jpg testoutfst100.jpg)
DRC84697032010-10-15 03:43:24 +0000309add_test(cjpeg-static-float cjpeg-static -dct float -outfile testoutflt.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
310if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000311add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000312else()
DRCb42a48c2010-10-18 01:06:36 +0000313add_test(cjpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
DRC84697032010-10-15 03:43:24 +0000314endif()
DRCda5220a2011-03-02 02:17:30 +0000315add_test(cjpeg-static-int-gray cjpeg-static -dct int -grayscale -outfile testoutgray.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
316add_test(cjpeg-static-int-gray-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimggray.jpg testoutgray.jpg)
DRC84697032010-10-15 03:43:24 +0000317add_test(djpeg-static-int djpeg-static -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000318add_test(djpeg-static-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
DRC84697032010-10-15 03:43:24 +0000319add_test(djpeg-static-fast djpeg-static -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000320add_test(djpeg-static-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
DRC84697032010-10-15 03:43:24 +0000321add_test(djpeg-static-float djpeg-static -dct float -ppm -outfile testoutflt.ppm ${CMAKE_SOURCE_DIR}/testorig.jpg)
322if(WITH_SIMD)
DRCb42a48c2010-10-18 01:06:36 +0000323add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000324else()
DRCb42a48c2010-10-18 01:06:36 +0000325add_test(djpeg-static-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
DRC84697032010-10-15 03:43:24 +0000326endif()
327add_test(djpeg-static-256 djpeg-static -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000328add_test(djpeg-static-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimg.bmp testout.bmp)
DRC84697032010-10-15 03:43:24 +0000329add_test(cjpeg-static-prog cjpeg-static -dct int -progressive -outfile testoutp.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
DRCb42a48c2010-10-18 01:06:36 +0000330add_test(cjpeg-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
DRC84697032010-10-15 03:43:24 +0000331add_test(jpegtran-static-prog jpegtran-static -outfile testoutt.jpg testoutp.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000332add_test(jpegtran-static-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testoutt.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000333if(WITH_ARITH_ENC)
DRC66f97e62010-11-23 05:49:54 +0000334add_test(cjpeg-static-ari cjpeg-static -dct int -arithmetic -outfile testoutari.jpg ${CMAKE_SOURCE_DIR}/testorig.ppm)
335add_test(cjpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testoutari.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000336add_test(jpegtran-static-toari jpegtran-static -arithmetic -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgint.jpg)
337add_test(jpegtran-static-toari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.jpg testouta.jpg)
338endif()
339if(WITH_ARITH_DEC)
DRC66f97e62010-11-23 05:49:54 +0000340add_test(djpeg-static-ari djpeg-static -dct int -fast -ppm -outfile testoutari.ppm ${CMAKE_SOURCE_DIR}/testimgari.jpg)
341add_test(djpeg-static-ari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgari.ppm testoutari.ppm)
DRC245cfdf2010-11-23 17:11:06 +0000342add_test(jpegtran-static-fromari jpegtran-static -outfile testouta.jpg ${CMAKE_SOURCE_DIR}/testimgari.jpg)
DRC66f97e62010-11-23 05:49:54 +0000343add_test(jpegtran-static-fromari-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgint.jpg testouta.jpg)
DRC245cfdf2010-11-23 17:11:06 +0000344endif()
DRC84697032010-10-15 03:43:24 +0000345add_test(jpegtran-static-crop jpegtran-static -crop 120x90+20+50 -transpose -perfect -outfile testoutcrop.jpg ${CMAKE_SOURCE_DIR}/testorig.jpg)
DRCb42a48c2010-10-18 01:06:36 +0000346add_test(jpegtran-static-crop-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_SOURCE_DIR}/testimgcrop.jpg testoutcrop.jpg)
DRC2c0a4e12010-10-16 08:51:43 +0000347
DRCa0f878a2011-04-02 04:43:14 +0000348add_custom_target(testclean COMMAND ${CMAKE_COMMAND} -P
349 ${CMAKE_SOURCE_DIR}/cmakescripts/testclean.cmake)
350
DRC2c0a4e12010-10-16 08:51:43 +0000351
352#
353# Installer
354#
355
DRC2c0a4e12010-10-16 08:51:43 +0000356if(MSVC)
357 set(INST_PLATFORM "Visual C++")
DRCb94f2de2011-03-22 09:31:25 +0000358 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-vc)
359 set(INST_DIR ${CMAKE_PROJECT_NAME})
DRC2c0a4e12010-10-16 08:51:43 +0000360elseif(MINGW)
361 set(INST_PLATFORM GCC)
DRCb94f2de2011-03-22 09:31:25 +0000362 set(INST_NAME ${CMAKE_PROJECT_NAME}-${VERSION}-gcc)
363 set(INST_DIR ${CMAKE_PROJECT_NAME}-gcc)
DRC2c0a4e12010-10-16 08:51:43 +0000364 set(INST_DEFS -DGCC)
365endif()
366
367if(64BIT)
368 set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
369 set(INST_NAME ${INST_NAME}64)
DRCb94f2de2011-03-22 09:31:25 +0000370 set(INST_DIR ${INST_DIR}64)
DRC2c0a4e12010-10-16 08:51:43 +0000371 set(INST_DEFS ${INST_DEFS} -DWIN64)
372endif()
373
DRC957d6232011-04-01 11:13:11 +0000374if(WITH_JAVA)
375 set(INST_DEFS ${INST_DEFS} -DJAVA)
376endif()
377
DRC2c0a4e12010-10-16 08:51:43 +0000378if(MSVC_IDE)
DRC926e01f2011-04-06 06:35:38 +0000379 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=${CMAKE_CFG_INTDIR}\\")
DRC2c0a4e12010-10-16 08:51:43 +0000380else()
381 set(INST_DEFS ${INST_DEFS} "-DBUILDDIR=")
382endif()
383
384configure_file(release/libjpeg-turbo.nsi.in libjpeg-turbo.nsi @ONLY)
385
386add_custom_target(installer
387 makensis -nocd ${INST_DEFS} libjpeg-turbo.nsi
DRCb94f2de2011-03-22 09:31:25 +0000388 DEPENDS jpeg jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom
389 cjpeg djpeg jpegtran jpgtest
DRC2c0a4e12010-10-16 08:51:43 +0000390 SOURCES libjpeg-turbo.nsi)
DRC7284c9a2010-10-16 21:55:14 +0000391
DRC8569c2f2011-02-18 23:49:42 +0000392install(TARGETS jpeg-static turbojpeg turbojpeg-static rdjpgcom wrjpgcom jpgtest
DRC7284c9a2010-10-16 21:55:14 +0000393 ARCHIVE DESTINATION lib
394 LIBRARY DESTINATION lib
395 RUNTIME DESTINATION bin
396)
397
398install(FILES ${CMAKE_SOURCE_DIR}/LGPL.txt ${CMAKE_SOURCE_DIR}/LICENSE.txt
399 ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
400 ${CMAKE_SOURCE_DIR}/libjpeg.txt ${CMAKE_SOURCE_DIR}/usage.txt
401 DESTINATION doc)
DRCe2befde2010-10-17 07:28:08 +0000402
403install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
404 ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
405 ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)