|
shun-iwasawa |
82a8f5 |
# Anything that must be linked against the shared C library on Windows must
|
|
shun-iwasawa |
82a8f5 |
# be built in this subdirectory, because CMake doesn't allow us to override
|
|
shun-iwasawa |
82a8f5 |
# the compiler flags for each build type except at directory scope. Note
|
|
shun-iwasawa |
82a8f5 |
# to CMake developers: Add a COMPILE_FLAGS_<config> target property, or</config>
|
|
shun-iwasawa |
82a8f5 |
# better yet, provide a friendly way of configuring a Windows target to use the
|
|
shun-iwasawa |
82a8f5 |
# static C library.
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
|
|
shun-iwasawa |
82a8f5 |
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
|
|
shun-iwasawa |
82a8f5 |
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
if(MSVC)
|
|
shun-iwasawa |
82a8f5 |
# Build all configurations against shared C library
|
|
shun-iwasawa |
82a8f5 |
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
|
shun-iwasawa |
82a8f5 |
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
|
shun-iwasawa |
82a8f5 |
if(${var} MATCHES "/MT")
|
|
shun-iwasawa |
82a8f5 |
string(REGEX REPLACE "/MT" "/MD" ${var} "${${var}}")
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
endforeach()
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
foreach(src ${JPEG_SOURCES})
|
|
shun-iwasawa |
82a8f5 |
set(JPEG_SRCS ${JPEG_SRCS} ../${src})
|
|
shun-iwasawa |
82a8f5 |
endforeach()
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
if(WITH_SIMD AND (MSVC_IDE OR XCODE))
|
|
shun-iwasawa |
82a8f5 |
# This tells CMake that the "source" files haven't been generated yet
|
|
shun-iwasawa |
82a8f5 |
set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
if(WIN32)
|
|
shun-iwasawa |
82a8f5 |
if(WITH_MEM_SRCDST)
|
|
shun-iwasawa |
82a8f5 |
set(DEFFILE ../win/jpeg${SO_MAJOR_VERSION}-memsrcdst.def)
|
|
shun-iwasawa |
82a8f5 |
else()
|
|
shun-iwasawa |
82a8f5 |
set(DEFFILE ../win/jpeg${SO_MAJOR_VERSION}.def)
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
add_library(jpeg SHARED ${JPEG_SRCS} ${DEFFILE} $<target_objects:simd></target_objects:simd>
|
|
shun-iwasawa |
82a8f5 |
${SIMD_OBJS})
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
set_target_properties(jpeg PROPERTIES SOVERSION ${SO_MAJOR_VERSION}
|
|
shun-iwasawa |
82a8f5 |
VERSION ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION})
|
|
shun-iwasawa |
82a8f5 |
if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR
|
|
shun-iwasawa |
82a8f5 |
CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4))
|
|
shun-iwasawa |
82a8f5 |
if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
|
|
shun-iwasawa |
82a8f5 |
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
set_target_properties(jpeg PROPERTIES MACOSX_RPATH 1)
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
if(MAPFLAG)
|
|
shun-iwasawa |
82a8f5 |
set_target_properties(jpeg PROPERTIES
|
|
shun-iwasawa |
82a8f5 |
LINK_FLAGS "${MAPFLAG}${CMAKE_CURRENT_BINARY_DIR}/../libjpeg.map")
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
if(MSVC)
|
|
shun-iwasawa |
82a8f5 |
set_target_properties(jpeg PROPERTIES
|
|
shun-iwasawa |
82a8f5 |
RUNTIME_OUTPUT_NAME jpeg${SO_MAJOR_VERSION})
|
|
shun-iwasawa |
82a8f5 |
# The jsimd_*.c file is built using /MT, so this prevents a linker warning.
|
|
shun-iwasawa |
82a8f5 |
set_target_properties(jpeg PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT /NODEFAULTLIB:LIBCMTD")
|
|
shun-iwasawa |
82a8f5 |
elseif(MINGW)
|
|
shun-iwasawa |
82a8f5 |
set_target_properties(jpeg PROPERTIES SUFFIX -${SO_MAJOR_VERSION}.dll)
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
if(WIN32)
|
|
shun-iwasawa |
82a8f5 |
set(USE_SETMODE "-DUSE_SETMODE")
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
if(WITH_12BIT)
|
|
shun-iwasawa |
82a8f5 |
set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}")
|
|
shun-iwasawa |
82a8f5 |
else()
|
|
shun-iwasawa |
82a8f5 |
set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
|
|
shun-iwasawa |
82a8f5 |
set(CJPEG_BMP_SOURCES ../rdbmp.c ../rdtarga.c)
|
|
shun-iwasawa |
82a8f5 |
set(DJPEG_BMP_SOURCES ../wrbmp.c ../wrtarga.c)
|
|
shun-iwasawa |
82a8f5 |
endif()
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c
|
|
shun-iwasawa |
82a8f5 |
../rdswitch.c ${CJPEG_BMP_SOURCES})
|
|
shun-iwasawa |
82a8f5 |
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
|
shun-iwasawa |
82a8f5 |
target_link_libraries(cjpeg jpeg)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c
|
|
shun-iwasawa |
82a8f5 |
../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES})
|
|
shun-iwasawa |
82a8f5 |
set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
|
shun-iwasawa |
82a8f5 |
target_link_libraries(djpeg jpeg)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c)
|
|
shun-iwasawa |
82a8f5 |
target_link_libraries(jpegtran jpeg)
|
|
shun-iwasawa |
82a8f5 |
set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "${USE_SETMODE}")
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
add_executable(jcstest ../jcstest.c)
|
|
shun-iwasawa |
82a8f5 |
target_link_libraries(jcstest jpeg)
|
|
shun-iwasawa |
82a8f5 |
|
|
shun-iwasawa |
82a8f5 |
install(TARGETS jpeg cjpeg djpeg jpegtran
|
|
shun-iwasawa |
82a8f5 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
shun-iwasawa |
82a8f5 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
shun-iwasawa |
82a8f5 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
shun-iwasawa |
82a8f5 |
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
|
|
shun-iwasawa |
82a8f5 |
CMAKE_C_LINKER_SUPPORTS_PDB)
|
|
shun-iwasawa |
82a8f5 |
install(FILES "$<target_pdb_file:jpeg>"</target_pdb_file:jpeg>
|
|
shun-iwasawa |
82a8f5 |
DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
|
|
shun-iwasawa |
82a8f5 |
endif()
|