diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ find_package(QRencode) set_package_properties(QRencode PROPERTIES TYPE REQUIRED) find_package(Dmtx) -set_package_properties(Dmtx PROPERTIES TYPE REQUIRED) +set_package_properties(Dmtx PROPERTIES TYPE RECOMMENDED) if (Qt5_POSITION_INDEPENDENT_CODE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,16 +1,22 @@ include(CMakePackageConfigHelpers) +if(TARGET Dmtx::Dmtx) + set(HAVE_DMTX 1) +endif() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-prison.h.in ${CMAKE_CURRENT_BINARY_DIR}/config-prison.h) set(prison_SRCS abstractbarcode.cpp aztecbarcode.cpp bitvector.cpp code39barcode.cpp code93barcode.cpp - datamatrixbarcode.cpp qrcodebarcode.cpp prison.cpp reedsolomon.cpp ) +if(TARGET Dmtx::Dmtx) + list(APPEND prison_SRCS datamatrixbarcode.cpp) +endif() ecm_qt_declare_logging_category(prison_SRCS HEADER prison_debug.h IDENTIFIER Prison::Log CATEGORY_NAME kf5.prison) add_library(KF5Prison ${prison_SRCS}) @@ -26,9 +32,11 @@ PUBLIC Qt5::Gui PRIVATE - Dmtx::Dmtx QRencode::QRencode ) +if(TARGET Dmtx::Dmtx) + target_link_libraries(KF5Prison PRIVATE Dmtx::Dmtx) +endif() set_target_properties(KF5Prison PROPERTIES VERSION ${PRISON_VERSION_STRING} diff --git a/src/lib/prison.cpp b/src/lib/config-prison.h.in copy from src/lib/prison.cpp copy to src/lib/config-prison.h.in --- a/src/lib/prison.cpp +++ b/src/lib/config-prison.h.in @@ -1,5 +1,5 @@ /* - Copyright (c) 2010-2016 Sune Vuorela + Copyright (c) 2018 Volker Krause Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -21,33 +21,11 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#include "prison.h" -#include "aztecbarcode.h" -#include "datamatrixbarcode.h" -#include "qrcodebarcode.h" -#include "code39barcode.h" -#include "code93barcode.h" +#ifndef PRISON_CONFIG_H +#define PRISON_CONFIG_H -Prison::AbstractBarcode *Prison::createBarcode(BarcodeType type) -{ - switch(type) - { - case Prison::Null: - return nullptr; - case Prison::QRCode: - return new QRCodeBarcode; - case Prison::DataMatrix: - return new DataMatrixBarcode; - case Prison::Aztec: - return new AztecBarcode; - case Prison::Code39: - return new Code39Barcode; - case Prison::Code93: - return new Code93Barcode; - } - return nullptr; +#cmakedefine HAVE_DMTX -} +#endif diff --git a/src/lib/prison.cpp b/src/lib/prison.cpp --- a/src/lib/prison.cpp +++ b/src/lib/prison.cpp @@ -24,6 +24,7 @@ */ +#include #include "prison.h" #include "aztecbarcode.h" #include "datamatrixbarcode.h" @@ -40,7 +41,11 @@ case Prison::QRCode: return new QRCodeBarcode; case Prison::DataMatrix: +#ifdef HAVE_DMTX return new DataMatrixBarcode; +#else + return nullptr; +#endif case Prison::Aztec: return new AztecBarcode; case Prison::Code39: