blob: cd867e72d9dea8ea271c4769f3a3ee8af7ed9e6b [file] [log] [blame]
DRC180c0162010-10-27 07:20:27 +00001#
2# Setup
3#
4
5cmake_minimum_required(VERSION 2.6)
6
7project(libjpeg-turbo)
8set(VERSION 1.0.90)
9
10if(NOT DEFINED WITH_SIMD)
11 set(WITH_SIMD 1)
12endif()
13
14# Detect whether compiler is 64-bit
15if(MSVC AND CMAKE_CL_64)
16 set(SIMD_X86_64 1)
17 set(64BIT 1)
18elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
19 set(SIMD_X86_64 1)
20 set(64BIT 1)
21endif()
22
23if(64BIT)
24 message(STATUS "64-bit build")
25else()
26 message(STATUS "32-bit build")
27endif()
28
29include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/win)
30
31
32#
33# Targets
34#
35
36set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
37 jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c jcphuff.c
38 jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c jdatasrc.c
39 jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c
40 jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c jdtrans.c jerror.c
41 jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c
42 jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
43
44if(WITH_SIMD)
45 add_definitions(-DWITH_SIMD)
46 add_subdirectory(simd)
47 if(SIMD_X86_64)
48 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_x86_64.c)
49 else()
50 set(JPEG_SOURCES ${JPEG_SOURCES} simd/jsimd_i386.c)
51 endif()
52 # This tells CMake that the "source" files haven't been generated yet
53 set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
54else()
55 set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c)
56 message(STATUS "Not using SIMD acceleration")
57endif()
58
59add_library(jpeg STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
60if(WITH_SIMD)
61 add_dependencies(jpeg simd)
62endif()
63
64add_executable(jpegut jpegut.c turbojpegl.c)
65target_link_libraries(jpegut jpeg)
66
67add_executable(jpgtest jpgtest.cxx bmp.c turbojpegl.c)
68target_link_libraries(jpgtest jpeg)
69
70add_executable(cjpeg cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c
71 rdtarga.c)
72set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS
73 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
74target_link_libraries(cjpeg jpeg)
75
76add_executable(djpeg djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c
77 wrppm.c wrtarga.c)
78set_property(TARGET djpeg PROPERTY COMPILE_FLAGS
79 "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED")
80target_link_libraries(djpeg jpeg)
81
82add_executable(jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c)
83target_link_libraries(jpegtran jpeg)
84
85
86#
87# Tests
88#
89
90enable_testing()
91add_test(jpegut jpegut)
92add_test(cjpeg-int cjpeg -dct int -outfile testoutint.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
93add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutint.jpg)
94add_test(cjpeg-fast cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
95add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg)
96add_test(cjpeg-float cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
97if(WITH_SIMD)
98add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg)
99else()
100add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg)
101endif()
102add_test(djpeg-int djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
103add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.ppm testoutint.ppm)
104add_test(djpeg-fast djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
105add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm)
106add_test(djpeg-float djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
107if(WITH_SIMD)
108add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm)
109else()
110add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm testoutflt.ppm)
111endif()
112add_test(djpeg-256 djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg)
113add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimg.bmp testout.bmp)
114add_test(cjpeg-prog cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm)
115add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgp.jpg testoutp.jpg)
116add_test(jpegtran-prog jpegtran -outfile testoutt.jpg testoutp.jpg)
117add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutt.jpg)