DRC | 180c016 | 2010-10-27 07:20:27 +0000 | [diff] [blame] | 1 | # |
| 2 | # Setup |
| 3 | # |
| 4 | |
| 5 | cmake_minimum_required(VERSION 2.6) |
| 6 | |
| 7 | project(libjpeg-turbo) |
| 8 | set(VERSION 1.0.90) |
| 9 | |
| 10 | if(NOT DEFINED WITH_SIMD) |
| 11 | set(WITH_SIMD 1) |
| 12 | endif() |
| 13 | |
| 14 | # Detect whether compiler is 64-bit |
| 15 | if(MSVC AND CMAKE_CL_64) |
| 16 | set(SIMD_X86_64 1) |
| 17 | set(64BIT 1) |
| 18 | elseif(CMAKE_SIZEOF_VOID_P MATCHES 8) |
| 19 | set(SIMD_X86_64 1) |
| 20 | set(64BIT 1) |
| 21 | endif() |
| 22 | |
| 23 | if(64BIT) |
| 24 | message(STATUS "64-bit build") |
| 25 | else() |
| 26 | message(STATUS "32-bit build") |
| 27 | endif() |
| 28 | |
| 29 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/win) |
| 30 | |
| 31 | |
| 32 | # |
| 33 | # Targets |
| 34 | # |
| 35 | |
| 36 | set(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 | |
| 44 | if(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) |
| 54 | else() |
| 55 | set(JPEG_SOURCES ${JPEG_SOURCES} jsimd_none.c) |
| 56 | message(STATUS "Not using SIMD acceleration") |
| 57 | endif() |
| 58 | |
| 59 | add_library(jpeg STATIC ${JPEG_SOURCES} ${SIMD_OBJS}) |
| 60 | if(WITH_SIMD) |
| 61 | add_dependencies(jpeg simd) |
| 62 | endif() |
| 63 | |
| 64 | add_executable(jpegut jpegut.c turbojpegl.c) |
| 65 | target_link_libraries(jpegut jpeg) |
| 66 | |
| 67 | add_executable(jpgtest jpgtest.cxx bmp.c turbojpegl.c) |
| 68 | target_link_libraries(jpgtest jpeg) |
| 69 | |
| 70 | add_executable(cjpeg cjpeg.c cdjpeg.c rdbmp.c rdgif.c rdppm.c rdswitch.c |
| 71 | rdtarga.c) |
| 72 | set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS |
| 73 | "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED") |
| 74 | target_link_libraries(cjpeg jpeg) |
| 75 | |
| 76 | add_executable(djpeg djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrbmp.c wrgif.c |
| 77 | wrppm.c wrtarga.c) |
| 78 | set_property(TARGET djpeg PROPERTY COMPILE_FLAGS |
| 79 | "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED") |
| 80 | target_link_libraries(djpeg jpeg) |
| 81 | |
| 82 | add_executable(jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c) |
| 83 | target_link_libraries(jpegtran jpeg) |
| 84 | |
| 85 | |
| 86 | # |
| 87 | # Tests |
| 88 | # |
| 89 | |
| 90 | enable_testing() |
| 91 | add_test(jpegut jpegut) |
| 92 | add_test(cjpeg-int cjpeg -dct int -outfile testoutint.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm) |
| 93 | add_test(cjpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutint.jpg) |
| 94 | add_test(cjpeg-fast cjpeg -dct fast -opt -outfile testoutfst.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm) |
| 95 | add_test(cjpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.jpg testoutfst.jpg) |
| 96 | add_test(cjpeg-float cjpeg -dct float -outfile testoutflt.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm) |
| 97 | if(WITH_SIMD) |
| 98 | add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.jpg testoutflt.jpg) |
| 99 | else() |
| 100 | add_test(cjpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt-nosimd.jpg testoutflt.jpg) |
| 101 | endif() |
| 102 | add_test(djpeg-int djpeg -dct int -fast -ppm -outfile testoutint.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg) |
| 103 | add_test(djpeg-int-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.ppm testoutint.ppm) |
| 104 | add_test(djpeg-fast djpeg -dct fast -ppm -outfile testoutfst.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg) |
| 105 | add_test(djpeg-fast-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgfst.ppm testoutfst.ppm) |
| 106 | add_test(djpeg-float djpeg -dct float -ppm -outfile testoutflt.ppm ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg) |
| 107 | if(WITH_SIMD) |
| 108 | add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgflt.ppm testoutflt.ppm) |
| 109 | else() |
| 110 | add_test(djpeg-float-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm testoutflt.ppm) |
| 111 | endif() |
| 112 | add_test(djpeg-256 djpeg -dct int -bmp -colors 256 -outfile testout.bmp ${CMAKE_CURRENT_SOURCE_DIR}/testorig.jpg) |
| 113 | add_test(djpeg-256-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimg.bmp testout.bmp) |
| 114 | add_test(cjpeg-prog cjpeg -dct int -progressive -outfile testoutp.jpg ${CMAKE_CURRENT_SOURCE_DIR}/testorig.ppm) |
| 115 | add_test(cjpeg-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgp.jpg testoutp.jpg) |
| 116 | add_test(jpegtran-prog jpegtran -outfile testoutt.jpg testoutp.jpg) |
| 117 | add_test(jpegtran-prog-cmp ${CMAKE_COMMAND} -E compare_files ${CMAKE_CURRENT_SOURCE_DIR}/testimgint.jpg testoutt.jpg) |