2021-06-10 13:15:39 +03:00
# Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
2023-01-09 04:14:42 +03:00
# Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
2020-10-06 01:22:06 +03:00
# vim: set ts=4 sw=4 et :
2008-09-18 18:44:52 +04:00
2021-07-26 17:29:05 +03:00
cmake_minimum_required ( VERSION 3.5 )
2008-09-18 18:44:52 +04:00
project ( zint-package )
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
2021-03-11 14:41:13 +03:00
set ( ZINT_VERSION_MAJOR 2 )
2022-12-13 00:06:08 +03:00
set ( ZINT_VERSION_MINOR 12 )
set ( ZINT_VERSION_RELEASE 0 )
2022-12-13 00:45:16 +03:00
set ( ZINT_VERSION_BUILD 9 ) # Set to 0 before release, set to 9 after release
2021-03-11 14:41:13 +03:00
set ( ZINT_VERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}.${ZINT_VERSION_RELEASE}.${ZINT_VERSION_BUILD}" )
2008-09-18 18:44:52 +04:00
2020-10-06 01:22:06 +03:00
add_definitions ( -DZINT_VERSION=\ "${ZINT_VERSION}\" )
2008-09-18 18:44:52 +04:00
2021-03-11 14:41:13 +03:00
set ( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
2008-09-18 18:44:52 +04:00
2021-07-26 17:29:05 +03:00
option ( ZINT_DEBUG "Set debug compile flags" OFF )
2021-10-21 01:05:30 +03:00
option ( ZINT_NOOPT "Set no optimize compile flags" OFF )
2021-03-17 02:38:47 +03:00
option ( ZINT_SANITIZE "Set sanitize compile/link flags" OFF )
option ( ZINT_TEST "Set test compile flag" OFF )
2021-07-26 17:29:05 +03:00
option ( ZINT_COVERAGE "Set code coverage flags" OFF )
2022-11-21 14:41:29 +03:00
option ( ZINT_SHARED "Build shared library" ON )
2021-03-17 02:38:47 +03:00
option ( ZINT_STATIC "Build static library" OFF )
2021-03-29 17:35:57 +03:00
option ( ZINT_USE_PNG "Build with PNG support" ON )
2022-05-19 12:17:51 +03:00
option ( ZINT_USE_QT "Build with Qt support" ON )
2022-07-08 21:16:02 +03:00
option ( ZINT_QT6 "If ZINT_USE_QT, use Qt6" OFF )
2019-09-01 22:23:15 +03:00
2023-01-09 04:14:42 +03:00
if ( NOT ZINT_SHARED AND NOT ZINT_STATIC )
message ( SEND_ERROR "Either ZINT_SHARED or ZINT_STATIC or both must be set" )
endif ( )
2021-03-11 14:41:13 +03:00
include ( SetPaths.cmake )
2008-09-24 13:00:44 +04:00
2020-10-06 01:22:06 +03:00
include ( CheckCXXCompilerFlag )
2021-03-30 13:00:24 +03:00
include ( CheckFunctionExists )
2009-05-22 01:00:23 +04:00
2021-06-10 13:15:39 +03:00
if ( NOT MSVC ) # Use default warnings if MSVC otherwise inundated
check_cxx_compiler_flag ( "-Wall" CXX_COMPILER_FLAG_WALL )
if ( CXX_COMPILER_FLAG_WALL )
add_compile_options ( "-Wall" )
endif ( )
2020-10-06 01:22:06 +03:00
2021-06-10 13:15:39 +03:00
check_cxx_compiler_flag ( "-Wextra" CXX_COMPILER_FLAG_WEXTRA )
if ( CXX_COMPILER_FLAG_WEXTRA )
add_compile_options ( "-Wextra" )
endif ( )
2020-10-06 01:22:06 +03:00
2021-06-10 13:15:39 +03:00
check_cxx_compiler_flag ( "-Wpedantic" CXX_COMPILER_FLAG_WPEDANTIC )
if ( CXX_COMPILER_FLAG_WPEDANTIC )
add_compile_options ( "-Wpedantic" )
endif ( )
2020-10-06 01:22:06 +03:00
endif ( )
if ( ZINT_DEBUG )
check_cxx_compiler_flag ( "-g" CXX_COMPILER_FLAG_G )
if ( CXX_COMPILER_FLAG_G )
2019-09-01 22:23:15 +03:00
add_compile_options ( "-g" )
2020-10-06 01:22:06 +03:00
endif ( )
2021-10-21 01:05:30 +03:00
endif ( )
2021-07-26 17:29:05 +03:00
2021-10-21 01:05:30 +03:00
if ( ZINT_NOOPT )
2020-10-06 01:22:06 +03:00
check_cxx_compiler_flag ( "-O0" CXX_COMPILER_FLAG_O0 )
if ( CXX_COMPILER_FLAG_O0 )
2019-09-01 22:23:15 +03:00
add_compile_options ( "-O0" )
2020-10-06 01:22:06 +03:00
endif ( )
endif ( )
2021-07-12 19:06:49 +03:00
if ( ZINT_SANITIZE )
2021-07-19 17:58:44 +03: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-26 17:29:05 +03:00
set ( CMAKE_REQUIRED_LIBRARIES -fsanitize= ${ sanitizer } )
check_cxx_compiler_flag ( -fsanitize= ${ sanitizer } CXX_COMPILER_FLAG_FSANITIZE_ ${ sanitizer } )
if ( CXX_COMPILER_FLAG_FSANITIZE_ ${ sanitizer } )
add_compile_options ( -fsanitize= ${ sanitizer } )
link_libraries ( -fsanitize= ${ sanitizer } )
2021-07-19 17:58:44 +03:00
endif ( )
2021-07-26 17:29:05 +03:00
unset ( CMAKE_REQUIRED_LIBRARIES )
2021-07-19 17:58:44 +03:00
endforeach ( )
2021-07-26 17:29:05 +03:00
2021-07-19 17:58:44 +03:00
if ( NOT ZINT_DEBUG AND CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
# Gives warning on MainWindow::setupUI() and retries (& takes forever) if var-tracking-assignments enabled
add_compile_options ( -fno-var-tracking-assignments )
2021-06-18 16:27:59 +03:00
endif ( )
2021-06-27 13:47:55 +03:00
endif ( )
2020-10-06 01:22:06 +03:00
endif ( )
2021-10-21 01:05:30 +03:00
if ( ZINT_TEST )
enable_testing ( )
endif ( )
if ( ZINT_COVERAGE )
set ( CMAKE_REQUIRED_LIBRARIES -fprofile-arcs )
check_cxx_compiler_flag ( --coverage CXX_COMPILER_FLAG_COVERAGE )
unset ( CMAKE_REQUIRED_LIBRARIES )
if ( CXX_COMPILER_FLAG_COVERAGE )
add_compile_options ( --coverage )
link_libraries ( -fprofile-arcs )
check_cxx_compiler_flag ( -O0 CXX_COMPILER_FLAG_O0 )
if ( CXX_COMPILER_FLAG_O0 )
add_compile_options ( -O0 )
endif ( )
endif ( )
endif ( )
2021-06-10 13:15:39 +03:00
if ( APPLE )
if ( UNIVERSAL ) # TODO: make universal binary
if ( NOT ZINT_HAS_BEEN_RUN_BEFORE )
if ( EXISTS /Developer/SDKs/MacOSX10.5.sdk OR EXISTS /SDKs/MacOSX10.5.sdk )
set ( CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden -Wl -single_module " CACHE STRING
" F l a g s u s e d b y t h e c o m p i l e r d u r i n g a l l b u i l d t y p e s . " F O R C E )
elseif ( EXISTS /Developer/SDKs/MacOSX10.4u.sdk OR EXISTS /SDKs/MacOSX10.4u.sdk )
set ( CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden -Wl -single_module " CACHE STRING
" F l a g s u s e d b y t h e c o m p i l e r d u r i n g a l l b u i l d t y p e s . " F O R C E )
endif ( )
2010-02-28 06:44:54 +03:00
message ( "Build architectures for OSX:${CMAKE_OSX_ARCHITECTURES}" )
2021-06-10 13:15:39 +03:00
endif ( )
else ( )
set ( CMAKE_OSX_SYSROOT "/" )
endif ( )
endif ( )
2009-02-06 11:44:09 +03:00
2021-03-30 13:00:24 +03:00
check_function_exists ( getopt HAVE_GETOPT )
if ( NOT HAVE_GETOPT )
add_subdirectory ( getopt )
2021-06-10 13:15:39 +03:00
endif ( )
2021-03-30 13:00:24 +03:00
2008-09-18 18:44:52 +04:00
add_subdirectory ( backend )
add_subdirectory ( frontend )
2021-03-29 17:35:57 +03:00
if ( NOT ZINT_USE_QT )
message ( STATUS "Qt support was disabled for this build" )
2022-07-08 21:16:02 +03:00
elseif ( ZINT_QT6 OR ( $ENV{ CMAKE_PREFIX_PATH } MATCHES "6[.][0-9][.][0-9]" ) )
2020-10-26 15:21:43 +03: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-09 23:52:02 +03:00
find_package ( Qt6Svg )
2020-10-26 15:21:43 +03: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-09 23:52:02 +03:00
if ( Qt6Widgets_FOUND AND Qt6Gui_FOUND AND Qt6UiTools_FOUND AND Qt6Svg_FOUND )
2021-07-08 14:08:59 +03:00
message ( STATUS "Qt version: " ${ Qt6Core_VERSION_MAJOR } . ${ Qt6Core_VERSION_MINOR } . ${ Qt6Core_VERSION_PATCH } )
2021-06-24 20:31:08 +03:00
add_subdirectory ( backend_qt )
2020-10-26 15:21:43 +03: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-09 23:52:02 +03:00
find_package ( Qt5Svg )
2020-10-26 15:21:43 +03: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-09 23:52:02 +03:00
if ( Qt5Widgets_FOUND AND Qt5Gui_FOUND AND Qt5UiTools_FOUND AND Qt5Svg_FOUND )
2021-07-06 18:35:04 +03: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-24 20:31:08 +03:00
add_subdirectory ( backend_qt )
2020-10-26 15:21:43 +03:00
add_subdirectory ( frontend_qt )
else ( )
message ( STATUS "Could NOT find Qt5" )
endif ( )
endif ( )
configure_file (
2008-09-18 21:07:17 +04:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e _ u n i n s t a l l . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
I M M E D I A T E @ O N L Y )
2020-10-26 15:21:43 +03:00
add_custom_target ( uninstall
2008-09-18 21:07:17 +04:00
" $ { C M A K E _ C O M M A N D } " - P " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e " )
2021-06-10 13:15:39 +03:00
# staniek: don't install
2021-03-11 14:41:13 +03:00
if ( DATA_INSTALL_DIR )
2015-09-14 22:47:07 +03:00
set ( CMAKE_MODULES_INSTALL_PATH ${ DATA_INSTALL_DIR } /cmake/modules )
2021-03-11 14:41:13 +03:00
else ( )
2015-09-14 22:47:07 +03:00
set ( CMAKE_MODULES_INSTALL_PATH ${ CMAKE_ROOT } /Modules )
2021-03-11 14:41:13 +03:00
endif ( )
2015-09-14 22:47:07 +03:00
install ( FILES cmake/modules/FindZint.cmake DESTINATION ${ CMAKE_MODULES_INSTALL_PATH } COMPONENT Devel )
2022-11-21 17:56:52 +03:00
configure_file ( "zint-config.cmake.in" "zint-config.cmake" @ONLY )
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/zint-config.cmake" DESTINATION "${SHARE_INSTALL_PREFIX}/zint" )
2009-05-20 12:32:33 +04:00
# This needs to be run very last so other parts of the scripts can take
# advantage of this.
2021-03-11 14:41:13 +03:00
if ( NOT ZINT_HAS_BEEN_RUN_BEFORE )
set ( ZINT_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL
" F l a g t o t r a c k w h e t h e r t h i s i s t h e f i r s t t i m e r u n n i n g C M a k e o r i f C M a k e h a s b e e n c o n f i g u r e d b e f o r e " )
endif ( )