DRC | c869c2c | 2010-10-15 08:43:32 +0000 | [diff] [blame] | 1 | # Anything that must be linked against the shared C library on Windows must |
| 2 | # be built in this subdirectory, because CMake doesn't allow us to override |
| 3 | # the compiler flags for each build type except at directory scope. Note |
| 4 | # to CMake developers: Add a COMPILE_FLAGS_<CONFIG> target property, or |
| 5 | # better yet, provide a friendly way of configuring a Windows target to use the |
| 6 | # static C library. |
| 7 | |
| 8 | if(MSVC) |
| 9 | # Build all configurations against shared C library |
| 10 | foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE |
DRC | b8cc52b | 2011-02-15 03:59:11 +0000 | [diff] [blame] | 11 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) |
DRC | c869c2c | 2010-10-15 08:43:32 +0000 | [diff] [blame] | 12 | if(${var} MATCHES "/MT") |
| 13 | string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}") |
| 14 | endif() |
| 15 | endforeach() |
| 16 | endif() |
| 17 | |
| 18 | foreach(src ${JPEG_SOURCES}) |
| 19 | set(JPEG_SRCS ${JPEG_SRCS} ${CMAKE_SOURCE_DIR}/${src}) |
| 20 | endforeach() |
| 21 | |
| 22 | if(WITH_SIMD) |
| 23 | # This tells CMake that the "source" files haven't been generated yet |
| 24 | set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1) |
| 25 | endif() |
| 26 | |
DRC | 189ee81 | 2013-01-27 15:54:59 +0000 | [diff] [blame] | 27 | if(WITH_MEM_SRCDST AND NOT WITH_JPEG8) |
DRC | ab70623 | 2013-01-18 23:42:31 +0000 | [diff] [blame] | 28 | add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS} |
| 29 | ${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}-memsrcdst.def) |
| 30 | else() |
| 31 | add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS} |
| 32 | ${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}.def) |
| 33 | endif() |
DRC | a9d5b25 | 2010-10-15 06:42:45 +0000 | [diff] [blame] | 34 | set_target_properties(jpeg PROPERTIES SOVERSION ${DLL_VERSION} |
| 35 | VERSION ${FULLVERSION}) |
DRC | c869c2c | 2010-10-15 08:43:32 +0000 | [diff] [blame] | 36 | if(MSVC) |
| 37 | set_target_properties(jpeg PROPERTIES SUFFIX ${DLL_VERSION}.dll) |
| 38 | elseif(MINGW OR CYGWIN) |
| 39 | set_target_properties(jpeg PROPERTIES SUFFIX -${DLL_VERSION}.dll) |
| 40 | endif(MSVC) |
| 41 | if(WITH_SIMD) |
| 42 | add_dependencies(jpeg simd) |
| 43 | endif() |
| 44 | |
DRC | aee4f72 | 2014-08-09 23:06:07 +0000 | [diff] [blame] | 45 | if(WITH_12BIT) |
| 46 | set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED -DUSE_SETMODE") |
| 47 | else() |
| 48 | set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED -DUSE_SETMODE") |
| 49 | set(CJPEG_BMP_SOURCES ../rdbmp.c ../rdtarga.c) |
| 50 | set(DJPEG_BMP_SOURCES ../wrbmp.c ../wrtarga.c) |
| 51 | endif() |
| 52 | |
| 53 | add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c |
| 54 | ../rdswitch.c ${CJPEG_BMP_SOURCES}) |
| 55 | set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) |
DRC | c869c2c | 2010-10-15 08:43:32 +0000 | [diff] [blame] | 56 | target_link_libraries(cjpeg jpeg) |
| 57 | |
| 58 | add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c |
DRC | aee4f72 | 2014-08-09 23:06:07 +0000 | [diff] [blame] | 59 | ../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES}) |
| 60 | set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) |
DRC | c869c2c | 2010-10-15 08:43:32 +0000 | [diff] [blame] | 61 | target_link_libraries(djpeg jpeg) |
| 62 | |
| 63 | add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c) |
| 64 | target_link_libraries(jpegtran jpeg) |
DRC | 7e3fd2f | 2011-05-25 06:04:43 +0000 | [diff] [blame] | 65 | set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "-DUSE_SETMODE") |
DRC | 7284c9a | 2010-10-16 21:55:14 +0000 | [diff] [blame] | 66 | |
DRC | b76c840 | 2011-12-19 15:01:55 +0000 | [diff] [blame] | 67 | add_executable(jcstest ../jcstest.c) |
| 68 | target_link_libraries(jcstest jpeg) |
| 69 | |
DRC | 7284c9a | 2010-10-16 21:55:14 +0000 | [diff] [blame] | 70 | install(TARGETS jpeg cjpeg djpeg jpegtran |
| 71 | ARCHIVE DESTINATION lib |
| 72 | LIBRARY DESTINATION lib |
| 73 | RUNTIME DESTINATION bin) |