2008-09-19 02:44:52 +12:00
# (c) 2008 by BogDan Vatra < bogdan@licentia.eu >
2020-10-06 11:22:06 +13:00
# vim: set ts=4 sw=4 et :
2008-09-19 02:44:52 +12:00
2020-12-01 04:51:14 +13:00
cmake_minimum_required ( VERSION 3.5 )
2008-09-19 02:44:52 +12:00
project ( zint-package )
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
2008-10-03 22:50:13 +13:00
#set(CMAKE_VERBOSE_MAKEFILE ON)
2008-09-19 02:51:21 +12:00
#comment or remove the above line before release
2008-09-19 02:44:52 +12:00
2021-03-12 00:41:13 +13:00
set ( ZINT_VERSION_MAJOR 2 )
set ( ZINT_VERSION_MINOR 9 )
set ( ZINT_VERSION_RELEASE 1 )
set ( ZINT_VERSION_BUILD 9 ) # Set to 0 before release, set to 9 after release
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
2021-03-12 00:41:13 +13:00
set ( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
2008-09-19 02:44:52 +12:00
2021-03-17 12:38:47 +13:00
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 )
2021-03-30 03:35:57 +13:00
option ( ZINT_USE_PNG "Build with PNG support" ON )
option ( ZINT_USE_QT "Build with QT support" ON )
2019-09-02 07:23:15 +12:00
2021-03-12 00:41:13 +13:00
include ( SetPaths.cmake )
2008-09-24 21:00:44 +12:00
2020-10-06 11:22:06 +13:00
include ( CheckCXXCompilerFlag )
2021-03-30 23:00:24 +13:00
include ( CheckFunctionExists )
2009-05-22 09:00:23 +12:00
2020-10-06 11:22:06 +13:00
check_cxx_compiler_flag ( "-Wall" CXX_COMPILER_FLAG_WALL )
if ( CXX_COMPILER_FLAG_WALL )
add_compile_options ( "-Wall" )
endif ( )
check_cxx_compiler_flag ( "-Wextra" CXX_COMPILER_FLAG_WEXTRA )
if ( CXX_COMPILER_FLAG_WEXTRA )
add_compile_options ( "-Wextra" )
endif ( )
check_cxx_compiler_flag ( "-Wpedantic" CXX_COMPILER_FLAG_WPEDANTIC )
if ( CXX_COMPILER_FLAG_WPEDANTIC )
add_compile_options ( "-Wpedantic" )
endif ( )
if ( ZINT_DEBUG )
check_cxx_compiler_flag ( "-g" CXX_COMPILER_FLAG_G )
if ( CXX_COMPILER_FLAG_G )
2019-09-02 07:23:15 +12:00
add_compile_options ( "-g" )
2020-10-06 11:22:06 +13:00
endif ( )
check_cxx_compiler_flag ( "-O0" CXX_COMPILER_FLAG_O0 )
if ( CXX_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-03-23 00:26:00 +13:00
if ( ZINT_TEST )
enable_testing ( )
endif ( )
2020-10-06 11:22:06 +13:00
if ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC )
if ( ZINT_SANITIZE )
add_compile_options ( -fsanitize=undefined -fsanitize=address )
link_libraries ( -fsanitize=undefined -fsanitize=address )
# Gives warning on MainWindow::setupUI() and retries (and takes forever) if var-tracking-assignments enabled
add_compile_options ( -fno-var-tracking-assignments )
endif ( )
endif ( )
2009-02-06 21:44:09 +13:00
IF ( APPLE )
2020-10-06 11:22:06 +13:00
IF ( UNIVERSAL ) # TODO: make universal binary
IF ( NOT ZINT_HAS_BEEN_RUN_BEFORE )
2010-02-28 16:44:54 +13:00
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 "Flags used by the compiler during all build types." FORCE )
ELSE ( EXISTS /Developer/SDKs/MacOSX10.5.sdk OR EXISTS /SDKs/MacOSX10.5.sdk )
IF ( 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 "Flags used by the compiler during all build types." FORCE )
ENDIF ( EXISTS /Developer/SDKs/MacOSX10.4u.sdk OR EXISTS /SDKs/MacOSX10.4u.sdk )
ENDIF ( EXISTS /Developer/SDKs/MacOSX10.5.sdk OR EXISTS /SDKs/MacOSX10.5.sdk )
message ( "Build architectures for OSX:${CMAKE_OSX_ARCHITECTURES}" )
ENDIF ( NOT ZINT_HAS_BEEN_RUN_BEFORE )
ELSE ( UNIVERSAL )
SET ( CMAKE_OSX_SYSROOT "/" )
ENDIF ( UNIVERSAL )
2009-02-06 21:44:09 +13:00
ENDIF ( APPLE )
2021-03-30 23:00:24 +13:00
check_function_exists ( getopt HAVE_GETOPT )
if ( NOT HAVE_GETOPT )
add_subdirectory ( getopt )
endif ( NOT HAVE_GETOPT )
2008-09-19 02:44:52 +12:00
add_subdirectory ( backend )
add_subdirectory ( frontend )
2021-03-30 03:35:57 +13:00
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]" )
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 )
2021-03-12 00:41:13 +13:00
find_package ( Qt6Xml )
2020-10-27 01:21:43 +13:00
2021-03-12 00:41:13 +13:00
if ( Qt6Widgets_FOUND AND Qt6Gui_FOUND AND Qt6UiTools_FOUND AND Qt6Xml_FOUND )
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 )
2021-03-12 00:41:13 +13:00
find_package ( Qt5Xml )
2020-10-27 01:21:43 +13:00
2021-03-12 00:41:13 +13:00
if ( Qt5Widgets_FOUND AND Qt5Gui_FOUND AND Qt5UiTools_FOUND AND Qt5Xml_FOUND )
2020-10-27 01:21:43 +13:00
add_subdirectory ( frontend_qt )
else ( )
message ( STATUS "Could NOT find Qt5" )
endif ( )
endif ( )
configure_file (
2008-09-19 05:07:17 +12: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-27 01:21:43 +13:00
add_custom_target ( uninstall
2008-09-19 05:07:17 +12: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 " )
2015-09-15 07:47:07 +12:00
# staniek: don't install
2021-03-12 00:41:13 +13:00
if ( DATA_INSTALL_DIR )
2015-09-15 07:47:07 +12:00
set ( CMAKE_MODULES_INSTALL_PATH ${ DATA_INSTALL_DIR } /cmake/modules )
2021-03-12 00:41:13 +13:00
else ( )
2015-09-15 07:47:07 +12:00
set ( CMAKE_MODULES_INSTALL_PATH ${ CMAKE_ROOT } /Modules )
2021-03-12 00:41:13 +13:00
endif ( )
2015-09-15 07:47:07 +12:00
install ( FILES cmake/modules/FindZint.cmake DESTINATION ${ CMAKE_MODULES_INSTALL_PATH } COMPONENT Devel )
2009-05-20 20:32:33 +12:00
# This needs to be run very last so other parts of the scripts can take
# advantage of this.
2021-03-12 00:41:13 +13: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 ( )