2021-06-10 22:15:39 +12:00
|
|
|
# Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
|
2024-01-18 10:55:11 +13:00
|
|
|
# Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
|
2020-10-06 11:22:06 +13:00
|
|
|
# vim: set ts=4 sw=4 et :
|
2008-09-19 02:44:52 +12:00
|
|
|
|
2021-07-27 02:29:05 +12:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2008-09-19 02:44:52 +12:00
|
|
|
project(zint-package)
|
|
|
|
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
2021-03-12 00:41:13 +13:00
|
|
|
set(ZINT_VERSION_MAJOR 2)
|
2023-12-18 22:44:47 +13:00
|
|
|
set(ZINT_VERSION_MINOR 13)
|
2022-12-13 10:06:08 +13:00
|
|
|
set(ZINT_VERSION_RELEASE 0)
|
2023-12-18 23:28:14 +13:00
|
|
|
set(ZINT_VERSION_BUILD 9) # Set to 0 before release, set to 9 after release
|
2021-03-12 00:41:13 +13:00
|
|
|
set(ZINT_VERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}.${ZINT_VERSION_RELEASE}.${ZINT_VERSION_BUILD}")
|
2008-09-19 02:44:52 +12:00
|
|
|
|
2020-10-06 11:22:06 +13:00
|
|
|
add_definitions(-DZINT_VERSION=\"${ZINT_VERSION}\")
|
2008-09-19 02:44:52 +12:00
|
|
|
|
2023-10-17 20:19:49 +13:00
|
|
|
option(ZINT_DEBUG "Set debug compile flags" OFF)
|
|
|
|
option(ZINT_NOOPT "Set no optimize compile flags" OFF)
|
|
|
|
option(ZINT_SANITIZE "Set sanitize compile/link flags" OFF)
|
|
|
|
option(ZINT_TEST "Set test compile flag" OFF)
|
|
|
|
option(ZINT_COVERAGE "Set code coverage flags" OFF)
|
|
|
|
option(ZINT_SHARED "Build shared library" ON)
|
|
|
|
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)
|
|
|
|
option(ZINT_QT6 "If ZINT_USE_QT, use Qt6" OFF)
|
|
|
|
option(ZINT_UNINSTALL "Add uninstall target" ON)
|
|
|
|
option(ZINT_FRONTEND "Build frontend" ON)
|
2019-09-02 07:23:15 +12:00
|
|
|
|
2023-01-09 14:14:42 +13:00
|
|
|
if(NOT ZINT_SHARED AND NOT ZINT_STATIC)
|
|
|
|
message(SEND_ERROR "Either ZINT_SHARED or ZINT_STATIC or both must be set")
|
|
|
|
endif()
|
|
|
|
|
2024-06-22 02:18:00 +12:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
# Taken from old (2008) KDE "SetPaths.cmake"
|
|
|
|
# Set a default build type for single-configuration CMake generators if no build type is set
|
|
|
|
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE RelWithDebInfo)
|
|
|
|
endif()
|
2008-09-24 21:00:44 +12:00
|
|
|
|
2024-05-28 07:55:04 +12:00
|
|
|
include(CheckCCompilerFlag)
|
2021-03-30 23:00:24 +13:00
|
|
|
include(CheckFunctionExists)
|
2009-05-22 09:00:23 +12:00
|
|
|
|
2021-06-10 22:15:39 +12:00
|
|
|
if(NOT MSVC) # Use default warnings if MSVC otherwise inundated
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag("-Wall" C_COMPILER_FLAG_WALL)
|
|
|
|
if(C_COMPILER_FLAG_WALL)
|
2021-06-10 22:15:39 +12:00
|
|
|
add_compile_options("-Wall")
|
|
|
|
endif()
|
2020-10-06 11:22:06 +13:00
|
|
|
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag("-Wextra" C_COMPILER_FLAG_WEXTRA)
|
|
|
|
if(C_COMPILER_FLAG_WEXTRA)
|
2021-06-10 22:15:39 +12:00
|
|
|
add_compile_options("-Wextra")
|
|
|
|
endif()
|
2020-10-06 11:22:06 +13:00
|
|
|
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag("-Wpedantic" C_COMPILER_FLAG_WPEDANTIC)
|
|
|
|
if(C_COMPILER_FLAG_WPEDANTIC)
|
2021-06-10 22:15:39 +12:00
|
|
|
add_compile_options("-Wpedantic")
|
|
|
|
endif()
|
2024-09-30 03:18:56 +13:00
|
|
|
|
|
|
|
check_c_compiler_flag("-Wundef" C_COMPILER_FLAG_WUNDEF)
|
|
|
|
if(C_COMPILER_FLAG_WUNDEF)
|
|
|
|
add_compile_options("-Wundef")
|
|
|
|
endif()
|
2020-10-06 11:22:06 +13:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZINT_DEBUG)
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag("-g" C_COMPILER_FLAG_G)
|
|
|
|
if(C_COMPILER_FLAG_G)
|
2019-09-02 07:23:15 +12:00
|
|
|
add_compile_options("-g")
|
2020-10-06 11:22:06 +13:00
|
|
|
endif()
|
2021-10-21 11:05:30 +13:00
|
|
|
endif()
|
2021-07-27 02:29:05 +12:00
|
|
|
|
2021-10-21 11:05:30 +13:00
|
|
|
if(ZINT_NOOPT)
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag("-O0" C_COMPILER_FLAG_O0)
|
|
|
|
if(C_COMPILER_FLAG_O0)
|
2019-09-02 07:23:15 +12:00
|
|
|
add_compile_options("-O0")
|
2020-10-06 11:22:06 +13:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-07-13 04:06:49 +12:00
|
|
|
if(ZINT_SANITIZE)
|
2021-07-20 02:58:44 +12:00
|
|
|
if(MSVC)
|
|
|
|
if(MSVC_VERSION GREATER_EQUAL 1920)
|
|
|
|
add_compile_options(-fsanitize=address)
|
|
|
|
message(STATUS "ZINT_SANITIZE: setting -fsanitize=address for MSVC 2019")
|
|
|
|
else()
|
|
|
|
message(STATUS "ZINT_SANITIZE: ignoring for MSVC < 2019")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(SANITIZERS address undefined)
|
|
|
|
foreach(sanitizer IN ITEMS ${SANITIZERS})
|
2021-07-27 02:29:05 +12:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES -fsanitize=${sanitizer})
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag(-fsanitize=${sanitizer} C_COMPILER_FLAG_FSANITIZE_${sanitizer})
|
|
|
|
if(C_COMPILER_FLAG_FSANITIZE_${sanitizer})
|
2021-07-27 02:29:05 +12:00
|
|
|
add_compile_options(-fsanitize=${sanitizer})
|
|
|
|
link_libraries(-fsanitize=${sanitizer})
|
2021-07-20 02:58:44 +12:00
|
|
|
endif()
|
2021-07-27 02:29:05 +12:00
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
2021-07-20 02:58:44 +12:00
|
|
|
endforeach()
|
2021-07-27 02:29:05 +12:00
|
|
|
|
2024-05-28 07:55:04 +12:00
|
|
|
if(NOT ZINT_DEBUG AND CMAKE_C_COMPILER_ID MATCHES "GNU")
|
2021-07-20 02:58:44 +12:00
|
|
|
# Gives warning on MainWindow::setupUI() and retries (& takes forever) if var-tracking-assignments enabled
|
|
|
|
add_compile_options(-fno-var-tracking-assignments)
|
2021-06-19 01:27:59 +12:00
|
|
|
endif()
|
2024-05-28 07:55:04 +12:00
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2023-06-13 00:42:15 +12:00
|
|
|
# Recent clangs added deprecation warnings for `sprintf()` that are only triggered on sanitize - suppress
|
2023-06-13 01:11:49 +12:00
|
|
|
add_compile_options(-Wno-deprecated-declarations)
|
2023-06-13 00:42:15 +12:00
|
|
|
endif()
|
2021-06-27 22:47:55 +12:00
|
|
|
endif()
|
2020-10-06 11:22:06 +13:00
|
|
|
endif()
|
|
|
|
|
2021-10-21 11:05:30 +13:00
|
|
|
if(ZINT_TEST)
|
|
|
|
enable_testing()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZINT_COVERAGE)
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES -fprofile-arcs)
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag(--coverage C_COMPILER_FLAG_COVERAGE)
|
2021-10-21 11:05:30 +13:00
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
2024-05-28 07:55:04 +12:00
|
|
|
if(C_COMPILER_FLAG_COVERAGE)
|
2021-10-21 11:05:30 +13:00
|
|
|
add_compile_options(--coverage)
|
|
|
|
link_libraries(-fprofile-arcs)
|
|
|
|
|
2024-05-28 07:55:04 +12:00
|
|
|
check_c_compiler_flag(-O0 C_COMPILER_FLAG_O0)
|
|
|
|
if(C_COMPILER_FLAG_O0)
|
2021-10-21 11:05:30 +13:00
|
|
|
add_compile_options(-O0)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2024-01-18 10:55:11 +13:00
|
|
|
check_function_exists(getopt_long_only HAVE_GETOPT_LONG_ONLY)
|
|
|
|
if(NOT HAVE_GETOPT_LONG_ONLY)
|
2021-03-30 23:00:24 +13:00
|
|
|
add_subdirectory(getopt)
|
2021-06-10 22:15:39 +12:00
|
|
|
endif()
|
2021-03-30 23:00:24 +13:00
|
|
|
|
2008-09-19 02:44:52 +12:00
|
|
|
add_subdirectory(backend)
|
2023-10-17 20:19:49 +13:00
|
|
|
if(ZINT_FRONTEND)
|
|
|
|
add_subdirectory(frontend)
|
|
|
|
endif()
|
2008-09-19 02:44:52 +12:00
|
|
|
|
2021-03-30 03:35:57 +13:00
|
|
|
if(NOT ZINT_USE_QT)
|
|
|
|
message(STATUS "Qt support was disabled for this build")
|
2022-07-09 06:16:02 +12:00
|
|
|
elseif(ZINT_QT6 OR ($ENV{CMAKE_PREFIX_PATH} MATCHES "6[.][0-9][.][0-9]"))
|
2020-10-27 01:21:43 +13:00
|
|
|
set(USE_QT6 TRUE)
|
|
|
|
message(STATUS "Using Qt6")
|
|
|
|
cmake_policy(SET CMP0012 NEW) # Recognize constants in if()
|
|
|
|
cmake_policy(SET CMP0072 NEW) # Choose OpenGL over legacy GL
|
|
|
|
find_package(Qt6Widgets)
|
|
|
|
find_package(Qt6Gui)
|
|
|
|
find_package(Qt6UiTools)
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
find_package(Qt6Svg)
|
2020-10-27 01:21:43 +13:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
if(Qt6Widgets_FOUND AND Qt6Gui_FOUND AND Qt6UiTools_FOUND AND Qt6Svg_FOUND)
|
2021-07-08 23:08:59 +12:00
|
|
|
message(STATUS "Qt version: " ${Qt6Core_VERSION_MAJOR}.${Qt6Core_VERSION_MINOR}.${Qt6Core_VERSION_PATCH})
|
2021-06-25 05:31:08 +12:00
|
|
|
add_subdirectory(backend_qt)
|
2020-10-27 01:21:43 +13:00
|
|
|
add_subdirectory(frontend_qt)
|
|
|
|
else()
|
|
|
|
message(STATUS "Could NOT find Qt6")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(STATUS "Using Qt5")
|
|
|
|
find_package(Qt5Widgets)
|
|
|
|
find_package(Qt5Gui)
|
|
|
|
find_package(Qt5UiTools)
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
find_package(Qt5Svg)
|
2020-10-27 01:21:43 +13:00
|
|
|
|
RMQR: update to ISO/IEC 23941:2022 - R13x77 numeric cclens change 8 -> 7
QRCODE: use stricter interpretation of ZINT_FULL_MULTIBYTE, excluding
certain trailing bytes
libzint: fix some confusing error messages introduced by segment stuff
general: new escape chars \U, \d and \o
backend_qt: fudge rendering of border rectangles due to scaling/translation
rounding errors TODO: better fudge
GUI: foreground/background colours -> text boxes and icon buttons, add swap
button, independently movable picker (NULL parent), preview colour changes,
preview Data Window changes, add clear data (del) buttons, add zap button
and Factory Reset menu option, various other fixes
libzint: remove STATIC_UNLESS_ZINT_TEST, use wrappers
CMake: add find package QtSvg, remove QtXml
manual: split symbology and general specs and sort, move DAFT to 4-state,
UPC/EAN -> EAN/UPC, DataBar -> GS1 DataBar always, expand MAILMARK info,
various other fiddlings
man page: options or -> |, expand MSI Plessey check digit options
README.linux: add packages info
license: add SPDX-License-Identifier to touched files
2022-06-10 08:52:02 +12:00
|
|
|
if(Qt5Widgets_FOUND AND Qt5Gui_FOUND AND Qt5UiTools_FOUND AND Qt5Svg_FOUND)
|
2021-07-07 03:35:04 +12:00
|
|
|
message(STATUS "Qt version: " ${Qt5Core_VERSION_STRING})
|
|
|
|
# Old Qt does not provide QT_VERSION_MAJOR
|
|
|
|
if (NOT QT_VERSION_MAJOR)
|
|
|
|
string(SUBSTRING ${Qt5Core_VERSION_STRING} 0 1 QT_VERSION_MAJOR)
|
|
|
|
endif()
|
2021-06-25 05:31:08 +12:00
|
|
|
add_subdirectory(backend_qt)
|
2020-10-27 01:21:43 +13:00
|
|
|
add_subdirectory(frontend_qt)
|
|
|
|
else()
|
|
|
|
message(STATUS "Could NOT find Qt5")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2023-10-17 20:19:49 +13:00
|
|
|
if(ZINT_UNINSTALL)
|
|
|
|
configure_file(
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
|
|
|
endif()
|
2008-09-19 05:07:17 +12:00
|
|
|
|
2022-11-22 03:56:52 +13:00
|
|
|
configure_file("zint-config.cmake.in" "zint-config.cmake" @ONLY)
|
2024-06-22 02:18:00 +12:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zint-config.cmake" DESTINATION "${CMAKE_INSTALL_DATADIR}/zint")
|