2018-06-07 08:56:19 -04:00
#############################################################
# CMake settings
2021-03-28 21:49:40 +02:00
cmake_minimum_required ( VERSION 3.12.0 )
2020-11-11 11:15:34 +01:00
set ( CMAKE_COLOR_MAKEFILE ON )
set ( CMAKE_AUTORCC ON )
2018-06-07 08:56:19 -04:00
# set path to additional CMake modules
2020-11-11 11:15:34 +01:00
set ( CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /cmake ${ CMAKE_MODULE_PATH } )
2018-06-07 08:56:19 -04:00
# POLICIES
2021-03-28 21:49:40 +02:00
cmake_policy ( SET CMP0048 NEW )
cmake_policy ( SET CMP0053 NEW )
cmake_policy ( SET CMP0071 NEW )
cmake_policy ( SET CMP0094 NEW )
2018-06-07 08:56:19 -04:00
2019-04-02 17:14:09 +02:00
# don't relink it only the shared object changes
2020-11-11 11:15:34 +01:00
set ( CMAKE_LINK_DEPENDS_NO_SHARED ON )
2019-04-02 17:14:09 +02:00
2018-06-07 08:56:19 -04:00
#############################################################
# Project and version
2020-11-11 11:15:34 +01:00
set ( CPACK_PACKAGE_VERSION_MAJOR "3" )
2021-02-19 13:12:08 +01:00
set ( CPACK_PACKAGE_VERSION_MINOR "19" )
2020-11-11 11:15:34 +01:00
set ( CPACK_PACKAGE_VERSION_PATCH "0" )
set ( COMPLETE_VERSION ${ CPACK_PACKAGE_VERSION_MAJOR } . ${ CPACK_PACKAGE_VERSION_MINOR } . ${ CPACK_PACKAGE_VERSION_PATCH } )
set ( RELEASE_NAME "Master" )
project ( qgis VERSION ${ COMPLETE_VERSION } )
if ( APPLE )
set ( QGIS_APP_NAME "QGIS" )
else ( )
set ( QGIS_APP_NAME "qgis" )
endif ( )
2010-03-05 15:22:21 +00:00
2009-04-11 20:51:50 +00:00
# Note the version no is Mmmpp for Major/minor/patch, 0-padded, thus '10100' for 1.1.0
2020-11-11 11:15:34 +01:00
math ( EXPR QGIS_VERSION_INT "${CPACK_PACKAGE_VERSION_MAJOR}*10000+${CPACK_PACKAGE_VERSION_MINOR}*100+${CPACK_PACKAGE_VERSION_PATCH}" )
message ( STATUS "QGIS version: ${COMPLETE_VERSION} ${RELEASE_NAME} (${QGIS_VERSION_INT})" )
2008-08-23 21:37:31 +00:00
2021-05-11 08:36:46 +02:00
set ( ENABLE_LOCAL_BUILD_SHORTCUTS FALSE CACHE BOOL "Disables some build steps which are only relevant for releases to speed up compilation time for development" )
2020-04-05 10:51:00 +02:00
#############################################################
2020-11-11 11:15:34 +01:00
if ( APPLE )
2020-04-05 10:51:00 +02:00
# QGIS custom dependencies package from qgis/QGIS-Mac-Packager
# they can be downloaded from https://qgis.org/downloads/macos/qgis-deps
# and extracted to /opt/QGIS/qgis-deps-<deps-version>/stage
2020-11-11 11:15:34 +01:00
set ( QGIS_MAC_DEPS_DIR "" CACHE PATH "Path to QGIS Mac custom dependencies directory" )
2020-04-05 10:51:00 +02:00
# Setup LIB_DIR and CMAKE_PREFIX_PATH to help CMake's
# find_packages to look for these libraries instead of system libraries
2020-11-11 11:15:34 +01:00
if ( QGIS_MAC_DEPS_DIR )
set ( ENV{LIB_DIR} ${ QGIS_MAC_DEPS_DIR } )
list ( APPEND CMAKE_PREFIX_PATH ${ QGIS_MAC_DEPS_DIR } )
endif ( )
endif ( )
2008-08-23 21:37:31 +00:00
2018-06-07 08:56:19 -04:00
#############################################################
2018-04-10 08:50:12 +02:00
# Configure OpenCL if available
2020-11-11 11:15:34 +01:00
set ( HAVE_OPENCL FALSE )
if ( ${ CMAKE_HOST_SYSTEM_NAME } MATCHES "BSD$" )
option ( USE_OPENCL "Use OpenCL" OFF )
else ( )
option ( USE_OPENCL "Use OpenCL" ON )
endif ( )
if ( USE_OPENCL )
find_package ( OpenCL )
if ( ${ OpenCL_FOUND } )
set ( HAVE_OPENCL TRUE )
2019-10-25 21:51:21 +02:00
# Fixup for standard FindOpenCL module not assigning proper framework headers directory
2020-11-11 11:15:34 +01:00
if ( APPLE AND "${OpenCL_INCLUDE_DIR}" MATCHES "OpenCL\\.framework/?$" )
set ( OpenCL_INCLUDE_DIR "${OpenCL_INCLUDE_DIR}/Headers" CACHE PATH "" FORCE )
set ( OpenCL_INCLUDE_DIRS ${ OpenCL_INCLUDE_DIR } )
endif ( )
find_package ( OpenCLhpp )
if ( NOT OPENCL_HPP_FOUND )
[opencl] Add FindOpenCLhpp CMake module; vendor cl2.hpp; fixup includes
CL/cl2.hpp, which the OpenCL support is based upon, is not always
included with OpenCL on some platforms, e.g. Mac, or not readily
available as a package. This work adds a CMake module specifically for
finding cl2.hpp, as installed by OpenCL-CLHPP project.
If not found, but standard OpenCL lib and headers are, the vendored
cl2.hpp in external/opencl-clhpp is used, as it needs no compilation.
- Only the cl2.hpp, license and README are vendored from OpenCL-CLHPP.
- Fix up referenced includes in other CMake targets, to ensure the
includes for OpenCL are specifically added (previously, they were
sometimes found in existing include directories of other dependencies).
- Fixup for standard FindOpenCL module not assinging proper framework
headers directory for Mac.
2018-09-30 19:55:29 -06:00
# Use internal headers copied from OpenCL-CLHPP project
2020-11-11 11:15:34 +01:00
set ( OPENCL_HPP_INCLUDE_DIR ${ CMAKE_SOURCE_DIR } /external/opencl-clhpp/include CACHE PATH "" FORCE )
message ( STATUS "Couldn't find OpenCL C++ headers, using internal: ${OPENCL_HPP_INCLUDE_DIR}" )
endif ( )
set ( OpenCL_INCLUDE_DIRS ${ OpenCL_INCLUDE_DIRS } ${ OPENCL_HPP_INCLUDE_DIR } )
else ( )
message ( STATUS "Couldn't find OpenCL: support DISABLED" )
endif ( )
endif ( )
2018-04-10 08:50:12 +02:00
2018-01-17 04:20:47 +01:00
# Configure CCache if available
2020-11-11 11:15:34 +01:00
if ( NOT MSVC )
2018-06-20 09:48:55 +02:00
option ( USE_CCACHE "Use ccache" ON )
if ( USE_CCACHE )
2018-04-04 13:17:57 +02:00
find_program ( CCACHE_FOUND ccache )
if ( CCACHE_FOUND )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache )
2021-02-08 15:25:39 +01:00
message ( STATUS "ccache found" )
2018-04-04 13:17:57 +02:00
endif ( CCACHE_FOUND )
2018-06-20 09:48:55 +02:00
endif ( USE_CCACHE )
endif ( NOT MSVC )
2018-01-17 04:20:47 +01:00
2020-11-11 11:15:34 +01:00
if ( IOS )
set ( DEFAULT_FORCE_STATIC_LIBS TRUE )
set ( DEFAULT_FORCE_STATIC_PROVIDERS TRUE )
else ( )
set ( DEFAULT_FORCE_STATIC_LIBS FALSE )
set ( DEFAULT_FORCE_STATIC_PROVIDERS FALSE )
endif ( )
set ( FORCE_STATIC_LIBS ${ DEFAULT_FORCE_STATIC_LIBS } CACHE BOOL "Determines whether libraries should be static only" )
mark_as_advanced ( FORCE_STATIC_LIBS )
if ( FORCE_STATIC_LIBS )
set ( LIBRARY_TYPE STATIC )
else ( )
set ( LIBRARY_TYPE SHARED )
endif ( )
set ( FORCE_STATIC_PROVIDERS ${ DEFAULT_FORCE_STATIC_PROVIDERS } CACHE BOOL "Determines whether data providers should be static only" )
mark_as_advanced ( FORCE_STATIC_PROVIDERS )
if ( FORCE_STATIC_PROVIDERS )
2019-09-02 16:49:36 +02:00
# following variable is used in qgsconfig.h
2020-11-11 11:15:34 +01:00
set ( HAVE_STATIC_PROVIDERS TRUE )
endif ( )
2019-09-02 16:49:36 +02:00
2008-08-23 21:37:31 +00:00
# in generated makefiles use relative paths so the project dir is moveable
# Note commented out since it cause problems but it would be nice to resolve these and enable
2011-05-28 11:50:03 +02:00
#
2020-11-11 11:15:34 +01:00
# issue is caused by include_directories(${CMAKE_BINARY_DIR}) near the end of this file generating incorrect path
#set (CMAKE_USE_RELATIVE_PATHS ON)
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
set ( WITH_CORE TRUE CACHE BOOL "Determines whether QGIS core should be built." )
mark_as_advanced ( WITH_CORE )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
2017-07-12 17:51:03 +02:00
# Only GRASS 7 is currently supported but we keep dual version support in cmake for possible future switch to GRASS 8.
# Try to configure and build GRASS plugin by default
2020-11-11 11:15:34 +01:00
foreach ( GRASS_SEARCH_VERSION 7 )
2017-07-12 17:51:03 +02:00
# Legacy note:
# For GRASS 6 there were used cached variables without version suffix so that existing caches didn't have to be reconfigured.
# Cached variables were: WITH_GRASS, WITH_GRASS7, GRASS_PREFIX, GRASS_PREFIX7, GRASS_INCLUDE_DIR, GRASS_INCLUDE_DIR7
2017-06-02 21:39:44 +02:00
# Everywhere else each variable has version major appended.
2017-07-12 17:51:03 +02:00
# Normal variables were: GRASS_FOUND6, GRASS_FOUND7, GRASS_MAJOR_VERSION6, GRASS_MAJOR_VERSION7, etc.
2017-06-02 21:39:44 +02:00
# In addition there is also GRASS_FOUND, which is TRUE if at least one version of GRASS was found
2020-11-11 11:15:34 +01:00
set ( GRASS_CACHE_VERSION ${ GRASS_SEARCH_VERSION } )
set ( WITH_GRASS ${ GRASS_CACHE_VERSION } TRUE CACHE BOOL "Determines whether GRASS ${GRASS_SEARCH_VERSION} plugin should be built" )
if ( WITH_GRASS ${ GRASS_CACHE_VERSION } )
find_package ( GRASS ${ GRASS_SEARCH_VERSION } )
set ( GRASS_PREFIX ${ GRASS_CACHE_VERSION } ${ GRASS_PREFIX${GRASS_SEARCH_VERSION } } CACHE PATH "Path to GRASS ${GRASS_SEARCH_VERSION} base directory" )
endif ( )
endforeach ( GRASS_SEARCH_VERSION )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
set ( WITH_GUI TRUE CACHE BOOL "Determines whether QGIS GUI library (and everything built on top of it) should be built" )
2017-07-06 14:05:08 +02:00
2021-05-18 12:40:26 +07:00
set ( WITH_AUTH TRUE CACHE BOOL "Determines whether QGIS authentication methods should be built" )
2020-11-11 11:15:34 +01:00
set ( WITH_ANALYSIS TRUE CACHE BOOL "Determines whether QGIS analysis library should be built" )
2018-12-03 12:00:21 -04:00
2020-11-11 11:15:34 +01:00
set ( WITH_DESKTOP TRUE CACHE BOOL "Determines whether QGIS desktop should be built" )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
set ( WITH_3D FALSE CACHE BOOL "Determines whether QGIS 3D library should be built" )
2017-07-19 19:21:38 +02:00
2020-11-11 11:15:34 +01:00
set ( WITH_QUICK FALSE CACHE BOOL "Determines whether QGIS Quick library should be built" )
2018-04-26 13:33:48 +02:00
2020-11-11 11:15:34 +01:00
set ( WITH_QGIS_PROCESS TRUE CACHE BOOL "Determines whether the standalone \" qgis_process\ " tool should be built" )
2020-02-24 11:36:21 +10:00
2019-04-05 09:05:30 +02:00
# try to configure and build python bindings by default
2020-11-11 11:15:34 +01:00
set ( WITH_BINDINGS TRUE CACHE BOOL "Determines whether python bindings should be built" )
if ( WITH_BINDINGS )
2019-04-05 09:05:30 +02:00
# By default bindings will be installed only to QGIS directory
# Someone might want to install it to python site-packages directory
# as otherwise user has to use PYTHONPATH environment variable to add
# QGIS bindings to package search path
2020-11-11 11:15:34 +01:00
set ( BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global python directory? (might need root)" )
set ( SIP_GLOBAL_INSTALL FALSE CACHE BOOL "Install sip source files to system sip directory? (might need root)" )
set ( WITH_STAGED_PLUGINS TRUE CACHE BOOL "Stage-install core Python plugins to run from build directory? (utilities and console are always staged)" )
set ( WITH_PY_COMPILE FALSE CACHE BOOL "Determines whether Python modules in staged or installed locations are byte-compiled" )
2019-04-05 09:05:30 +02:00
# concatenate QScintilla2 API files
2020-11-11 11:15:34 +01:00
if ( WITH_GUI )
set ( WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. (For devs) run 'make qsci-pap-src' in between QGIS build and install to regenerate .pap file in source tree for console auto-completion." )
2019-04-05 09:05:30 +02:00
# keep casual users from updating their source tree via WITH_QSCIAPI
2020-11-11 11:15:34 +01:00
mark_as_advanced ( WITH_QSCIAPI )
endif ( )
endif ( )
2019-04-05 09:05:30 +02:00
2017-06-02 21:39:44 +02:00
# server disabled default because it needs FastCGI (which is optional dependency)
2020-11-11 11:15:34 +01:00
set ( WITH_SERVER FALSE CACHE BOOL "Determines whether QGIS server should be built" )
if ( WITH_SERVER )
set ( SERVER_SKIP_ECW FALSE CACHE BOOL "Determines whether QGIS server should disable ECW (ECW in server apps requires a special license)" )
set ( WITH_SERVER_PLUGINS ${ WITH_BINDINGS } CACHE BOOL "Determines whether QGIS server support for python plugins should be built" )
if ( WITH_SERVER_PLUGINS AND NOT WITH_BINDINGS )
message ( FATAL_ERROR "Server plugins are not supported without python bindings. Enable WITH_BINDINGS or disable WITH_SERVER_PLUGINS" )
endif ( )
if ( WITH_SERVER_PLUGINS )
set ( HAVE_SERVER_PYTHON_PLUGINS TRUE )
endif ( )
endif ( )
2017-06-02 21:39:44 +02:00
# Custom widgets
2020-11-11 11:15:34 +01:00
set ( WITH_CUSTOM_WIDGETS FALSE CACHE BOOL "Determines whether QGIS custom widgets for Qt Designer should be built" )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( NOT WITH_GUI )
set ( HAVE_GUI FALSE ) # used in qgsconfig.h
2017-07-06 14:05:08 +02:00
# force value of some options
2020-11-11 11:15:34 +01:00
if ( WITH_DESKTOP )
message ( FATAL_ERROR "Desktop cannot be built without gui. Enable WITH_GUI or disable WITH_DESKTOP." )
endif ( )
if ( WITH_CUSTOM_WIDGETS )
message ( FATAL_ERROR "Custom widgets cannot be built without gui. Enable WITH_GUI or disable WITH_CUSTOM_WIDGETS." )
endif ( )
else ( )
set ( HAVE_GUI TRUE ) # used in qgsconfig.h
endif ( )
if ( WITH_DESKTOP AND NOT WITH_ANALYSIS )
message ( FATAL_ERROR "Desktop cannot be built without analysis" )
endif ( )
if ( WITH_QGIS_PROCESS AND NOT WITH_ANALYSIS )
message ( FATAL_ERROR "Process tool cannot be built without analysis" )
endif ( )
if ( WITH_DESKTOP )
2019-08-02 12:57:20 +02:00
# The qgis_desktop target is meant to build a minimal but complete running QGIS during development
# This should help to reduce compile time while still having a "complete enough" QGIS for most of the development
2020-11-11 11:15:34 +01:00
add_custom_target ( qgis_desktop
2019-10-06 20:16:01 +02:00
D E P E N D S q g i s q g i s p y t h o n p y c o r e p y g u i p y a n a l y s i s p o s t g r e s p r o v i d e r s t a g e d - p l u g i n s p y p l u g i n - i n s t a l l e r r e s o u r c e s s v g d o c i c o n s
2019-08-02 12:57:20 +02:00
)
2020-11-11 11:15:34 +01:00
endif ( )
2019-08-02 12:57:20 +02:00
2018-04-06 16:11:50 +02:00
# try to configure and build MDAL support
2020-11-24 00:18:51 +01:00
set ( WITH_INTERNAL_MDAL TRUE CACHE BOOL "Determines whether MDAL should be built from internal copy" )
2020-11-11 11:15:34 +01:00
if ( NOT WITH_INTERNAL_MDAL )
set ( MDAL_PREFIX "" CACHE PATH "Path to MDAL base directory" )
endif ( )
2018-04-06 16:11:50 +02:00
2020-11-24 00:18:51 +01:00
# try to configure and build POLY2TRI support
set ( WITH_INTERNAL_POLY2TRI TRUE CACHE BOOL "Determines whether POLY2TRI should be built from internal copy" )
2017-06-02 21:39:44 +02:00
# try to configure and build POSTGRESQL support
2020-11-11 11:15:34 +01:00
set ( WITH_POSTGRESQL TRUE CACHE BOOL "Determines whether POSTGRESQL support should be built" )
if ( WITH_POSTGRESQL )
set ( POSTGRESQL_PREFIX "" CACHE PATH "Path to POSTGRESQL base directory" )
endif ( )
2021-05-07 14:22:20 +10:00
# try to configure and build POSTGRESQL support
set ( WITH_SPATIALITE TRUE CACHE BOOL "Determines whether Spatialite support should be built (required for spatialite, virtual, wfs providers)" )
if ( WITH_SPATIALITE )
set ( WITH_QSPATIALITE FALSE CACHE BOOL "Determines whether QSPATIALITE sql driver should be built" )
endif ( )
2020-11-11 11:15:34 +01:00
set ( WITH_ORACLE FALSE CACHE BOOL "Determines whether Oracle support should be built" )
if ( WITH_ORACLE )
set ( HAVE_ORACLE TRUE )
set ( ORACLE_INCLUDEDIR "" CACHE STRING "Path to OCI headers" )
set ( ORACLE_LIBDIR "" CACHE STRING "Path to OCI libraries" )
endif ( )
2021-01-12 15:57:00 +01:00
set ( WITH_HANA FALSE CACHE BOOL "Determines whether SAP HANA Spatial support should be built" )
if ( WITH_HANA )
find_package ( ODBC )
if ( ODBC_FOUND )
set ( HAVE_HANA TRUE )
add_subdirectory ( external/odbccpp )
2021-01-12 21:00:29 +01:00
set_target_properties ( odbccpp_static PROPERTIES AUTOMOC OFF AUTOUIC OFF AUTORCC OFF )
2021-01-12 15:57:00 +01:00
else ( )
message ( STATUS "Couldn't find ODBC library" )
endif ( )
endif ( WITH_HANA )
2019-07-03 15:47:01 +02:00
2020-11-11 11:15:34 +01:00
set ( WITH_PDAL FALSE CACHE BOOL "Determines whether PDAL support should be built" )
if ( WITH_PDAL )
set ( HAVE_PDAL TRUE )
endif ( )
2020-11-12 07:19:06 +10:00
set ( WITH_EPT TRUE CACHE BOOL "Determines whether Entwine Point Cloud (EPT) support should be built" )
2020-11-11 11:15:34 +01:00
if ( WITH_EPT )
set ( HAVE_EPT TRUE )
endif ( )
2020-11-06 15:11:31 +10:00
2017-06-02 21:39:44 +02:00
#BUILD WITH QtMobility by default on android only. Other platform can force it
2020-11-11 11:15:34 +01:00
if ( ANDROID )
set ( DEFAULT_WITH_QTMOBILITY TRUE )
else ( )
set ( DEFAULT_WITH_QTMOBILITY FALSE )
endif ( )
set ( WITH_QTMOBILITY ${ DEFAULT_WITH_QTMOBILITY } CACHE BOOL "Determines if QtMobility related code should be build (for example internal GPS)" )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
set ( WITH_GEOREFERENCER TRUE CACHE BOOL "Determines whether GeoReferencer plugin should be built" )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
set ( WITH_THREAD_LOCAL TRUE CACHE BOOL "Determines whether std::thread_local should be used" )
mark_as_advanced ( WITH_THREAD_LOCAL )
2017-11-06 09:16:12 +10:00
2020-11-11 11:15:34 +01:00
if ( MINGW OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" )
2017-11-06 09:16:12 +10:00
# MingW has broken support for thread_local, so force disabling it
# see
# https://sourceforge.net/p/mingw-w64/bugs/445/
# https://sourceforge.net/p/mingw-w64/bugs/527/
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80816
2019-06-12 00:10:43 +01:00
# also OpenBSD has no thread_local support, see https://github.com/qgis/QGIS/issues/25248
2017-11-06 09:16:12 +10:00
2020-11-11 11:15:34 +01:00
else ( )
if ( WITH_THREAD_LOCAL )
set ( USE_THREAD_LOCAL TRUE ) # used in qgsconfig.h
endif ( )
endif ( )
2017-11-06 09:16:12 +10:00
2017-06-02 21:39:44 +02:00
# Compile flag. Make it possible to turn it off.
2020-11-11 11:15:34 +01:00
set ( PEDANTIC TRUE CACHE BOOL "Determines if we should compile in pedantic mode." )
2017-06-02 21:39:44 +02:00
# whether coverage tests should be performed
2020-11-11 11:15:34 +01:00
set ( ENABLE_COVERAGE FALSE CACHE BOOL "Perform coverage tests?" )
2017-06-02 21:39:44 +02:00
# whether coverage documentation should be generated
2020-11-11 11:15:34 +01:00
set ( GENERATE_COVERAGE_DOCS FALSE CACHE BOOL "Generate coverage docs (requires lcov)?" )
2017-06-02 21:39:44 +02:00
# hide this variable because building of python bindings might fail
# if set to other directory than expected
2020-11-11 11:15:34 +01:00
mark_as_advanced ( LIBRARY_OUTPUT_PATH )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( MSVC AND CMAKE_GENERATOR MATCHES "NMake" )
2017-06-02 21:39:44 +02:00
# following variable is also used in qgsconfig.h
2020-11-11 11:15:34 +01:00
set ( USING_NMAKE TRUE )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( CMAKE_GENERATOR MATCHES "Ninja" )
2017-06-02 21:39:44 +02:00
# following variable is also used in qgsconfig.h
2020-11-11 11:15:34 +01:00
set ( USING_NINJA TRUE )
endif ( )
2017-06-02 21:39:44 +02:00
#############################################################
# check if lexer and parser are not missing
# http://www.mail-archive.com/cmake@cmake.org/msg02861.html
2020-11-11 11:15:34 +01:00
include ( Flex )
2017-06-02 21:39:44 +02:00
FIND_FLEX ( )
2020-11-11 11:15:34 +01:00
if ( NOT FLEX_EXECUTABLE )
message ( FATAL_ERROR "Couldn't find Flex" )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
include ( Bison )
2017-06-02 21:39:44 +02:00
FIND_BISON ( )
2020-11-11 11:15:34 +01:00
if ( NOT BISON_EXECUTABLE )
message ( FATAL_ERROR "Couldn't find Bison" )
endif ( )
2017-06-02 21:39:44 +02:00
#############################################################
# search for dependencies
2020-11-11 11:15:34 +01:00
if ( NOT WIN32 AND NOT ANDROID )
include ( CheckFunctionExists )
2017-06-02 21:39:44 +02:00
CHECK_FUNCTION_EXISTS ( openpty OPENPTY_IN_LIBC )
2020-11-11 11:15:34 +01:00
if ( NOT OPENPTY_IN_LIBC )
set ( CMAKE_REQUIRED_INCLUDES util.h )
set ( CMAKE_REQUIRED_LIBRARIES util )
2017-06-02 21:39:44 +02:00
CHECK_FUNCTION_EXISTS ( openpty NEED_LIBUTIL )
2020-11-11 11:15:34 +01:00
if ( NEED_LIBUTIL )
set ( OPENPTY_LIBRARY util )
else ( )
message ( SEND_ERROR "openpty not found!" )
endif ( )
endif ( )
endif ( )
2017-06-02 21:39:44 +02:00
# required
2020-11-11 11:15:34 +01:00
find_package ( Proj )
find_package ( GEOS )
find_package ( GDAL )
find_package ( Expat REQUIRED )
find_package ( Spatialindex REQUIRED )
if ( WITH_GUI )
find_package ( Qwt REQUIRED )
endif ( )
find_package ( LibZip REQUIRED )
find_package ( Sqlite3 )
if ( NOT SQLITE3_FOUND )
message ( SEND_ERROR "sqlite3 dependency was not found!" )
endif ( )
find_package ( Protobuf REQUIRED ) # for decoding of vector tiles in MVT format
message ( STATUS "Found Protobuf: ${Protobuf_LIBRARIES}" )
if ( NOT Protobuf_PROTOC_EXECUTABLE )
message ( SEND_ERROR "Protobuf library's 'protoc' tool was not found!" )
endif ( )
find_package ( ZLIB REQUIRED ) # for decompression of vector tiles in MBTiles file
message ( STATUS "Found zlib: ${ZLIB_LIBRARIES}" )
2020-03-25 13:27:11 +01:00
2017-06-02 21:39:44 +02:00
# optional
2020-11-11 11:15:34 +01:00
if ( WITH_POSTGRESQL )
find_package ( Postgres ) # PostgreSQL provider
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( NOT WITH_INTERNAL_MDAL )
find_package ( MDAL REQUIRED ) # MDAL provider
endif ( )
2018-04-06 16:11:50 +02:00
2020-11-24 00:18:51 +01:00
if ( NOT WITH_INTERNAL_POLY2TRI )
find_package ( Poly2Tri REQUIRED )
endif ( )
2021-05-07 14:22:20 +10:00
if ( WITH_SPATIALITE )
find_package ( SpatiaLite REQUIRED )
set ( HAVE_SPATIALITE TRUE )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( NOT PROJ_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND )
message ( SEND_ERROR "Some dependencies were not found! Proj: ${PROJ_FOUND}, Geos: ${GEOS_FOUND}, GDAL: ${GDAL_FOUND}" )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( POSTGRES_FOUND )
2017-06-02 21:39:44 +02:00
# following variable is used in qgsconfig.h
2020-11-11 11:15:34 +01:00
set ( HAVE_POSTGRESQL TRUE )
endif ( )
set ( WITH_QTWEBKIT TRUE CACHE BOOL "Enable QtWebkit support" )
if ( WITH_QTWEBKIT )
add_definitions ( -DWITH_QTWEBKIT )
message ( STATUS "Qt WebKit support enabled" )
else ( )
message ( STATUS "Qt WebKit support DISABLED." )
endif ( )
if ( WITH_EPT ) # EPT provider
find_package ( ZSTD ) # for decompression of point clouds
2020-11-12 07:19:06 +10:00
if ( NOT ZSTD_FOUND )
message ( FATAL_ERROR "ZSTD not found - EPT provider cannot be built" )
endif ( )
2020-11-11 11:15:34 +01:00
find_package ( LazPerf ) # for decompression of point clouds
if ( NOT LazPerf_FOUND )
message ( STATUS "Using embedded laz-perf" )
endif ( )
set ( HAVE_EPT TRUE ) # used in qgsconfig.h
endif ( )
if ( WITH_PDAL )
2020-12-15 14:25:09 +01:00
if ( NOT WITH_EPT )
message ( FATAL_ERROR "PDAL provider cannot be built with EPT disabled" )
endif ( )
2020-11-11 11:15:34 +01:00
find_package ( PDAL ) # PDAL provider
endif ( )
if ( PDAL_FOUND )
set ( HAVE_PDAL TRUE ) # used in qgsconfig.h
endif ( )
2020-11-03 14:05:57 +01:00
2017-06-02 21:39:44 +02:00
#############################################################
2021-03-22 12:44:38 +10:00
# search for Qt
2021-03-22 12:45:49 +10:00
set ( WITH_QT6 FALSE CACHE BOOL "Enable (broken, experimental) Qt6 support" )
2021-03-22 12:44:38 +10:00
if ( WITH_QT6 )
set ( QT_MIN_VERSION 6.0.0 )
2021-03-22 13:11:29 +10:00
set ( QT_VERSION_BASE "Qt6" )
2021-03-22 12:44:38 +10:00
else ( )
set ( QT_MIN_VERSION 5.12.0 )
2021-05-13 07:32:03 +02:00
set ( QT_VERSION_BASE "Qt5" )
2021-03-22 12:44:38 +10:00
endif ( )
2018-10-10 18:05:45 +02:00
# Use Qt5SerialPort optionally for GPS
2020-11-11 11:15:34 +01:00
set ( WITH_QT5SERIALPORT TRUE CACHE BOOL "Determines whether Qt5SerialPort should be tried for GPS positioning" )
if ( WITH_QT5SERIALPORT )
2021-03-22 13:11:29 +10:00
find_package ( ${ QT_VERSION_BASE } COMPONENTS SerialPort REQUIRED )
2018-10-10 18:05:45 +02:00
# following variable is used in qgsconfig.h
2020-11-11 11:15:34 +01:00
set ( HAVE_QT5SERIALPORT TRUE )
endif ( )
2021-03-22 13:11:29 +10:00
find_package ( ${ QT_VERSION_BASE } COMPONENTS Core Gui Widgets Network Xml Svg Concurrent Test UiTools Sql REQUIRED )
2021-03-23 22:07:15 +01:00
if ( WITH_QT6 )
find_package ( ${ QT_VERSION_BASE } COMPONENTS Core5Compat REQUIRED )
else ( )
# TODO only available starting from Qt 6.2
find_package ( ${ QT_VERSION_BASE } COMPONENTS Positioning )
endif ( )
2020-11-11 11:15:34 +01:00
if ( NOT IOS )
2021-03-22 13:11:29 +10:00
find_package ( ${ QT_VERSION_BASE } COMPONENTS PrintSupport REQUIRED )
2020-11-11 11:15:34 +01:00
else ( )
add_definitions ( -DQT_NO_PRINTER )
endif ( )
2021-03-22 12:44:38 +10:00
if ( WITH_QTWEBKIT AND NOT WITH_QT6 )
2020-11-11 11:15:34 +01:00
find_package ( Qt5WebKit REQUIRED )
find_package ( Qt5WebKitWidgets REQUIRED )
endif ( )
if ( WITH_3D )
2021-03-22 13:11:29 +10:00
find_package ( ${ QT_VERSION_BASE } COMPONENTS 3DCore 3DRender 3DInput 3DLogic 3DExtras REQUIRED )
2020-11-11 11:15:34 +01:00
set ( HAVE_3D TRUE ) # used in qgsconfig.h
endif ( )
if ( APPLE )
2021-03-22 13:11:29 +10:00
find_package ( ${ QT_VERSION_BASE } COMPONENTS MacExtras REQUIRED )
2020-11-11 11:15:34 +01:00
endif ( )
2020-02-08 12:04:24 +10:00
# get the Qt plugins directory
2021-03-22 13:11:29 +10:00
get_target_property ( QMAKE_EXECUTABLE ${ QT_VERSION_BASE } ::qmake LOCATION )
2021-03-22 12:44:38 +10:00
2020-08-20 15:35:41 +02:00
EXEC_PROGRAM ( ${ QMAKE_EXECUTABLE } ARGS "-query QT_INSTALL_PLUGINS" RETURN_VALUE return_code OUTPUT_VARIABLE DEFAULT_QT_PLUGINS_DIR )
2020-11-11 11:15:34 +01:00
set ( QT_PLUGINS_DIR ${ DEFAULT_QT_PLUGINS_DIR } CACHE STRING "Path to installation directory for Qt Plugins. Defaults to Qt native plugin directory" )
2020-02-08 12:04:24 +10:00
2021-03-22 12:44:38 +10:00
if ( WITH_QT6 )
message ( STATUS "Found Qt version: ${Qt6Core_VERSION_STRING}" )
else ( )
message ( STATUS "Found Qt version: ${Qt5Core_VERSION_STRING}" )
endif ( )
2020-11-11 11:15:34 +01:00
if ( WITH_QUICK )
2021-03-22 13:11:29 +10:00
find_package ( ${ QT_VERSION_BASE } COMPONENTS Qml Quick REQUIRED )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Android" )
find_package ( ${ QT_VERSION_BASE } COMPONENTS AndroidExtras )
2020-11-11 11:15:34 +01:00
endif ( )
2018-04-26 13:33:48 +02:00
# following variable is used in qgsconfig.h
2020-11-11 11:15:34 +01:00
set ( HAVE_QUICK TRUE )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( WITH_QTWEBKIT )
set ( OPTIONAL_QTWEBKIT ${ Qt5WebKitWidgets_LIBRARIES } )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( WITH_QTMOBILITY )
find_package ( QtMobility 1.1.0 )
endif ( )
2017-06-02 21:39:44 +02:00
# search for QScintilla2 (C++ lib)
2020-11-11 11:15:34 +01:00
if ( WITH_GUI )
find_package ( QScintilla REQUIRED )
endif ( )
2017-06-02 21:39:44 +02:00
# Password helper
2021-03-23 22:07:15 +01:00
find_package ( QtKeychain REQUIRED )
# Master password hash and authentication encryption
find_package ( QCA REQUIRED )
# Check for runtime dependency of qca-ossl plugin
# REQUIRED if unit tests are to be run from build directory
if ( NOT MSVC )
include ( QCAMacros )
FIND_QCAOSSL_PLUGIN_CPP ( ENABLE_TESTS )
2020-11-11 11:15:34 +01:00
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( APPLE )
2017-10-18 16:03:40 -06:00
# Libtasn1 is for DER-encoded PKI ASN.1 parsing/extracting workarounds
2020-11-11 11:15:34 +01:00
find_package ( Libtasn1 REQUIRED )
endif ( )
2017-10-18 16:03:40 -06:00
2020-11-11 11:15:34 +01:00
if ( SUPPRESS_QT_WARNINGS )
2017-06-02 21:39:44 +02:00
# Newer versions of UseQt4.cmake include Qt with -isystem automatically
# This can be used to force this behavior on older systems
# Can be removed as soon as Travis-CI updates from precise
2020-11-11 11:15:34 +01:00
include_directories ( SYSTEM ${ QT_INCLUDE_DIR } )
endif ( )
2017-06-02 21:39:44 +02:00
# Disable automatic conversion from QString to ASCII 8-bit strings (char *)
# (Keeps code compatible with Qt/Mac/64bit)
2020-11-11 11:15:34 +01:00
add_definitions ( -DQT_NO_CAST_TO_ASCII )
endif ( )
2014-04-25 10:26:43 +02:00
2020-11-11 11:15:34 +01:00
set ( CMAKE_AUTOMOC ON )
2019-11-03 14:19:20 +01:00
2011-05-06 16:39:45 +02:00
# build our version of astyle
2020-11-11 11:15:34 +01:00
set ( WITH_ASTYLE FALSE CACHE BOOL "If you plan to contribute you should reindent with scripts/prepare_commit.sh (using 'our' astyle)" )
2011-05-06 16:39:45 +02:00
2018-04-26 13:33:48 +02:00
# QML
2020-11-11 11:15:34 +01:00
set ( QML_IMPORT_PATH "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" CACHE PATH "QML directory for QML autocomplete" )
2018-04-26 13:33:48 +02:00
2017-06-02 21:39:44 +02:00
#############################################################
# testing
2008-08-23 21:37:31 +00:00
# whether unit tests should be build
2020-11-11 11:15:34 +01:00
set ( ENABLE_TESTS TRUE CACHE BOOL "Build unit tests?" )
if ( ENABLE_TESTS )
2021-02-01 11:12:08 +01:00
set ( PUSH_TO_CDASH FALSE CACHE BOOL "Determines whether test results should be pushed to CDASH site" )
set ( QT_USE_QTTEST TRUE )
enable_testing ( )
# Adds some testing specific build targets e.g. make Experimental
include ( Dart )
# Additional test configuration options e.g. max upload size of test report
configure_file (
" $ { C M A K E _ S O U R C E _ D I R } / c m a k e _ t e m p l a t e s / C T e s t C u s t o m . c m a k e . i n "
" $ { C M A K E _ B I N A R Y _ D I R } / C T e s t C u s t o m . c m a k e "
I M M E D I A T E @ O N L Y )
2021-02-02 07:41:42 +01:00
if ( PUSH_TO_CDASH )
configure_file (
" $ { C M A K E _ S O U R C E _ D I R } / c m a k e _ t e m p l a t e s / C T e s t C o n f i g . c m a k e . i n "
" $ { C M A K E _ B I N A R Y _ D I R } / C T e s t C o n f i g . c m a k e "
I M M E D I A T E @ O N L Y )
endif ( )
2021-02-01 11:12:08 +01:00
# For server side testing we have no X, we can use xvfb as a fake x
# sudo apt-get install xvfb
add_custom_target ( check COMMAND xvfb-run --server-args=-screen\ 0\ 1024x768x24 ctest --output-on-failure )
2020-11-11 11:15:34 +01:00
endif ( )
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
2017-06-02 21:39:44 +02:00
# ModelTest
2020-11-11 11:15:34 +01:00
set ( ENABLE_MODELTEST FALSE CACHE BOOL "Enable QT ModelTest (not for production)" )
endif ( )
2008-08-23 21:37:31 +00:00
2015-01-14 19:38:21 +11:00
#############################################################
2008-08-23 21:37:31 +00:00
# enable warnings
2020-11-11 11:15:34 +01:00
if ( PEDANTIC )
message ( STATUS "Pedantic compiler settings enabled" )
if ( MSVC )
set ( _warnings "" )
if ( NOT USING_NMAKE AND NOT USING_NINJA )
set ( _warnings "${_warnings} /W4" )
endif ( )
2008-08-23 21:37:31 +00:00
# disable warnings
2020-11-11 11:15:34 +01:00
set ( _warnings "${_warnings} /wd4091 " ) # 'typedef': ignored on left of '' when no variable is declared (occurs in MS DbgHelp.h header)
set ( _warnings "${_warnings} /wd4100 " ) # unused formal parameters
set ( _warnings "${_warnings} /wd4127 " ) # constant conditional expressions (used in Qt template classes)
set ( _warnings "${_warnings} /wd4190 " ) # 'identifier' has C-linkage specified, but returns UDT 'identifier2' which is incompatible with C
set ( _warnings "${_warnings} /wd4231 " ) # nonstandard extension used : 'identifier' before template explicit instantiation (used in Qt template classes)
set ( _warnings "${_warnings} /wd4244 " ) # conversion from '...' to '...' possible loss of data
set ( _warnings "${_warnings} /wd4251 " ) # needs to have dll-interface to be used by clients of class (occurs in Qt template classes)
set ( _warnings "${_warnings} /wd4267 " ) # 'argument': conversion from 'size_t' to 'int', possible loss of data
set ( _warnings "${_warnings} /wd4275 " ) # non dll-interface class '...' used as base for dll-interface class '...'
set ( _warnings "${_warnings} /wd4290 " ) # c++ exception specification ignored except to indicate a function is not __declspec(nothrow) (occurs in sip generated bindings)
set ( _warnings "${_warnings} /wd4456 " ) # declaration of '...' hides previous local declaration
set ( _warnings "${_warnings} /wd4457 " ) # declaration of '...' hides a function parameter
set ( _warnings "${_warnings} /wd4458 " ) # declaration of '...' hides class member
set ( _warnings "${_warnings} /wd4505 " ) # unreferenced local function has been removed (QgsRasterDataProvider::extent)
set ( _warnings "${_warnings} /wd4510 " ) # default constructor could not be generated (sqlite3_index_info, QMap)
set ( _warnings "${_warnings} /wd4512 " ) # assignment operator could not be generated (sqlite3_index_info)
set ( _warnings "${_warnings} /wd4610 " ) # user defined constructor required (sqlite3_index_info)
set ( _warnings "${_warnings} /wd4706 " ) # assignment within conditional expression (pal)
set ( _warnings "${_warnings} /wd4714 " ) # function '...' marked as __forceinline not inlined (QString::toLower/toUpper/trimmed)
set ( _warnings "${_warnings} /wd4800 " ) # 'int' : forcing value to bool 'true' or 'false' (performance warning)
set ( _warnings "${_warnings} /wd4996 " ) # '...': was declared deprecated (unfortunately triggered when implementing deprecated interfaces even when it is deprecated too)
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_warnings}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_warnings}" )
else ( )
2013-02-03 21:20:26 +01:00
# add warnings via flags (not as definitions as on Mac -Wall can not be overridden per language )
2020-11-11 11:15:34 +01:00
set ( _warnings "-Wall -Wextra -Wno-long-long -Wformat-security -Wno-strict-aliasing" )
2019-09-23 09:17:13 +10:00
2020-11-11 11:15:34 +01:00
set ( WERROR FALSE CACHE BOOL "Treat build warnings as errors." )
if ( WERROR )
set ( _warnings "${_warnings} -Werror" )
endif ( )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_warnings}" )
2019-09-23 09:17:13 +10:00
# c++ only warnings
2020-11-11 11:15:34 +01:00
set ( _warnings "${_warnings} -Wnon-virtual-dtor" )
2020-02-13 23:32:01 +01:00
2019-09-23 09:17:13 +10:00
# unavoidable - we can't avoid these, as older, supported compilers do not support removing the redundant move
2020-11-11 11:15:34 +01:00
set ( _warnings "${_warnings} -Wno-redundant-move" )
2019-09-23 09:17:13 +10:00
2020-11-11 11:15:34 +01:00
if ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.9.999 )
2019-09-23 09:17:13 +10:00
# heaps of these thrown by Qt headers at the moment (sep 2019)
2020-11-11 11:15:34 +01:00
set ( _warnings "${_warnings} -Wno-deprecated-copy" )
endif ( )
2019-09-23 09:17:13 +10:00
2020-11-11 11:15:34 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_warnings}" )
2013-02-03 21:20:26 +01:00
2008-08-23 21:37:31 +00:00
# Qt produces lots of warnings with strict aliasing (as of Qt 4.4.0 & GCC 4.3)
2011-10-11 18:10:31 +00:00
# There are redundant declarations in Qt and GDAL
2020-11-11 11:15:34 +01:00
# add_definitions( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )
2013-02-02 17:06:22 +01:00
2020-11-11 11:15:34 +01:00
if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-overloaded-virtual -Wimplicit-fallthrough" )
endif ( )
2013-09-24 10:39:54 -06:00
# add any extra CXXFLAGS flags set by user. can be -D CXX_EXTRA_FLAGS or environment variable
# command line -D option overrides environment variable
# e.g. useful for suppressing transient upstream warnings in dependencies, like Qt
2020-11-11 11:15:34 +01:00
set ( CXX_EXTRA_FLAGS "" CACHE STRING "Additional appended CXXFLAGS" )
if ( "${CXX_EXTRA_FLAGS}" STREQUAL "" AND DEFINED $ENV{ CXX_EXTRA_FLAGS } )
set ( CXX_EXTRA_FLAGS "$ENV{CXX_EXTRA_FLAGS}" )
endif ( )
if ( NOT "${CXX_EXTRA_FLAGS}" STREQUAL "" )
message ( STATUS "Appending CXX_EXTRA_FLAGS" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_EXTRA_FLAGS}" )
endif ( )
endif ( )
endif ( )
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments" )
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Qunused-arguments" )
set ( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Qunused-arguments" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Qunused-arguments" )
endif ( )
if ( CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)" )
2011-01-28 16:59:02 +00:00
# spatialite crashes on ppc - see bugs.debian.org/603986
2020-11-11 11:15:34 +01:00
add_definitions ( -fno-strict-aliasing )
endif ( )
if ( CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo )
message ( STATUS "Debug output enabled" )
set ( QGISDEBUG TRUE )
else ( )
set ( QGISDEBUG FALSE )
endif ( )
if ( MSVC )
2021-04-22 00:06:40 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /std:c++17" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /std:c++17" )
2020-11-11 11:15:34 +01:00
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
2012-08-18 19:43:53 +02:00
# disable macros that offend std::numeric_limits<T>::min()/max()
2020-11-11 11:15:34 +01:00
add_definitions ( -DNOMINMAX )
endif ( )
2012-08-13 17:12:28 +02:00
2020-02-07 09:54:53 +10:00
# Prevent build when Qt api deprecated before this Qt version is used:
2020-11-11 11:15:34 +01:00
add_definitions ( -DQT_DEPRECATED_WARNINGS )
2020-02-07 09:54:53 +10:00
# Unfortunately Qwt uses deprecated QString::null in headers, preventing this being raised above 5.8
2020-11-11 11:15:34 +01:00
add_definitions ( -DQT_DISABLE_DEPRECATED_BEFORE=0x050800 )
2020-02-07 09:54:53 +10:00
2020-10-11 03:12:56 +02:00
# For fast string concatenation
2020-11-11 11:15:34 +01:00
add_definitions ( -DQT_USE_QSTRINGBUILDER )
2021-05-16 11:37:01 +07:00
set ( WITH_GSL TRUE CACHE BOOL "Determines whether GSL library should be used" )
if ( WITH_ANALYSIS AND WITH_GSL )
2020-11-11 11:15:34 +01:00
find_package ( GSL REQUIRED )
2021-05-16 11:37:01 +07:00
set ( HAVE_GSL TRUE )
if ( WITH_GEOREFERENCER )
set ( HAVE_GEOREFERENCER TRUE )
endif ( )
2020-11-11 11:15:34 +01:00
endif ( )
if ( ENABLE_COVERAGE )
include ( "cmake/modules/coverage/CodeCoverage.cmake" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage" )
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage" )
set ( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage --coverage" )
2014-12-01 20:33:03 +11:00
SETUP_TARGET_FOR_COVERAGE ( qgis_coverage ctest coverage )
2020-11-11 11:15:34 +01:00
endif ( )
2014-12-01 20:33:03 +11:00
2008-08-23 21:37:31 +00:00
#############################################################
# platform specific stuff
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
if ( WIN32 )
set ( DEFAULT_LIB_SUBDIR lib )
set ( DEFAULT_LIBEXEC_SUBDIR . )
set ( DEFAULT_DATA_SUBDIR . )
set ( DEFAULT_PLUGIN_SUBDIR plugins )
set ( DEFAULT_INCLUDE_SUBDIR include )
set ( DEFAULT_QML_SUBDIR qml )
set ( DEFAULT_SERVER_MODULE_SUBDIR server )
if ( MSVC )
set ( DEFAULT_BIN_SUBDIR bin )
set ( DEFAULT_CGIBIN_SUBDIR bin )
2017-06-02 21:39:44 +02:00
# put all the build products into a single directory
# under build (doesn't affect install target) to make for
# easier debugging.
# Turn on defines for non standard maths stuff
2020-11-11 11:15:34 +01:00
add_definitions ( -D_USE_MATH_DEFINES )
2017-06-02 21:39:44 +02:00
# Turn off deprecation warnings
2020-11-11 11:15:34 +01:00
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
add_definitions ( -D_CRT_NONSTDC_NO_WARNINGS )
if ( INSTALL_DEPS )
install ( DIRECTORY ${ INSTALL_DEPS } DESTINATION . )
endif ( )
else ( )
set ( DEFAULT_BIN_SUBDIR . )
set ( DEFAULT_CGIBIN_SUBDIR . )
endif ( )
else ( )
2021-01-14 10:11:07 +01:00
2021-01-14 14:37:37 +10:00
if ( APPLE )
set ( QGIS_MACAPP_FRAMEWORK TRUE CACHE BOOL "Build as a framework on OSX" )
endif ( )
2021-01-14 10:11:07 +01:00
2021-01-14 14:37:37 +10:00
if ( APPLE AND QGIS_MACAPP_FRAMEWORK )
2020-11-11 11:15:34 +01:00
if ( POLICY CMP0042 ) # in CMake 3.0.0+
set ( CMAKE_MACOSX_RPATH OFF ) # otherwise ON by default
endif ( )
if ( POLICY CMP0068 ) # in CMake 3.9.0+
2017-09-13 15:20:20 -06:00
cmake_policy ( SET CMP0068 NEW )
2020-11-11 11:15:34 +01:00
endif ( )
2017-06-02 21:39:44 +02:00
# for Mac OS X, everything is put inside an application bundle
# save the root install prefix for the app later
2020-11-11 11:15:34 +01:00
set ( QGIS_INSTALL_PREFIX ${ CMAKE_INSTALL_PREFIX } )
set ( QGIS_MACAPP_PREFIX ${ CMAKE_INSTALL_PREFIX } / ${ QGIS_APP_NAME } .app/Contents )
2017-06-02 21:39:44 +02:00
# common prefix for components, let cmake handle it
2020-11-11 11:15:34 +01:00
set ( CMAKE_INSTALL_PREFIX ${ QGIS_MACAPP_PREFIX } /MacOS )
2020-04-05 10:51:00 +02:00
# 5 bundling levels, each includes previous
# -1 nothing
# 0 fixup the library paths for all QGIS libraries with @loader_path
2017-06-02 21:39:44 +02:00
# 1 Qt frameworks
# 2 non-system libraries, "standard"
# 3 non-system frameworks, "standalone"
2020-11-11 11:15:34 +01:00
set ( QGIS_MACAPP_BUNDLE 1 CACHE STRING "What to bundle into app package" )
set ( QGIS_MACAPP_BUNDLE_USER "" CACHE STRING "Path to user bundling script" )
set ( QGIS_MACAPP_INSTALL_DEV FALSE CACHE BOOL "Install developer frameworks" )
set ( QGIS_MACAPP_DEV_PREFIX "/Library/Frameworks" CACHE STRING "Path to install developer frameworks" )
set ( DEFAULT_BIN_SUBDIR bin )
set ( QGIS_BIN_SUBDIR_REV .. )
set ( DEFAULT_CGIBIN_SUBDIR fcgi-bin )
set ( QGIS_CGIBIN_SUBDIR_REV .. )
set ( DEFAULT_LIB_SUBDIR lib )
set ( QGIS_LIB_SUBDIR_REV .. )
set ( QGIS_FW_SUBDIR ../Frameworks )
set ( QGIS_FW_SUBDIR_REV ../MacOS )
set ( DEFAULT_DATA_SUBDIR ../Resources )
set ( QGIS_DATA_SUBDIR_REV ../MacOS )
set ( DEFAULT_LIBEXEC_SUBDIR lib/qgis )
set ( QGIS_LIBEXEC_SUBDIR_REV ../.. )
set ( DEFAULT_PLUGIN_SUBDIR ../PlugIns/qgis )
set ( QGIS_PLUGIN_SUBDIR_REV ../../MacOS )
set ( DEFAULT_INCLUDE_SUBDIR include/qgis )
set ( DEFAULT_QML_SUBDIR qml )
2017-06-02 21:39:44 +02:00
# Set server moodules path to DEFAULT_LIBEXEC_SUBDIR+'/server'
2020-11-11 11:15:34 +01:00
set ( DEFAULT_SERVER_MODULE_SUBDIR ${ DEFAULT_LIBEXEC_SUBDIR } /server )
2017-06-02 21:39:44 +02:00
# path for framework references when running from build directory
# changed later to reference in-app resources upon install
2020-11-11 11:15:34 +01:00
set ( CMAKE_INSTALL_NAME_DIR ${ CMAKE_BINARY_DIR } /output/lib )
2017-06-02 21:39:44 +02:00
# recent cmakes force SDKs, recent SDKs don't have user symlinks
# need to find non-system frameworks
# cmake bug #0007250 - CMAKE_SHARED_LINKER_FLAGS ignored when creating
# a framework, so these need to be manually handled with LINK_FLAGS options
2020-11-11 11:15:34 +01:00
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -F/Library/Frameworks" )
set ( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -F/Library/Frameworks" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -F/Library/Frameworks" )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
else ( )
2017-06-02 21:39:44 +02:00
# UNIX
2020-11-11 11:15:34 +01:00
set ( DEFAULT_BIN_SUBDIR bin )
set ( DEFAULT_CGIBIN_SUBDIR bin )
set ( DEFAULT_LIB_SUBDIR lib ${ LIB_SUFFIX } )
set ( DEFAULT_DATA_SUBDIR share/qgis )
set ( DEFAULT_LIBEXEC_SUBDIR lib ${ LIB_SUFFIX } /qgis )
set ( DEFAULT_PLUGIN_SUBDIR lib ${ LIB_SUFFIX } /qgis/plugins )
set ( DEFAULT_INCLUDE_SUBDIR include/qgis )
set ( DEFAULT_QML_SUBDIR qml )
set ( DEFAULT_SERVER_MODULE_SUBDIR ${ DEFAULT_LIBEXEC_SUBDIR } /server )
2021-01-14 10:11:07 +01:00
2021-01-14 14:37:37 +10:00
# QGIS_MACAPP_FRAMEWORK=FALSE
if ( APPLE )
set ( QGIS_MACAPP_BUNDLE -1 )
set ( CMAKE_FRAMEWORK FALSE )
set ( QGIS_INSTALL_PREFIX ${ CMAKE_INSTALL_PREFIX } )
endif ( )
2020-11-11 11:15:34 +01:00
endif ( )
endif ( )
if ( ANDROID )
set ( DEFAULT_PLUGIN_SUBDIR lib )
set ( DEFAULT_DATA_SUBDIR files/share )
2017-06-02 21:39:44 +02:00
string ( REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME>" "" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}" )
2020-11-11 11:15:34 +01:00
endif ( )
2017-06-02 21:39:44 +02:00
#assume we have escaped compiler directives
#eventually we want to change this to new
#since we don't need to jump through so many
#hoops to escape compiler directives then
2020-11-11 11:15:34 +01:00
if ( COMMAND cmake_policy )
2017-06-02 21:39:44 +02:00
cmake_policy ( SET CMP0003 NEW )
2020-11-11 11:15:34 +01:00
if ( NOT "${CMAKE_VERSION}" VERSION_LESS "3.3" )
2017-06-02 21:39:44 +02:00
cmake_policy ( SET CMP0063 NEW )
2020-11-11 11:15:34 +01:00
endif ( )
if ( MSVC )
2017-06-02 21:39:44 +02:00
cmake_policy ( SET CMP0020 NEW )
2020-11-11 11:15:34 +01:00
endif ( )
endif ( )
2017-06-02 21:39:44 +02:00
2018-01-30 12:41:22 +01:00
if ( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux" )
2020-11-11 11:15:34 +01:00
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
set ( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined" )
2018-01-30 12:41:22 +01:00
endif ( ) #"${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
set ( CMAKE_CXX_VISIBILITY_PRESET hidden )
include ( GenerateExportHeader )
2019-11-04 18:35:26 +01:00
2020-11-11 11:15:34 +01:00
set ( ADD_CLAZY_CHECKS ${ DEFAULT_MANUAL_SUBDIR } CACHE STRING "Add default set of clazy checks which should not raise any warnings" )
mark_as_advanced ( ADD_CLAZY_CHECKS )
if ( ADD_CLAZY_CHECKS )
set ( CMAKE_CXX_BASE_FLAGS "${CMAKE_CXX_FLAGS}" )
set ( CLAZY_BASE_CHECKS "connect-3arg-lambda,lambda-unique-connection,empty-qstringliteral,fully-qualified-moc-types,lambda-in-connect,lowercase-qml-type-name,qcolor-from-literal,qfileinfo-exists,qmap-with-pointer-key,unused-non-trivial-variable,overridden-signal,qdeleteall,qstring-left,skipped-base-method,missing-qobject-macro,isempty-vs-count" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_BASE_FLAGS} -Xclang -plugin-arg-clazy -Xclang ${CLAZY_BASE_CHECKS}" )
endif ( )
endif ( )
2016-06-11 10:33:59 +02:00
2008-08-23 21:37:31 +00:00
#############################################################
# user-changeable settings which can be used to customize
# layout of QGIS installation
# (default values are platform-specific)
2020-11-11 11:15:34 +01:00
set ( QGIS_BIN_SUBDIR ${ DEFAULT_BIN_SUBDIR } CACHE STRING "Subdirectory where executables will be installed" )
set ( QGIS_CGIBIN_SUBDIR ${ DEFAULT_CGIBIN_SUBDIR } CACHE STRING "Subdirectory where CGI executables will be installed" )
set ( QGIS_LIB_SUBDIR ${ DEFAULT_LIB_SUBDIR } CACHE STRING "Subdirectory where libraries will be installed" )
set ( QGIS_LIBEXEC_SUBDIR ${ DEFAULT_LIBEXEC_SUBDIR } CACHE STRING "Subdirectory where private executables will be installed" )
set ( QGIS_DATA_SUBDIR ${ DEFAULT_DATA_SUBDIR } CACHE STRING "Subdirectory where QGIS data will be installed" )
set ( QGIS_PLUGIN_SUBDIR ${ DEFAULT_PLUGIN_SUBDIR } CACHE STRING "Subdirectory where plugins will be installed" )
set ( QGIS_INCLUDE_SUBDIR ${ DEFAULT_INCLUDE_SUBDIR } CACHE STRING "Subdirectory where header files will be installed" )
set ( QGIS_QML_SUBDIR ${ DEFAULT_QML_SUBDIR } CACHE STRING "Subdirectory where qml files/libraries will be installed" )
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
set ( QGIS_SERVER_MODULE_SUBDIR ${ DEFAULT_SERVER_MODULE_SUBDIR } CACHE STRING "Subdirectory where server modules will be installed" )
2016-12-14 19:17:57 +01:00
2008-08-23 21:37:31 +00:00
# mark *_SUBDIR variables as advanced as this is not something
# that an average user would use
2020-11-11 11:15:34 +01:00
mark_as_advanced ( QGIS_BIN_SUBDIR QGIS_CGIBIN_SUBDIR QGIS_LIB_SUBDIR QGIS_LIBEXEC_SUBDIR QGIS_DATA_SUBDIR QGIS_PLUGIN_SUBDIR QGIS_INCLUDE_SUBDIR )
2008-08-23 21:37:31 +00:00
# full paths for the installation
2020-11-11 11:15:34 +01:00
set ( QGIS_BIN_DIR ${ QGIS_BIN_SUBDIR } )
set ( QGIS_CGIBIN_DIR ${ QGIS_CGIBIN_SUBDIR } )
set ( QGIS_LIB_DIR ${ QGIS_LIB_SUBDIR } )
set ( QGIS_LIBEXEC_DIR ${ QGIS_LIBEXEC_SUBDIR } )
set ( QGIS_DATA_DIR ${ QGIS_DATA_SUBDIR } )
set ( QGIS_PLUGIN_DIR ${ QGIS_PLUGIN_SUBDIR } )
set ( QGIS_INCLUDE_DIR ${ QGIS_INCLUDE_SUBDIR } )
set ( QGIS_QML_DIR ${ QGIS_QML_SUBDIR } )
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
set ( QGIS_SERVER_MODULE_DIR ${ QGIS_SERVER_MODULE_SUBDIR } )
2016-12-14 19:17:57 +01:00
2011-07-25 19:12:40 +02:00
# set the default locations where the targets (executables, libraries) will land when compiled
# this is to allow running qgis from the source tree without having to actually do a "make install"
2020-11-11 11:15:34 +01:00
set ( QGIS_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } /output )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ QGIS_OUTPUT_DIRECTORY } / ${ QGIS_BIN_SUBDIR } )
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ QGIS_OUTPUT_DIRECTORY } / ${ QGIS_LIB_SUBDIR } )
2011-07-25 19:12:40 +02:00
# write a marker with source directory path into the output's bin directory
# if run from the build directory QGIS will detect it and alter the paths
2020-11-11 11:15:34 +01:00
file ( WRITE ${ QGIS_OUTPUT_DIRECTORY } / ${ QGIS_BIN_SUBDIR } /qgisbuildpath.txt "${CMAKE_SOURCE_DIR}\n${QGIS_OUTPUT_DIRECTORY}" )
2011-07-25 19:12:40 +02:00
2008-08-23 21:37:31 +00:00
# manual page - makes sense only on unix systems
2020-11-11 11:15:34 +01:00
if ( UNIX AND NOT APPLE )
set ( DEFAULT_MANUAL_SUBDIR man )
set ( QGIS_MANUAL_SUBDIR ${ DEFAULT_MANUAL_SUBDIR } CACHE STRING "Subdirectory where manual files will be installed" )
mark_as_advanced ( QGIS_MANUAL_SUBDIR )
set ( QGIS_MANUAL_DIR ${ CMAKE_INSTALL_PREFIX } / ${ QGIS_MANUAL_SUBDIR } )
endif ( )
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
set ( DISABLE_DEPRECATED FALSE CACHE BOOL "If set to true, it will disable deprecated functionality to prepare for the next generation of QGIS" )
if ( DISABLE_DEPRECATED )
add_definitions ( -DQGIS_DISABLE_DEPRECATED )
endif ( )
2016-04-19 15:11:26 +02:00
2021-02-02 09:21:15 +10:00
# whether to install required system libs in the output package
set ( QGIS_INSTALL_SYS_LIBS TRUE CACHE BOOL "If set to TRUE install all required system libs in the output package" )
2014-05-07 16:41:59 +02:00
2015-09-20 00:13:37 +02:00
#############################################################
2021-03-28 21:49:40 +02:00
# Python
2015-09-20 00:13:37 +02:00
2021-02-24 09:25:34 +10:00
set ( MIN_PYTHON_VERSION "3.7" )
2021-03-28 21:49:40 +02:00
set ( Python_FIND_FRAMEWORK "LAST" )
2021-01-19 16:24:56 +01:00
2021-05-14 10:42:26 +02:00
if ( WITH_BINDINGS )
find_package ( Python ${ MIN_PYTHON_VERSION } REQUIRED COMPONENTS Interpreter Development )
else ( )
find_package ( Python ${ MIN_PYTHON_VERSION } REQUIRED COMPONENTS Interpreter )
endif ( )
2021-03-28 21:49:40 +02:00
message ( "-- Found Python executable: ${Python_EXECUTABLE} (version ${Python_VERSION})" )
message ( "-- Python library: ${Python_LIBRARIES}" )
message ( "-- Python site-packages: ${Python_SITEARCH}" )
2010-01-16 11:04:41 +00:00
2021-03-22 13:11:29 +10:00
if ( WITH_CORE AND WITH_BINDINGS AND NOT WITH_QT6 )
2021-05-13 07:32:03 +02:00
set ( PYTHON_OUTPUT_DIRECTORY ${ QGIS_OUTPUT_DIRECTORY } /python )
set ( QGIS_PYTHON_OUTPUT_DIRECTORY ${ PYTHON_OUTPUT_DIRECTORY } /qgis )
2016-09-20 09:45:28 +10:00
# python support: check for interpreter, sip, pyqt5
2020-11-11 11:15:34 +01:00
find_package ( PyQt5 REQUIRED )
set ( PYQT_SIP_FLAGS ${ PYQT5_SIP_FLAGS } )
set ( PYQT_SIP_DIR ${ PYQT5_SIP_DIR } )
separate_arguments ( PYQT_SIP_FLAGS ) # convert space separated values to a list
2015-11-08 15:24:28 +00:00
2020-11-11 11:15:34 +01:00
find_package ( SIP REQUIRED )
find_package ( Qsci REQUIRED )
include ( PythonMacros )
include ( PyQtMacros )
include ( SIPMacros )
2010-01-16 11:04:41 +00:00
2020-11-11 11:15:34 +01:00
set ( SIP_INCLUDES ${ PYQT_SIP_DIR } ${ CMAKE_SOURCE_DIR } /python )
2021-05-18 19:15:22 +10:00
set ( SIP_CONCAT_PARTS 13 )
2010-01-16 11:04:41 +00:00
2020-11-11 11:15:34 +01:00
if ( NOT BINDINGS_GLOBAL_INSTALL )
2021-03-28 21:49:40 +02:00
set ( Python_SITEARCH ${ QGIS_DATA_DIR } /python )
2020-11-11 11:15:34 +01:00
endif ( )
2010-01-16 11:04:41 +00:00
2020-11-11 11:15:34 +01:00
if ( WITH_CUSTOM_WIDGETS )
set ( PYUIC_WIDGET_PLUGIN_DIRECTORY ${ PYQT5_MOD_DIR } /uic/widget-plugins/ )
endif ( )
endif ( )
2010-01-16 11:04:41 +00:00
2021-03-28 21:49:40 +02:00
2008-08-23 21:37:31 +00:00
#############################################################
# create qgsconfig.h
2011-07-04 11:15:40 -05:00
# installed with app target
2020-11-11 11:15:34 +01:00
configure_file ( ${ CMAKE_SOURCE_DIR } /cmake_templates/qgsconfig.h.in ${ CMAKE_BINARY_DIR } /qgsconfig.h )
include_directories ( ${ CMAKE_BINARY_DIR } )
2008-08-23 21:37:31 +00:00
2017-06-02 21:39:44 +02:00
#############################################################
# create qgsversion.h
2020-11-11 11:15:34 +01:00
include ( CreateQgsVersion )
2017-06-02 21:39:44 +02:00
CREATE_QGSVERSION ( )
####################################################
2009-04-11 10:16:16 +00:00
# Added by Jef to prevent python core and gui libs linking to other qgisCore and qgisGui libs
# that may be in the same install prefix
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
link_directories ( ${ CMAKE_BINARY_DIR } /src/core ${ CMAKE_BINARY_DIR } /src/gui )
endif ( )
2009-04-11 10:16:16 +00:00
2017-02-20 10:37:06 +10:00
####################################################
# clang-tidy
2020-11-11 11:15:34 +01:00
set ( WITH_CLANG_TIDY FALSE CACHE BOOL "Use Clang tidy" )
mark_as_advanced ( WITH_CLANG_TIDY )
if ( WITH_CORE )
if ( WITH_CLANG_TIDY )
find_program (
2017-10-27 14:43:36 +02:00
C L A N G _ T I D Y _ E X E
N A M E S " c l a n g - t i d y "
D O C " P a t h t o c l a n g - t i d y e x e c u t a b l e "
)
2020-11-11 11:15:34 +01:00
if ( NOT CLANG_TIDY_EXE )
message ( STATUS "clang-tidy not found." )
else ( )
message ( STATUS "clang-tidy found: ${CLANG_TIDY_EXE}" )
set ( DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=*,-clang-analyzer-alpha.*,-cppcoreguidelines*,-readability-implicit-bool-cast,-llvm-include-order,-cert-err58-cpp,-modernize-pass-by-value,-google-readability-braces-around-statements,-modernize-use-auto,-modernize-loop-convert,-readability-else-after-return,-readability-braces-around-statements,-google-runtime-references,-readability-named-parameter,-google-default-arguments,-google-readability-todo,-readability-inconsistent-declaration-parameter-name,-cert-flp30-c,-google-readability-casting,-clang-analyzer-security.FloatLoopCounter,-google-runtime-int,-modernize-use-using,-google-explicit-constructor,-google-build-using-namespace,-cert-err34-c,-clang-analyzer-core.CallAndMessage,-google-readability-function-size,-modernize-make-shared,-modernize-use-nullptr,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-core.NonNullParamChecker,performance-unnecessary-copy-initialization,-readability-simplify-boolean-expr,-modernize-raw-string-literal,-performance-unnecessary-copy-initialization" )
endif ( )
endif ( )
endif ( )
2008-08-23 21:37:31 +00:00
#############################################################
# process subdirs
2012-09-04 20:31:59 +02:00
#create a variable to specify where our test data is
#so that unit tests can use TEST_DATA_DIR to locate
#the test data. See CMakeLists in test dirs for more info
#TEST_DATA_DIR is also used by QgsRenderChecker currently in core
2020-11-11 11:15:34 +01:00
set ( TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/testdata" )
2012-09-04 20:31:59 +02:00
2020-11-11 11:15:34 +01:00
add_subdirectory ( doc )
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
add_subdirectory ( src )
add_subdirectory ( images )
add_subdirectory ( resources )
add_subdirectory ( i18n )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( WITH_BINDINGS )
add_subdirectory ( python )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( APPLE )
2017-06-02 21:39:44 +02:00
# must be last for install, so install_name_tool can do its work
2020-11-11 11:15:34 +01:00
add_subdirectory ( mac )
2017-06-02 21:39:44 +02:00
# allow QGIS to be run directly from build directory and to run unit tests
2020-11-11 11:15:34 +01:00
execute_process ( COMMAND /bin/mkdir -p "${QGIS_OUTPUT_DIRECTORY}/lib" )
execute_process (
2017-06-02 21:39:44 +02:00
C O M M A N D / b i n / l n - f s . . / . . / P l u g i n s / q g i s / q g i s g r a s s 6 . f r a m e w o r k l i b /
W O R K I N G _ D I R E C T O R Y " $ { Q G I S _ O U T P U T _ D I R E C T O R Y } "
)
2020-11-11 11:15:34 +01:00
execute_process (
2017-06-02 21:39:44 +02:00
C O M M A N D / b i n / l n - f s . . / . . / P l u g i n s / q g i s / q g i s g r a s s 7 . f r a m e w o r k l i b /
W O R K I N G _ D I R E C T O R Y " $ { Q G I S _ O U T P U T _ D I R E C T O R Y } "
)
2020-11-11 11:15:34 +01:00
endif ( )
2017-06-02 21:39:44 +02:00
# manual page - makes sense only on unix systems
2020-11-11 11:15:34 +01:00
if ( UNIX AND NOT APPLE )
install ( FILES qgis.1 DESTINATION ${ QGIS_MANUAL_DIR } /man1 )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
install ( FILES cmake/FindQGIS.cmake DESTINATION ${ QGIS_DATA_DIR } )
endif ( )
2017-06-02 21:39:44 +02:00
2020-11-11 11:15:34 +01:00
if ( WITH_ASTYLE )
add_subdirectory ( external/astyle )
endif ( )
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
if ( ENABLE_TESTS )
add_subdirectory ( tests )
set ( CTEST_BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/bin" )
message ( STATUS "Ctest Binary Directory set to: ${CTEST_BINARY_DIRECTORY}" )
endif ( )
2008-08-23 21:37:31 +00:00
2012-10-25 22:48:37 -06:00
#############################################################
# Post-install commands
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
add_subdirectory ( postinstall )
endif ( )
2012-10-25 22:48:37 -06:00
2008-08-23 21:37:31 +00:00
#############################################################
# Uninstall stuff see: http://www.vtk.org/Wiki/CMake_FAQ
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
configure_file (
2017-06-02 21:39:44 +02: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 _ t e m p l a t e s / 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 )
2008-08-23 21:37:31 +00:00
2020-11-11 11:15:34 +01:00
add_custom_target ( uninstall
2017-06-02 21:39:44 +02: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 " )
2020-11-11 11:15:34 +01:00
endif ( )
2008-08-23 21:37:31 +00:00
#############################################################
# Enable packaging
2020-11-11 11:15:34 +01:00
if ( WITH_CORE )
2017-06-02 21:39:44 +02:00
# Do not warn about runtime libs when building using VS Express
2020-11-11 11:15:34 +01:00
if ( NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS )
set ( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON )
endif ( )
2021-02-02 09:21:15 +10:00
if ( QGIS_INSTALL_SYS_LIBS )
include ( InstallRequiredSystemLibraries )
endif ( )
2020-11-11 11:15:34 +01:00
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "QGIS" )
set ( CPACK_PACKAGE_VENDOR "Open Source Geospatial Foundation" )
set ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README" )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" )
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "QGIS ${COMPLETE_VERSION}" )
if ( WIN32 AND NOT UNIX )
2017-06-02 21:39:44 +02:00
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backslashes.
2020-11-11 11:15:34 +01:00
set ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/win_build\\\\sidebar.bmp" )
set ( CPACK_NSIS_INSTALLED_ICON_NAME "\\\\qgis.exe" )
set ( CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} QGIS" )
set ( CPACK_NSIS_HELP_LINK "http:\\\\\\\\qgis.org" )
set ( CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\qgis.org" )
set ( CPACK_NSIS_CONTACT "info@qgis.org" )
set ( CPACK_NSIS_MODIFY_PATH ON )
# set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " !include \\\"${CMAKE_SOURCE_DIR}\\\\win_build\\\\extra.nsh\\\"")
else ( )
#set(CPACK_STRIP_FILES "QGIS")
#set(CPACK_SOURCE_STRIP_FILES "")
endif ( )
set ( CPACK_PACKAGE_EXECUTABLES "qgis" "QGIS" )
set ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" )
include ( CPack )
endif ( )
if ( UNIX AND NOT APPLE )
add_subdirectory ( linux )
endif ( )