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 11 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) 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 27 if(WITH_MEM_SRCDST AND NOT WITH_JPEG8) 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() 34 set_target_properties(jpeg PROPERTIES SOVERSION ${DLL_VERSION} 35 VERSION ${FULLVERSION}) 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 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}) 56 target_link_libraries(cjpeg jpeg) 57 58 add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c 59 ../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES}) 60 set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) 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) 65 set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "-DUSE_SETMODE") 66 67 add_executable(jcstest ../jcstest.c) 68 target_link_libraries(jcstest jpeg) 69 70 install(TARGETS jpeg cjpeg djpeg jpegtran 71 ARCHIVE DESTINATION lib 72 LIBRARY DESTINATION lib 73 RUNTIME DESTINATION bin) 74