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 8if(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() 16endif() 17 18foreach(src ${JPEG_SOURCES}) 19 set(JPEG_SRCS ${JPEG_SRCS} ${CMAKE_SOURCE_DIR}/${src}) 20endforeach() 21 22if(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) 25endif() 26 27if(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) 30else() 31 add_library(jpeg SHARED ${JPEG_SRCS} ${SIMD_OBJS} 32 ${CMAKE_SOURCE_DIR}/win/jpeg${DLL_VERSION}.def) 33endif() 34set_target_properties(jpeg PROPERTIES SOVERSION ${DLL_VERSION} 35 VERSION ${FULLVERSION}) 36if(MSVC) 37 set_target_properties(jpeg PROPERTIES SUFFIX ${DLL_VERSION}.dll) 38elseif(MINGW OR CYGWIN) 39 set_target_properties(jpeg PROPERTIES SUFFIX -${DLL_VERSION}.dll) 40endif(MSVC) 41if(WITH_SIMD) 42 add_dependencies(jpeg simd) 43endif() 44 45if(WITH_12BIT) 46 set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED -DUSE_SETMODE") 47else() 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) 51endif() 52 53add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c 54 ../rdswitch.c ${CJPEG_BMP_SOURCES}) 55set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) 56target_link_libraries(cjpeg jpeg) 57 58add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c 59 ../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES}) 60set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) 61target_link_libraries(djpeg jpeg) 62 63add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c) 64target_link_libraries(jpegtran jpeg) 65set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "-DUSE_SETMODE") 66 67add_executable(jcstest ../jcstest.c) 68target_link_libraries(jcstest jpeg) 69 70install(TARGETS jpeg cjpeg djpeg jpegtran 71 ARCHIVE DESTINATION lib 72 LIBRARY DESTINATION lib 73 RUNTIME DESTINATION bin) 74