From db0d26a4adc2a27dba01a19bf58e828a632f4068 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 27 Feb 2024 23:13:08 -0600 Subject: [PATCH] Use maplibre-native-qt dependency instead of mapbox-gl-native --- CMakeLists.txt | 2 ++ external/CMakeLists.txt | 4 +-- external/maplibre-native-qt.cmake | 43 +++++++++++++++++++++++++++++++ scwx-qt/scwx-qt.cmake | 14 +++++----- 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 external/maplibre-native-qt.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 72d0499d..0889734f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,3 +48,5 @@ add_subdirectory(external) add_subdirectory(wxdata) add_subdirectory(scwx-qt) add_subdirectory(test) + +set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER CMakePredefinedTargets) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 8bbdf6da..bbc76c64 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -8,7 +8,7 @@ set_property(DIRECTORY date.cmake hsluv-c.cmake imgui.cmake - mapbox-gl-native.cmake + maplibre-native-qt.cmake stb.cmake textflowcpp.cmake units.cmake) @@ -17,7 +17,7 @@ include(aws-sdk-cpp.cmake) include(date.cmake) include(hsluv-c.cmake) include(imgui.cmake) -include(mapbox-gl-native.cmake) +include(maplibre-native-qt.cmake) include(stb.cmake) include(textflowcpp.cmake) include(units.cmake) diff --git a/external/maplibre-native-qt.cmake b/external/maplibre-native-qt.cmake new file mode 100644 index 00000000..aef6de7b --- /dev/null +++ b/external/maplibre-native-qt.cmake @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.20) +set(PROJECT_NAME scwx-mln) + +set(gtest_disable_pthreads ON) +set(MLN_WITH_QT ON) +set(MLN_QT_WITH_INTERNAL_ICU ON) +set(MLN_QT_WITH_LOCATION OFF) +add_subdirectory(maplibre-native-qt) + +find_package(ZLIB) +target_include_directories(mbgl-core PRIVATE ${ZLIB_INCLUDE_DIRS}) +target_link_libraries(mbgl-core INTERFACE ${ZLIB_LIBRARIES}) + +if (MSVC) + # Produce PDB file for debug + target_compile_options(mbgl-core PRIVATE "$<$:/Zi>") + target_compile_options(Core PRIVATE "$<$:/Zi>") + target_link_options(Core PRIVATE "$<$:/DEBUG>") + target_link_options(Core PRIVATE "$<$:/OPT:REF>") + target_link_options(Core PRIVATE "$<$:/OPT:ICF>") +else() + target_compile_options(mbgl-core PRIVATE "$<$:-g>") + target_compile_options(Core PRIVATE "$<$:-g>") +endif() + +set(MLN_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/maplibre-native-qt/vendor/maplibre-native/include + ${CMAKE_CURRENT_SOURCE_DIR}/maplibre-native-qt/src/core/include + ${CMAKE_CURRENT_BINARY_DIR}/maplibre-native-qt/src/core/include PARENT_SCOPE) + +set_target_properties(test_mln_core PROPERTIES EXCLUDE_FROM_ALL True) +set_target_properties(test_mln_widgets PROPERTIES EXCLUDE_FROM_ALL True) +set_target_properties(Widgets PROPERTIES EXCLUDE_FROM_ALL True) + +set_target_properties(test_mln_core PROPERTIES FOLDER mln/exclude) +set_target_properties(test_mln_widgets PROPERTIES FOLDER mln/exclude) +set_target_properties(Widgets PROPERTIES FOLDER mln/exclude) + +set_target_properties(Core PROPERTIES FOLDER mln) +set_target_properties(mbgl-core PROPERTIES FOLDER mln) +set_target_properties(mbgl-vendor-csscolorparser PROPERTIES FOLDER mln) +set_target_properties(mbgl-vendor-nunicode PROPERTIES FOLDER mln) +set_target_properties(mbgl-vendor-parsedate PROPERTIES FOLDER mln) +set_target_properties(mbgl-vendor-sqlite PROPERTIES FOLDER mln) diff --git a/scwx-qt/scwx-qt.cmake b/scwx-qt/scwx-qt.cmake index 53be9d97..d0121e40 100644 --- a/scwx-qt/scwx-qt.cmake +++ b/scwx-qt/scwx-qt.cmake @@ -496,7 +496,7 @@ endif() target_include_directories(scwx-qt PUBLIC ${scwx-qt_SOURCE_DIR}/source ${FTGL_INCLUDE_DIR} ${IMGUI_INCLUDE_DIRS} - ${MBGL_INCLUDE_DIR} + ${MLN_INCLUDE_DIRS} ${STB_INCLUDE_DIR} ${TEXTFLOWCPP_INCLUDE_DIR}) @@ -554,7 +554,7 @@ target_link_libraries(scwx-qt PUBLIC Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Positioning Boost::json Boost::timer - qmaplibregl + QMapLibre::Core $<$:opengl32> Fontconfig::Fontconfig GeographicLib::GeographicLib @@ -570,11 +570,11 @@ target_link_libraries(supercell-wx PRIVATE scwx-qt wxdata) # Set DT_RUNPATH for Linux targets -set_target_properties(qmaplibregl PROPERTIES INSTALL_RPATH "\$ORIGIN/../lib") +set_target_properties(Core PROPERTIES INSTALL_RPATH "\$ORIGIN/../lib") # QMapLibre::Core set_target_properties(supercell-wx PROPERTIES INSTALL_RPATH "\$ORIGIN/../lib") install(TARGETS supercell-wx - qmaplibregl + Core # QMapLibre::Core RUNTIME_DEPENDENCIES PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" "qt6" POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" @@ -587,8 +587,8 @@ install(TARGETS supercell-wx # NO_TRANSLATIONS is needed for Qt 6.5.0 (will be fixed in 6.5.1) # https://bugreports.qt.io/browse/QTBUG-112204 -qt_generate_deploy_app_script(TARGET qmaplibregl - OUTPUT_SCRIPT deploy_script_qmaplibregl +qt_generate_deploy_app_script(TARGET Core # QMapLibre::Core + OUTPUT_SCRIPT deploy_script_qmaplibre_core NO_TRANSLATIONS NO_UNSUPPORTED_PLATFORM_ERROR) @@ -597,7 +597,7 @@ qt_generate_deploy_app_script(TARGET supercell-wx NO_TRANSLATIONS NO_UNSUPPORTED_PLATFORM_ERROR) -install(SCRIPT ${deploy_script_qmaplibregl} +install(SCRIPT ${deploy_script_qmaplibre_core} COMPONENT supercell-wx) install(SCRIPT ${deploy_script_scwx}