Warning, /education/marble/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 cmake_minimum_required(VERSION 3.10)
0002 
0003 # Set minimum OS X target
0004 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
0005 
0006 # KDE Application Version, managed by release script
0007 set (RELEASE_SERVICE_VERSION_MAJOR "24")
0008 set (RELEASE_SERVICE_VERSION_MINOR "04")
0009 set (RELEASE_SERVICE_VERSION_MICRO "70")
0010 set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
0011 
0012 project(marble VERSION ${RELEASE_SERVICE_VERSION})
0013 
0014 ####################################################
0015 # CMake Settings
0016 SET(CMAKE_COLOR_MAKEFILE ON)
0017 # SET(CMAKE_SKIP_RPATH ON)
0018 
0019 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
0020 
0021 # Let CMake find the correct library dir instead of
0022 # relying on the obsolete LIB_SUFFIX parameter
0023 include(GNUInstallDirs)
0024 
0025 # Taken from KDECompilerSettings.cmake:
0026 # Pick sensible versions of the C and C++ standards.
0027 # Note that MSVC does not have equivalent flags; the features are either
0028 # supported or they are not.
0029 if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
0030     # We use the C89 standard because that is what is common to all our
0031     # compilers (in particular, MSVC 2010 does not support C99)
0032     set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -std=iso9899:1990")
0033 endif()
0034 set(CMAKE_CXX_STANDARD 17)
0035 # Default to hidden visibility for symbols
0036 set(CMAKE_C_VISIBILITY_PRESET hidden)
0037 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
0038 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
0039 if (POLICY CMP0063)
0040     cmake_policy(SET CMP0063 NEW)
0041 endif()
0042 
0043 # RPATH/RUNPATH settings
0044 if (UNIX)
0045     # Add CMAKE_INSTALL_FULL_LIBDIR to the RPATH to be used when installing,
0046     # but only if it isn't a standard system directory.
0047     list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemLibDir)
0048     list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES      "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemCxxLibDir)
0049     list(FIND CMAKE_C_IMPLICIT_LINK_DIRECTORIES        "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemCLibDir)
0050     if("${isSystemLibDir}" STREQUAL "-1"  AND  "${isSystemCxxLibDir}" STREQUAL "-1"  AND  "${isSystemCLibDir}" STREQUAL "-1")
0051         set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
0052     endif()
0053 
0054     # Add directories which are in the linker search path (but outside the project)
0055     # to the RPATH to be used when installing
0056     set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
0057     # no libs or plugins are designed to be used from the build dir, so directly link with install rpath
0058     set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
0059 endif (UNIX)
0060 
0061 ####################################################
0062 # Where to look first for cmake modules,
0063 # before ${CMAKE_ROOT}/Modules/ is checked
0064 set ( CMAKE_MODULE_PATH
0065      ${CMAKE_SOURCE_DIR}/cmake/modules
0066      ${CMAKE_CURRENT_SOURCE_DIR}
0067      ${CMAKE_CURRENT_SOURCE_DIR}/src
0068      ${CMAKE_CURRENT_SOURCE_DIR}/cmake_find_rules
0069      ${CMAKE_CURRENT_SOURCE_DIR}/cmake_scripts
0070      ${CMAKE_MODULE_PATH}
0071      )
0072 
0073 # add cmake macros
0074 include(GenerateExportHeader)
0075 include( MarbleMacros )
0076 
0077 ####################################################
0078 # Generate the tiles with the tilecreator at compile time
0079 # if this option is set, srtm.jpg will not be installed but the generated tiles instead
0080 option(MOBILE "Create a Marble version optimized for handheld devices")
0081 
0082 ####################################################
0083 # Provide opt-in switch for mobile variant, which is not only useful for Android.
0084 option(BUILD_TOUCH "Build touch-friendly Marble version (on Android this option is bypassed)" OFF)
0085 
0086 ####################################################
0087 # Build a D-Bus interface for the Marble widget
0088 # This is disabled by default for all win32, apple and Android
0089 if(WIN32 OR APPLE OR ANDROID)
0090     option(BUILD_WITH_DBUS "Build the D-Bus interface for the Marble widget" OFF)
0091 else()
0092     option(BUILD_WITH_DBUS "Build the D-Bus interface for the Marble widget" ON)
0093 endif()
0094 
0095 
0096 #######################################################
0097 # Specific options for building for different platforms
0098 
0099 if(ANDROID)
0100    add_definitions(-DANDROID)
0101 endif()
0102 
0103 
0104 #######################################################
0105 # Find Qt dependencies
0106 
0107 find_package(Protobuf)
0108 set_package_properties(Protobuf PROPERTIES TYPE OPTIONAL PURPOSE "Parsing of OSM PBF files.")
0109 
0110 if(ANDROID)
0111     set(REQUIRED_QT_VERSION 5.14.0)
0112    # TODO: still needed with ECM toolchain?
0113    SET(QT_QMAKE_EXECUTABLE "$ENV{Qt5_android}/bin/qmake")
0114 else()
0115     set(REQUIRED_QT_VERSION 5.14.0)
0116 endif()
0117 
0118 find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED
0119     COMPONENTS
0120         Core
0121         Xml
0122         Network
0123         Test
0124         Widgets
0125         Svg
0126         Sql
0127         Concurrent
0128         Quick
0129         PrintSupport
0130 )
0131 
0132 if(ANDROID)
0133     find_package(Qt5Positioning ${REQUIRED_QT_VERSION} REQUIRED)
0134     find_package(Qt5Multimedia ${REQUIRED_QT_VERSION} REQUIRED)
0135 
0136    set ( MARBLE_NO_WEBKITWIDGETS TRUE )
0137 else()
0138     find_package(Qt5WebChannel ${REQUIRED_QT_VERSION})
0139     find_package(Qt5WebEngine ${REQUIRED_QT_VERSION})
0140     find_package(Qt5WebEngineWidgets ${REQUIRED_QT_VERSION})
0141 
0142    if ( NOT Qt5WebEngineWidgets_FOUND )
0143      set ( MARBLE_NO_WEBKITWIDGETS TRUE )
0144    endif()
0145 endif()
0146 
0147 if (BUILD_WITH_DBUS)
0148   find_package(Qt5DBus ${REQUIRED_QT_VERSION})
0149   if (NOT Qt5DBus_FOUND)
0150     set(MARBLE_NO_DBUS TRUE)
0151   endif()
0152 else()
0153   set(MARBLE_NO_DBUS TRUE)
0154 endif()
0155 
0156 SET(CMAKE_AUTOMOC TRUE)
0157 
0158 # Use M_PI under Windows
0159 if( WIN32 )
0160     add_definitions( -D_USE_MATH_DEFINES )
0161 endif( WIN32 )
0162 
0163 ####################################################
0164 # build unit tests
0165 
0166 INCLUDE (CTest)
0167 ENABLE_TESTING()
0168 
0169 option( BUILD_MARBLE_TESTS "Build unit tests" ON )
0170 add_feature_info("Unit tests" BUILD_MARBLE_TESTS "Build unit tests. Toggle with BUILD_MARBLE_TESTS=YES/NO. 'make test' will run all.")
0171 
0172 if( BUILD_MARBLE_TESTS )
0173 #  SET (TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/test_data")
0174   #where unit test binaries should be installed to and run from
0175 #  SET (MARBLE_TEST_DIR   ${CMAKE_CURRENT_BINARY_DIR}/tests)
0176 endif( BUILD_MARBLE_TESTS )
0177 
0178 ####################################################
0179 set (PEDANTIC FALSE CACHE BOOL "Determines if we should compile with -Wall -Werror.")
0180 set (WITH_DESIGNER_PLUGIN TRUE CACHE BOOL "Build plugins for Qt Designer")
0181 add_feature_info("Qt Designer plugins" WITH_DESIGNER_PLUGIN "Marble widget support in Qt Designer. Toggle with WITH_DESIGNER_PLUGIN=YES/NO")
0182 
0183 set(EXEC_INSTALL_PREFIX  ${CMAKE_INSTALL_PREFIX} CACHE PATH  "Base directory for executables and libraries" FORCE)
0184 if (NOT QT_PLUGINS_DIR)
0185    set(QT_PLUGINS_DIR ${CMAKE_INSTALL_LIBDIR}/plugins)
0186 endif()
0187 
0188 ####################################################
0189 # Detect default for the user configurable MARBLE_DATA_PATH option
0190 
0191 if(WIN32)
0192     set(data_dir data)
0193     set(locale_dir "${data_dir}/locale")
0194     set(plugin_dir plugins)
0195 elseif(APPLE)
0196     # needed for finding bundle path in e.g. katlasdir.h
0197     FIND_LIBRARY(APP_SERVICES_LIBRARY ApplicationServices )
0198     MARK_AS_ADVANCED (APP_SERVICES_LIBRARY)
0199     SET(MAC_EXTRA_LIBS ${APP_SERVICES_LIBRARY})
0200       # for Mac OS X, everything is put inside an application bundle
0201       SET (CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/)
0202       # path for library references
0203       SET (CMAKE_INSTALL_NAME_DIR @executable_path/lib)
0204       # install the Info.plist file
0205       install(FILES src/mac/Info.plist DESTINATION ${CMAKE_INSTALL_PREFIX}/Marble.app/Contents)
0206       #SET (lib_dir ${CMAKE_INSTALL_PREFIX}/Marble.app/Contents/MacOS/lib)
0207       SET (data_dir   ${CMAKE_INSTALL_PREFIX}/Marble.app/Contents/MacOS/resources/data)
0208       set(locale_dir "${data_dir}/locale")
0209       SET (plugin_dir   ${CMAKE_INSTALL_PREFIX}/Marble.app/Contents/MacOS/resources/plugins)
0210 elseif(ANDROID)
0211       set(plugin_dir "${CMAKE_INSTALL_PREFIX}/assets/plugins")
0212       set(data_dir "${CMAKE_INSTALL_PREFIX}/assets/data")
0213       set(locale_dir "${data_dir}/locale")
0214 else() # Linux / bsd etc...
0215       set(data_dir ${CMAKE_INSTALL_FULL_DATAROOTDIR}/marble/data)
0216       set(locale_dir "${CMAKE_INSTALL_FULL_DATAROOTDIR}/locale")
0217       set(plugin_dir ${CMAKE_INSTALL_FULL_LIBDIR}/marble/plugins)
0218 endif()
0219 
0220 if(NOT ICON_INSTALL_DIR)
0221         set(ICON_INSTALL_DIR share/icons)
0222 endif(NOT ICON_INSTALL_DIR)
0223 
0224 if(NOT APPS_INSTALL_DIR)
0225         set(APPS_INSTALL_DIR share/applications)
0226 endif(NOT APPS_INSTALL_DIR)
0227 
0228 if(NOT INCLUDE_INSTALL_DIR)
0229     set(INCLUDE_INSTALL_DIR "include")
0230 endif()
0231 
0232 if (NOT MARBLE_DATA_PATH)
0233   set (MARBLE_DATA_PATH ${data_dir})
0234 endif (NOT MARBLE_DATA_PATH)
0235 
0236 if (NOT MARBLE_PLUGIN_PATH)
0237   set (MARBLE_PLUGIN_PATH ${plugin_dir})
0238 endif (NOT MARBLE_PLUGIN_PATH)
0239 
0240 if (NOT MARBLE_DATA_INSTALL_PATH)
0241   set (MARBLE_DATA_INSTALL_PATH ${MARBLE_DATA_PATH})
0242 endif (NOT MARBLE_DATA_INSTALL_PATH)
0243 
0244 if (NOT MARBLE_PLUGIN_INSTALL_PATH)
0245   set (MARBLE_PLUGIN_INSTALL_PATH ${MARBLE_PLUGIN_PATH})
0246 endif (NOT MARBLE_PLUGIN_INSTALL_PATH)
0247 
0248 #MESSAGE( STATUS, "MARBLE_PLUGIN_INSTALL_PATH: ${MARBLE_PLUGIN_INSTALL_PATH}" )
0249 
0250 if(WIN32)
0251   set (STATIC_BUILD FALSE CACHE BOOL "Link to static Qt libs (win32 only)?")
0252 endif(WIN32)
0253 
0254 add_definitions(
0255     -DQT_USE_QSTRINGBUILDER
0256     -DQT_NO_SIGNALS_SLOTS_KEYWORDS
0257     -DQT_NO_URL_CAST_FROM_STRING
0258     -DQT_NO_CAST_TO_ASCII
0259     -DQT_NO_CAST_FROM_BYTEARRAY
0260     -DQT_DISABLE_DEPRECATED_BEFORE=0x050700
0261 )
0262 
0263 if (NOT WIN32)
0264     # Strict iterators can't be used on Windows, they lead to a link error
0265     # when application code iterates over a QVector<QPoint> for instance
0266     # See example at https://bugreports.qt.io/browse/QTBUG-78112
0267     add_definitions(-DQT_STRICT_ITERATORS)
0268 endif()
0269 ####################################################
0270 # Options for static build
0271 if(STATIC_BUILD)
0272   set(BUILD_SHARED_LIBS FALSE)
0273   add_definitions(-DSTATIC_BUILD=1)
0274 else()
0275   set(BUILD_SHARED_LIBS TRUE)
0276 endif(STATIC_BUILD)
0277 
0278 #############################################################
0279 if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc")
0280     # Its good programming practice to build with no warnings...
0281     add_definitions( -Wall -Wextra -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Wno-long-long
0282                      -Wchar-subscripts -Wcast-align -Wpointer-arith -Wformat-security )
0283 
0284     # In pedantic mode, treat warnings as errors
0285     if (PEDANTIC)
0286         add_definitions( -Werror )
0287     endif (PEDANTIC)
0288 endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER MATCHES "icc")
0289 
0290 #############################################################
0291 # Add a compiler def so that we can conditionally compile
0292 # code in debug mode only (e.g. extra console messages)
0293 IF (CMAKE_BUILD_TYPE MATCHES Debug)
0294     IF(NOT MINGW)
0295         ADD_DEFINITIONS(-DDEBUG)
0296     ELSE(NOT MINGW)
0297         REMOVE_DEFINITIONS( -DQT_NO_DEBUG )
0298     ENDIF(NOT MINGW)
0299 ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)
0300 
0301 ####################################################
0302 # on Win32 set the debug postfix
0303 if(WIN32)
0304   # distinguish between debug and release plugin
0305   SET(CMAKE_DEBUG_POSTFIX "d")
0306 endif(WIN32)
0307 ####################################################
0308 
0309 
0310 ####################################################
0311 # Add global ECM & KF5 settings
0312 set(REQUIRED_ECM_VERSION 1.7.0)
0313 set(KDE_INSTALL_DIRS_NO_DEPRECATED TRUE)
0314 set(KDE_SKIP_UNINSTALL_TARGET ON CACHE BOOL "KDE uninstall target must be disabled")
0315 set(REQUIRED_KF5_MIN_VERSION 5.7.0)
0316 
0317 find_package(ECM ${REQUIRED_ECM_VERSION} QUIET)
0318 if(ECM_FOUND)
0319   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
0320 
0321   include(KDEInstallDirs)
0322   # KDECMakeSettings expects LIB_INSTALL_DIR set
0323   set(LIB_INSTALL_DIR ${KDE_INSTALL_LIBDIR})
0324   include(KDECMakeSettings)
0325   include(ECMInstallIcons)
0326   include(ECMEnableSanitizers)
0327   include(ECMCoverageOption)
0328   include(ECMQtDeclareLoggingCategory)
0329 endif()
0330 
0331 ####################################################
0332 # Add the include directories
0333 
0334 include_directories(
0335   ${CMAKE_CURRENT_SOURCE_DIR}
0336   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble
0337   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/projections
0338   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/geodata
0339   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/geodata/data
0340   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/geodata/graphicsitem
0341   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/geodata/handlers/dgml
0342   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/geodata/parser
0343   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/geodata/writer
0344   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/geodata/scene
0345   ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/marble/graphicsview
0346   ${CMAKE_CURRENT_BINARY_DIR}/src
0347   ${CMAKE_CURRENT_BINARY_DIR}/src/lib/marble
0348 )
0349 ####################################################
0350 # Descend into subdirectories
0351 add_subdirectory(doc)
0352 add_subdirectory(src)
0353 add_subdirectory(data)
0354 
0355 include(DistTarget)
0356 
0357 add_subdirectory(tests)
0358 
0359 option(BUILD_MARBLE_TOOLS "Build various tools related to Marble" OFF)
0360 add_feature_info("Marble tools" BUILD_MARBLE_TOOLS "Build various Marble tools for e.g. file format conversion. Toggle with BUILD_MARBLE_TOOLS=YES/NO.")
0361 if(BUILD_MARBLE_TOOLS)
0362   add_subdirectory(tools)
0363 endif()
0364 
0365 option(BUILD_MARBLE_EXAMPLES "Build C++ examples showing how to use the Marble library" OFF)
0366 add_feature_info("Marble library C++ examples" BUILD_MARBLE_EXAMPLES "Build C++ examples showing how to use the Marble library. Toggle with BUILD_MARBLE_EXAMPLES=YES/NO.")
0367 if(BUILD_MARBLE_EXAMPLES)
0368   add_subdirectory(examples/cpp)
0369 endif()
0370 
0371 ####################################################
0372 # Handle translation catalogs of KDE Application release tarball of marble
0373 # (for custom bundle translation handling see data/lang/README)
0374 
0375 # KDE Application release tarballs have the respective po files added on tarball creation,
0376 # which are otherwise stored and edited separately on the KDE svn servers.
0377 # Toplevel subdir "poqm/" holds all the po files which should be processed and installed as qm files
0378 marble_install_po_files_as_qm(poqm)
0379 
0380 # Toplevel subdir "po/" holds all the po files which should be processed and installed as mo files
0381 # Those are used by app and plugin code building against KI18n.
0382 # So the respective macro ki18n_install can be used.
0383 # Likewise, it contains the translated user documentation, which is handled by kdoctools_install.
0384 # Just, the macros are not available here in the toplevel CMakeLists.txt file.
0385 # As a temporary hack (your task to improve it, dear reader :) ) the macros
0386 # are called only from src/apps/marble-kde/CMakeLists.txt.
0387 # That should catch 99.9 % cases of builds from released tarball, where all the
0388 # KF5-dependent apps and plugins will be built and installed together.
0389 # Currently these are:
0390 # src/apps/marble-kde
0391 # src/plasmarunner
0392 # src/plasma/applets/worldclock
0393 # src/plasma/wallpapers/worldmap
0394 #
0395 # Let releaseme know about this:
0396 # SKIP_PO_INSTALL
0397 
0398 
0399 ####################################################
0400 # Install extra files
0401 install(FILES LICENSES/LGPL-2.1-or-later.txt
0402         DESTINATION ${MARBLE_DATA_INSTALL_PATH}
0403         RENAME LICENSE.txt)
0404 
0405 ############################################################
0406 # Uninstall stuff
0407 CONFIGURE_FILE(
0408     "${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/cmake_uninstall.cmake.in"
0409     "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
0410     IMMEDIATE @ONLY)
0411 
0412 ADD_CUSTOM_TARGET(uninstall
0413     "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
0414 
0415 include(MarbleCPackOptions)
0416 
0417 marble_feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES)