Bind macro definitions to the zint library target

The libpng dependency is exported to consumers, while the ZINT_TEST option
affects the build output. Both are therefore marked public
This commit is contained in:
Schaich 2021-03-22 19:33:05 +09:00
parent 3b7bdcaf90
commit 83bac8c8a5
2 changed files with 7 additions and 9 deletions

View file

@ -63,10 +63,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
endif() endif()
endif() endif()
if(ZINT_TEST)
add_definitions("-DZINT_TEST")
endif()
IF(APPLE) IF(APPLE)
IF (UNIVERSAL) # TODO: make universal binary IF (UNIVERSAL) # TODO: make universal binary
IF(NOT ZINT_HAS_BEEN_RUN_BEFORE) IF(NOT ZINT_HAS_BEEN_RUN_BEFORE)

View file

@ -14,10 +14,6 @@ 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_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}) set(zint_SRCS ${zint_OUTPUT_SRCS} ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS})
if(NOT PNG_FOUND)
add_definitions(-DNO_PNG)
endif()
add_library(zint SHARED ${zint_SRCS}) add_library(zint SHARED ${zint_SRCS})
if(ZINT_STATIC) if(ZINT_STATIC)
@ -29,6 +25,12 @@ set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_
if(PNG_FOUND) if(PNG_FOUND)
target_link_libraries(zint PNG::PNG) target_link_libraries(zint PNG::PNG)
else()
target_compile_definitions(zint PUBLIC NO_PNG)
endif()
if(ZINT_TEST)
target_compile_definitions(zint PUBLIC ZINT_TEST)
endif() endif()
if(NOT MSVC) if(NOT MSVC)
@ -39,7 +41,7 @@ endif()
if(MSVC) if(MSVC)
# "BUILD_SHARED_LIBS" is a CMake defined variable, see documentation. # "BUILD_SHARED_LIBS" is a CMake defined variable, see documentation.
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
add_definitions("-DDLL_EXPORT") target_compile_definitions(zint PRIVATE DLL_EXPORT)
endif() endif()
endif() endif()