From 83bac8c8a5964a3c8656806631a7b76ca9a3e9cd Mon Sep 17 00:00:00 2001 From: Schaich Date: Mon, 22 Mar 2021 19:33:05 +0900 Subject: [PATCH] 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 --- CMakeLists.txt | 4 ---- backend/CMakeLists.txt | 12 +++++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ae80c74..fda0260f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,10 +63,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) endif() endif() -if(ZINT_TEST) - add_definitions("-DZINT_TEST") -endif() - IF(APPLE) IF (UNIVERSAL) # TODO: make universal binary IF(NOT ZINT_HAS_BEEN_RUN_BEFORE) diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index 7d4a6433..304efb56 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -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_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}) if(ZINT_STATIC) @@ -29,6 +25,12 @@ set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_ if(PNG_FOUND) 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() if(NOT MSVC) @@ -39,7 +41,7 @@ endif() if(MSVC) # "BUILD_SHARED_LIBS" is a CMake defined variable, see documentation. if(BUILD_SHARED_LIBS) - add_definitions("-DDLL_EXPORT") + target_compile_definitions(zint PRIVATE DLL_EXPORT) endif() endif()