mirror of
https://github.com/libjpeg-turbo/libjpeg-turbo
synced 2025-03-28 21:13:18 +00:00
Allow building only static or only shared libraries on Windows
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.4.x@1553 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
parent
3ebcc3206f
commit
665c96edaa
153
CMakeLists.txt
153
CMakeLists.txt
@ -53,6 +53,8 @@ option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions w
|
||||
option(WITH_TURBOJPEG "Include the TurboJPEG wrapper library and associated test programs" TRUE)
|
||||
option(WITH_JAVA "Build Java wrapper for the TurboJPEG library" FALSE)
|
||||
option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_SIMD=0 WITH_TURBOJPEG=0 WITH_ARITH_ENC=0 WITH_ARITH_DEC=0)" FALSE)
|
||||
option(ENABLE_STATIC "Build static libraries" TRUE)
|
||||
option(ENABLE_SHARED "Build shared libraries" TRUE)
|
||||
|
||||
if(WITH_12BIT)
|
||||
set(WITH_SIMD FALSE)
|
||||
@ -220,16 +222,21 @@ endif()
|
||||
|
||||
if(WITH_JAVA)
|
||||
add_subdirectory(java)
|
||||
set(ENABLE_SHARED TRUE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(sharedlib)
|
||||
|
||||
add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
|
||||
if(NOT MSVC)
|
||||
set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
|
||||
if(ENABLE_SHARED)
|
||||
add_subdirectory(sharedlib)
|
||||
endif()
|
||||
if(WITH_SIMD)
|
||||
add_dependencies(jpeg-static simd)
|
||||
|
||||
if(ENABLE_STATIC OR WITH_TURBOJPEG)
|
||||
add_library(jpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS})
|
||||
if(NOT MSVC)
|
||||
set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
|
||||
endif()
|
||||
if(WITH_SIMD)
|
||||
add_dependencies(jpeg-static simd)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_TURBOJPEG)
|
||||
@ -239,40 +246,44 @@ if(WITH_TURBOJPEG)
|
||||
include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
|
||||
endif()
|
||||
|
||||
add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
|
||||
set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
|
||||
if(MINGW)
|
||||
set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
|
||||
endif()
|
||||
target_link_libraries(turbojpeg jpeg-static)
|
||||
set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
|
||||
if(ENABLE_SHARED)
|
||||
add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
|
||||
set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
|
||||
if(MINGW)
|
||||
set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
|
||||
endif()
|
||||
target_link_libraries(turbojpeg jpeg-static)
|
||||
set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "")
|
||||
|
||||
add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
|
||||
turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c)
|
||||
if(NOT MSVC)
|
||||
set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
|
||||
endif()
|
||||
if(WITH_SIMD)
|
||||
add_dependencies(turbojpeg-static simd)
|
||||
add_executable(tjunittest tjunittest.c tjutil.c)
|
||||
target_link_libraries(tjunittest turbojpeg)
|
||||
|
||||
add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
|
||||
wrppm.c)
|
||||
target_link_libraries(tjbench turbojpeg jpeg-static)
|
||||
set_property(TARGET tjbench PROPERTY COMPILE_FLAGS
|
||||
"-DBMP_SUPPORTED -DPPM_SUPPORTED")
|
||||
endif()
|
||||
|
||||
add_executable(tjunittest tjunittest.c tjutil.c)
|
||||
target_link_libraries(tjunittest turbojpeg)
|
||||
if(ENABLE_STATIC)
|
||||
add_library(turbojpeg-static STATIC ${JPEG_SOURCES} ${SIMD_OBJS}
|
||||
turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c)
|
||||
if(NOT MSVC)
|
||||
set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
|
||||
endif()
|
||||
if(WITH_SIMD)
|
||||
add_dependencies(turbojpeg-static simd)
|
||||
endif()
|
||||
|
||||
add_executable(tjunittest-static tjunittest.c tjutil.c)
|
||||
target_link_libraries(tjunittest-static turbojpeg-static)
|
||||
add_executable(tjunittest-static tjunittest.c tjutil.c)
|
||||
target_link_libraries(tjunittest-static turbojpeg-static)
|
||||
|
||||
add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
|
||||
wrppm.c)
|
||||
target_link_libraries(tjbench turbojpeg jpeg-static)
|
||||
set_property(TARGET tjbench PROPERTY COMPILE_FLAGS
|
||||
"-DBMP_SUPPORTED -DPPM_SUPPORTED")
|
||||
|
||||
add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c
|
||||
wrppm.c)
|
||||
target_link_libraries(tjbench-static turbojpeg-static jpeg-static)
|
||||
set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS
|
||||
"-DBMP_SUPPORTED -DPPM_SUPPORTED")
|
||||
add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c
|
||||
wrbmp.c wrppm.c)
|
||||
target_link_libraries(tjbench-static turbojpeg-static jpeg-static)
|
||||
set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS
|
||||
"-DBMP_SUPPORTED -DPPM_SUPPORTED")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_12BIT)
|
||||
@ -283,19 +294,21 @@ else()
|
||||
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
|
||||
endif()
|
||||
|
||||
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
|
||||
${CJPEG_BMP_SOURCES})
|
||||
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
||||
target_link_libraries(cjpeg-static jpeg-static)
|
||||
if(ENABLE_STATIC)
|
||||
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
|
||||
${CJPEG_BMP_SOURCES})
|
||||
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
||||
target_link_libraries(cjpeg-static jpeg-static)
|
||||
|
||||
add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
|
||||
wrppm.c ${DJPEG_BMP_SOURCES})
|
||||
set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
||||
target_link_libraries(djpeg-static jpeg-static)
|
||||
add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
|
||||
wrppm.c ${DJPEG_BMP_SOURCES})
|
||||
set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
||||
target_link_libraries(djpeg-static jpeg-static)
|
||||
|
||||
add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
|
||||
target_link_libraries(jpegtran-static jpeg-static)
|
||||
set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
|
||||
add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
|
||||
target_link_libraries(jpegtran-static jpeg-static)
|
||||
set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE")
|
||||
endif()
|
||||
|
||||
add_executable(rdjpgcom rdjpgcom.c)
|
||||
|
||||
@ -421,7 +434,15 @@ if(WITH_JAVA)
|
||||
TJUnitTest -bi -yuv -noyuvpad)
|
||||
endif()
|
||||
|
||||
foreach(libtype shared static)
|
||||
set(TEST_LIBTYPES "")
|
||||
if(ENABLE_SHARED)
|
||||
set(TEST_LIBTYPES ${TEST_LIBTYPES} shared)
|
||||
endif()
|
||||
if(ENABLE_STATIC)
|
||||
set(TEST_LIBTYPES ${TEST_LIBTYPES} static)
|
||||
endif()
|
||||
|
||||
foreach(libtype ${TEST_LIBTYPES})
|
||||
if(libtype STREQUAL "shared")
|
||||
set(dir sharedlib/)
|
||||
else()
|
||||
@ -794,13 +815,35 @@ add_custom_target(installer
|
||||
SOURCES libjpeg-turbo.nsi)
|
||||
|
||||
if(WITH_TURBOJPEG)
|
||||
set(TURBOJPEG_TARGETS turbojpeg turbojpeg-static tjbench)
|
||||
if(ENABLE_SHARED)
|
||||
install(TARGETS turbojpeg tjbench
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
if(ENABLE_STATIC)
|
||||
install(TARGETS turbojpeg-static ARCHIVE DESTINATION lib)
|
||||
if(NOT ENABLE_SHARED)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static.exe
|
||||
DESTINATION bin RENAME tjbench.exe)
|
||||
endif()
|
||||
endif()
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)
|
||||
endif()
|
||||
install(TARGETS jpeg-static rdjpgcom wrjpgcom ${TURBOJPEG_TARGETS}
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
|
||||
if(ENABLE_STATIC)
|
||||
install(TARGETS jpeg-static ARCHIVE DESTINATION lib)
|
||||
if(NOT ENABLE_SHARED)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static.exe
|
||||
DESTINATION bin RENAME cjpeg.exe)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static.exe
|
||||
DESTINATION bin RENAME djpeg.exe)
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jpegtran-static.exe
|
||||
DESTINATION bin RENAME jpegtran.exe)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION bin)
|
||||
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
|
||||
${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt
|
||||
@ -810,4 +853,4 @@ install(FILES ${CMAKE_SOURCE_DIR}/README ${CMAKE_SOURCE_DIR}/README-turbo.txt
|
||||
|
||||
install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h
|
||||
${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h
|
||||
${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include)
|
||||
DESTINATION include)
|
||||
|
@ -47,6 +47,10 @@ used.
|
||||
iOS would produce an undefined symbol error (_putenv$UNIX2003) when attempting
|
||||
to link the library with an i386 iOS application for the iOS simulator.
|
||||
|
||||
[9] The Windows (CMake) build system now supports building only static or only
|
||||
shared libraries. This is accomplished by adding either -DENABLE_STATIC=0 or
|
||||
-DENABLE_SHARED=0 to the CMake command line.
|
||||
|
||||
|
||||
1.4.0
|
||||
=====
|
||||
|
Loading…
x
Reference in New Issue
Block a user