From 9ff3f13c19a7c35f2cb92122d6a566296d5c4e0f Mon Sep 17 00:00:00 2001 From: Schaich Date: Mon, 29 Mar 2021 23:35:57 +0900 Subject: [PATCH] Optionalize the PNG and the Qt dependencies Expose the ability to turn these dependencies off, which results in reduced functionality. However, it enables a developer using the zint library to instruct cmake to build a libzint as deployed by e.g. build servers which don't have png/zint installed, without having to uninstall those libraries from the development system --- CMakeLists.txt | 6 +++++- backend/CMakeLists.txt | 8 +++++--- backend/tests/CMakeLists.txt | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0291c4a..ed64f0cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,8 @@ option(ZINT_DEBUG "Set debug compile flag" OFF) option(ZINT_SANITIZE "Set sanitize compile/link flags" OFF) option(ZINT_TEST "Set test compile flag" OFF) option(ZINT_STATIC "Build static library" OFF) +option(ZINT_USE_PNG "Build with PNG support" ON) +option(ZINT_USE_QT "Build with QT support" ON) include(SetPaths.cmake) @@ -90,7 +92,9 @@ ENDIF(APPLE) add_subdirectory(backend) add_subdirectory(frontend) -if($ENV{CMAKE_PREFIX_PATH} MATCHES "6[.][0-9][.][0-9]") +if(NOT ZINT_USE_QT) + message(STATUS "Qt support was disabled for this build") +elseif($ENV{CMAKE_PREFIX_PATH} MATCHES "6[.][0-9][.][0-9]") set(USE_QT6 TRUE) message(STATUS "Using Qt6") cmake_policy(SET CMP0012 NEW) # Recognize constants in if() diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index 7db775aa..7bb3a7dc 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -5,8 +5,6 @@ project(zint) configure_file(zintconfig.h.in ../../backend/zintconfig.h) -find_package(PNG) - set(zint_COMMON_SRCS common.c library.c large.c reedsol.c gs1.c eci.c general_field.c sjis.c gb2312.c gb18030.c) set(zint_ONEDIM_SRCS code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c) set(zint_POSTAL_SRCS postal.c auspost.c imail.c mailmark.c) @@ -37,7 +35,11 @@ endfunction() set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}" VERSION ${ZINT_VERSION}) -if(PNG_FOUND) +if(ZINT_USE_PNG) + find_package(PNG) +endif() + +if(ZINT_USE_PNG AND PNG_FOUND) zint_target_link_libraries(PNG::PNG) else() zint_target_compile_definitions(PUBLIC NO_PNG) diff --git a/backend/tests/CMakeLists.txt b/backend/tests/CMakeLists.txt index 2c975a8e..8151c993 100644 --- a/backend/tests/CMakeLists.txt +++ b/backend/tests/CMakeLists.txt @@ -81,7 +81,7 @@ zint_add_test(medical test_medical) zint_add_test(pcx test_pcx) zint_add_test(pdf417 test_pdf417) zint_add_test(plessey test_plessey) -if(PNG_FOUND) +if(ZINT_USE_PNG AND PNG_FOUND) zint_add_test(png test_png) endif() zint_add_test(postal test_postal)