mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-24 20:14:28 -04:00
Add ZINT_SHARED CMake option
Either shared or static (or both) libraries can be built now. Executables (zint and zint-qt) are linked with the static library if the shared library it not built.
This commit is contained in:
parent
2f8681b21a
commit
66431d8ec1
8 changed files with 53 additions and 18 deletions
|
@ -13,32 +13,45 @@ set(zint_TWODIM_SRCS code16k.c codablock.c dmatrix.c pdf417.c qr.c maxicode.c co
|
|||
set(zint_OUTPUT_SRCS vector.c ps.c svg.c emf.c bmp.c pcx.c gif.c png.c tif.c raster.c output.c)
|
||||
set(zint_SRCS ${zint_OUTPUT_SRCS} ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS})
|
||||
|
||||
add_library(zint SHARED ${zint_SRCS})
|
||||
if(ZINT_SHARED)
|
||||
add_library(zint SHARED ${zint_SRCS})
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${PROJECT_NAME} PRIVATE libzint.rc)
|
||||
if(WIN32)
|
||||
target_sources(${PROJECT_NAME} PRIVATE libzint.rc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ZINT_STATIC)
|
||||
add_library(zint-static STATIC ${zint_SRCS})
|
||||
if(WIN32)
|
||||
set_target_properties(zint-static PROPERTIES OUTPUT_NAME zint-static)
|
||||
else()
|
||||
set_target_properties(zint-static PROPERTIES OUTPUT_NAME zint)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(zint_target_link_libraries library)
|
||||
target_link_libraries(zint ${library})
|
||||
if(ZINT_SHARED)
|
||||
target_link_libraries(zint ${library})
|
||||
endif()
|
||||
if(ZINT_STATIC)
|
||||
target_link_libraries(zint-static ${library})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(zint_target_compile_definitions scope definition)
|
||||
target_compile_definitions(zint ${scope} ${definition})
|
||||
if(ZINT_SHARED)
|
||||
target_compile_definitions(zint ${scope} ${definition})
|
||||
endif()
|
||||
if(ZINT_STATIC)
|
||||
target_compile_definitions(zint-static ${scope} ${definition})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
|
||||
VERSION ${ZINT_VERSION})
|
||||
if(ZINT_SHARED)
|
||||
set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
|
||||
VERSION ${ZINT_VERSION})
|
||||
endif()
|
||||
|
||||
if(ZINT_USE_PNG)
|
||||
find_package(PNG)
|
||||
|
@ -63,7 +76,9 @@ if(MSVC)
|
|||
target_compile_definitions(zint PRIVATE DLL_EXPORT)
|
||||
endif()
|
||||
|
||||
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
if(ZINT_SHARED)
|
||||
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
endif()
|
||||
if(ZINT_STATIC)
|
||||
install(TARGETS zint-static ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
endif()
|
||||
|
|
|
@ -21,9 +21,11 @@ endif()
|
|||
|
||||
set(testcommon_SRCS testcommon.c testcommon.h)
|
||||
|
||||
add_library(testcommon ${testcommon_SRCS})
|
||||
target_link_libraries(testcommon zint)
|
||||
target_include_directories(testcommon PUBLIC ${zint_backend_tests_SOURCE_DIR})
|
||||
if(ZINT_SHARED)
|
||||
add_library(testcommon ${testcommon_SRCS})
|
||||
target_link_libraries(testcommon zint)
|
||||
target_include_directories(testcommon PUBLIC ${zint_backend_tests_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if(ZINT_STATIC)
|
||||
add_library(testcommon-static ${testcommon_SRCS})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue