diff --git a/CMakeLists.txt b/CMakeLists.txt index daa1ac6..32b2b3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,93 +1,93 @@ cmake_minimum_required(VERSION 3.0) set(KF5_VERSION "5.43.0") # handled by release scripts project(prison VERSION ${KF5_VERSION}) # ECM setup include(FeatureSummary) find_package(ECM 5.43.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${ECM_MODULE_PATH}") cmake_policy(SET CMP0063 NEW) include(GenerateExportHeader) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(ECMAddQch) include(ECMAddTests) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(ECMQtDeclareLoggingCategory) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") set(REQUIRED_QT_VERSION 5.7.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG OPTIONAL_COMPONENTS Quick) 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) endif() ecm_setup_version(PROJECT VARIABLE_PREFIX PRISON VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/prison_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PrisonConfigVersion.cmake" SOVERSION 5 ) add_subdirectory(src) if(BUILD_TESTING) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test Widgets) add_subdirectory(autotests) add_subdirectory(tests) endif() set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5Prison") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5Prison_QCH FILE KF5PrisonQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5PrisonQchTargets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PrisonConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PrisonConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PrisonConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PrisonConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5PrisonTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5PrisonTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/prison_version.h DESTINATION ${KF5_INCLUDE_INSTALL_DIR} COMPONENT Devel ) # contains list of debug categories, for kdebugsettings install(FILES prison.categories DESTINATION ${KDE_INSTALL_CONFDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index d6a460d..9fddb7d 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,84 +1,92 @@ 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}) generate_export_header(KF5Prison BASE_NAME Prison) add_library(KF5::Prison ALIAS KF5Prison) target_include_directories(KF5Prison INTERFACE "$") target_include_directories(KF5Prison PUBLIC "$") target_link_libraries(KF5Prison 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} SOVERSION ${PRISON_SOVERSION} EXPORT_NAME Prison ) install(TARGETS KF5Prison EXPORT KF5PrisonTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) ecm_generate_headers(Prison_CamelCase_HEADERS HEADER_NAMES AbstractBarcode Prison PREFIX PRISON REQUIRED_HEADERS Prison_HEADERS ) install(FILES ${Prison_CamelCase_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/prison COMPONENT Devel) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/prison_export.h ${Prison_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/prison COMPONENT Devel ) if(BUILD_QCH) ecm_add_qch( KF5Prison_QCH NAME Prison BASE_NAME KF5Prison VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${Prison_HEADERS} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS Qt5Gui_QCH BLANK_MACROS PRISON_EXPORT PRISON_DEPRECATED PRISON_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() ecm_generate_pri_file(BASE_NAME Prison LIB_NAME KF5Prison DEPS "Qt5::Gui" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/prison) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) diff --git a/src/lib/prison.cpp b/src/lib/config-prison.h.in similarity index 60% copy from src/lib/prison.cpp copy to src/lib/config-prison.h.in index 892490e..efd356b 100644 --- a/src/lib/prison.cpp +++ b/src/lib/config-prison.h.in @@ -1,53 +1,31 @@ /* - 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 files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 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 index 892490e..cf96ade 100644 --- a/src/lib/prison.cpp +++ b/src/lib/prison.cpp @@ -1,53 +1,58 @@ /* Copyright (c) 2010-2016 Sune Vuorela Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 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 #include "prison.h" #include "aztecbarcode.h" #include "datamatrixbarcode.h" #include "qrcodebarcode.h" #include "code39barcode.h" #include "code93barcode.h" Prison::AbstractBarcode *Prison::createBarcode(BarcodeType type) { switch(type) { case Prison::Null: return nullptr; 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: return new Code39Barcode; case Prison::Code93: return new Code93Barcode; } return nullptr; }