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