diff --git a/.github/workflows/Android.yml b/.github/workflows/Android.yml index af5e34a..f0de1b6 100644 --- a/.github/workflows/Android.yml +++ b/.github/workflows/Android.yml @@ -1,59 +1,72 @@ -name: Android Qt6 CI +name: Android CI on: workflow_dispatch: - # push: - # branches: - # - main - # tags: - # - '**' - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/iOS.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" - - # pull_request: - # branches: - # - main - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/iOS.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" + push: + branches: + - main + tags: + - "**" + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/iOS.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" + + pull_request: + branches: + - main + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/iOS.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" concurrency: # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} -env: - QT_VERSION: 6.5.3 - jobs: build: - name: Build QMapLibre for ${{ matrix.config.abi }} + name: Build QMapLibre for Android (Qt${{ matrix.qt_version}}, ${{ matrix.abi }}) runs-on: ubuntu-22.04 strategy: matrix: - config: - - abi: x86 + include: + - qt_version: 6.5.3 + abi: x86 arch: android_x86 - - abi: x86_64 + - qt_version: 6.5.3 + abi: x86_64 arch: android_x86_64 - - abi: armeabi-v7a + - qt_version: 6.5.3 + abi: armeabi-v7a arch: android_armv7 - - abi: arm64-v8a + - qt_version: 6.5.3 + abi: arm64-v8a + arch: android_arm64_v8a + - qt_version: 6.6.0 + abi: x86 + arch: android_x86 + - qt_version: 6.6.0 + abi: x86_64 + arch: android_x86_64 + - qt_version: 6.6.0 + abi: armeabi-v7a + arch: android_armv7 + - qt_version: 6.6.0 + abi: arm64-v8a arch: android_arm64_v8a steps: @@ -69,7 +82,7 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} modules: qtlocation qtpositioning set-env: false @@ -78,13 +91,13 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} target: android - arch: ${{ matrix.config.arch }} + arch: ${{ matrix.arch }} modules: qtlocation qtpositioning - name: Fix Qt release - if: ${{ matrix.config.abi }} == 'armeabi-v7a' + if: ${{ matrix.abi }} == 'armeabi-v7a' run: | chmod +x "$Qt6_DIR/bin/qt-cmake" sed -i "s/C:\/Qt\/Qt-${QT_VERSION}/\/usr\/local\/Qt-${QT_VERSION}/g" "$Qt6_DIR/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake" @@ -101,12 +114,12 @@ jobs: - name: Set up ccache uses: hendrikmuhs/ccache-action@v1 with: - key: Android_QMapLibre_${{ matrix.config.abi }} + key: Android_QMapLibre_${{ matrix.qt_version }}_${{ matrix.abi }} max-size: 200M - name: Build QMapLibre env: - ANDROID_ABI: ${{ matrix.config.abi }} + ANDROID_ABI: ${{ matrix.abi }} run: | mkdir build && cd build qt-cmake ../source/ \ @@ -117,10 +130,9 @@ jobs: -DCMAKE_INSTALL_PREFIX="../install" \ -DQT_HOST_PATH="$(readlink -f "$Qt6_DIR/../gcc_64")" ninja - ninja test ninja install - - name: Create artifacts + - name: Compress installation run: | pushd install tar cjvf ../QMapLibre_Android.tar.bz2 * @@ -129,56 +141,61 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: QMapLibre_Android_${{ matrix.config.abi }} - path: install/home/runner/work/QMapLibre + name: QMapLibre_Android_${{ matrix.qt_version }}_${{ matrix.abi }} + path: QMapLibre_Android.tar.bz2 combine: name: Combine QMapLibre runs-on: ubuntu-22.04 needs: build + strategy: + matrix: + qt_version: [6.5.3, 6.6.0] steps: - name: Download artifacts for x86 uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_x86 - path: install-x86 + name: QMapLibre_Android_${{ matrix.qt_version}}_x86 + path: x86 - name: Download artifacts for x86_64 uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_x86_64 - path: install-x86_64 + name: QMapLibre_Android_${{ matrix.qt_version}}_x86_64 + path: x86_64 - name: Download artifacts for armeabi-v7a uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_armeabi-v7a - path: install-armeabi-v7a + name: QMapLibre_Android_${{ matrix.qt_version}}_armeabi-v7a + path: armeabi-v7a - name: Download artifacts for arm64-v8a uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_arm64-v8a - path: install-arm64-v8a + name: QMapLibre_Android_${{ matrix.qt_version}}_arm64-v8a + path: arm64-v8a - name: Combine artifacts run: | - cp -r install-arm64-v8a install - cp -r install-armeabi-v7a/Qt/${QT_VERSION}/* install/Qt/${QT_VERSION}/ - cp -r install-x86/Qt/${QT_VERSION}/* install/Qt/${QT_VERSION}/ - cp -r install-x86_64/Qt/${QT_VERSION}/* install/Qt/${QT_VERSION}/ + mkdir install && pushd install + tar xf ../x86/QMapLibre_Android.tar.bz2 + tar xf ../x86_64/QMapLibre_Android.tar.bz2 + tar xf ../armeabi-v7a/QMapLibre_Android.tar.bz2 + tar xf ../arm64-v8a/QMapLibre_Android.tar.bz2 + popd - name: Create artifacts run: | pushd install - tar cjvf ../QMapLibre_Android.tar.bz2 Qt + tar cjvf ../QMapLibre_Android.tar.bz2 * popd - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: QMapLibre_Android + name: QMapLibre_Android_${{ matrix.qt_version}} path: QMapLibre_Android.tar.bz2 release: @@ -188,22 +205,26 @@ jobs: needs: combine permissions: contents: write + strategy: + matrix: + qt_version: [6.5.3, 6.6.0] steps: - name: Download artifacts uses: actions/download-artifact@v3 with: - name: QMapLibre_Android + name: QMapLibre_Android_${{ matrix.qt_version }} - name: Make tarball env: TAG_NAME: ${{ github.ref_name }} + QT_VERSION: ${{ matrix.qt_version }} run: | mv QMapLibre_Android.tar.bz2 QMapLibre_${TAG_NAME}_Qt${QT_VERSION}_Android.tar.bz2 - name: Release uses: ncipollo/release-action@v1 with: - artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ env.QT_VERSION }}_Android.tar.bz2 + artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_Android.tar.bz2 allowUpdates: true draft: true diff --git a/.github/workflows/iOS.yml b/.github/workflows/iOS.yml index b628c67..c6e23f3 100644 --- a/.github/workflows/iOS.yml +++ b/.github/workflows/iOS.yml @@ -1,49 +1,56 @@ -name: iOS Qt6 CI +name: iOS CI on: workflow_dispatch: - # push: - # branches: - # - main - # tags: - # - '**' - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/Android.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" - - # pull_request: - # branches: - # - main - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/Android.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" + push: + branches: + - main + tags: + - "**" + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/Android.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" + + pull_request: + branches: + - main + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/Android.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" concurrency: # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} -env: - QT_VERSION: 6.5.3 - jobs: - build-plugin: - name: Build QMapLibre + build: + name: Build QMapLibre for iOS (Qt${{ matrix.qt_version}}) runs-on: macos-13 + strategy: + matrix: + include: + - qt_version: 6.5.3 + deployment_target: 14.0 + - qt_version: 6.6.0 + deployment_target: 14.0 + + env: + DEPLOYMENT_TARGET: ${{ matrix.deployment_target }} steps: - name: Checkout @@ -62,7 +69,7 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} target: desktop modules: qtlocation qtpositioning set-env: false @@ -71,7 +78,7 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} target: ios modules: qtlocation qtpositioning @@ -81,7 +88,7 @@ jobs: - name: Set up ccache uses: hendrikmuhs/ccache-action@v1 with: - key: iOS_QMapLibre + key: iOS_QMapLibre_${{ matrix.qt_version }} max-size: 200M - name: Use latest version of ccache @@ -91,7 +98,6 @@ jobs: - name: Build QMapLibre run: | - export CCACHE_LOGFILE="../ccache.log" mkdir build && cd build qt-cmake ../source/ \ -G"Ninja Multi-Config" \ @@ -100,53 +106,50 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ -DCMAKE_INSTALL_PREFIX="../install" \ -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="${DEPLOYMENT_TARGET}" \ -DQT_HOST_PATH="$(readlink -f "$Qt6_DIR/../macos")" ninja - ninja test ninja install - - name: Upload ccache.log - uses: actions/upload-artifact@v3 - with: - name: ccache_iOS - path: ccache.log - - - name: Create artifacts + - name: Compress installation run: | pushd install tar cjvf ../QMapLibre_iOS.tar.bz2 * popd - - name: Upload artifacts + - name: Upload installation uses: actions/upload-artifact@v3 with: - name: QMapLibre_iOS + name: QMapLibre_iOS_${{ matrix.qt_version }} path: QMapLibre_iOS.tar.bz2 release: name: Release QMapLibre if: github.ref_type == 'tag' runs-on: macos-13 - needs: build-plugin + needs: build permissions: contents: write + strategy: + matrix: + qt_version: [6.5.3, 6.6.0] steps: - name: Download artifacts uses: actions/download-artifact@v3 with: - name: QMapLibre_iOS + name: QMapLibre_iOS_${{ matrix.qt_version }} - name: Make tarball env: TAG_NAME: ${{ github.ref_name }} + QT_VERSION: ${{ matrix.qt_version }} run: | mv QMapLibre_iOS.tar.bz2 QMapLibre_${TAG_NAME}_Qt${QT_VERSION}_iOS.tar.bz2 - name: Release uses: ncipollo/release-action@v1 with: - artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ env.QT_VERSION }}_iOS.tar.bz2 + artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_iOS.tar.bz2 allowUpdates: true draft: true diff --git a/CMakeLists.txt b/CMakeLists.txt index 10b045a..396e917 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.19...3.21) # Version file(READ "VERSION.txt" MLN_QT_VERSION) -string(REGEX REPLACE "\n" "" MLN_QT_VERSION "${MLN_QT_VERSION}") # get rid of the newline at the end +string(STRIP "${MLN_QT_VERSION}" MLN_QT_VERSION) # get rid of the whitespace set(MLN_QT_VERSION_COMPATIBILITY 3.0.0) message(STATUS "Version ${MLN_QT_VERSION}") # Project definition -project(MapLibreNativeQt +project( + MapLibreNativeQt VERSION "${MLN_QT_VERSION}" DESCRIPTION "MapLibre Native Qt Bindings" LANGUAGES CXX @@ -38,15 +39,15 @@ option(MLN_QT_WITH_CLANG_TIDY "Build QMapLibre with clang-tidy checks enabled" O # Find Qt find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui Network REQUIRED) # main dependencies -if (NOT MLN_QT_WITH_INTERNAL_SQLITE) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Gui Network REQUIRED) # main dependencies +if(NOT MLN_QT_WITH_INTERNAL_SQLITE) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Sql REQUIRED) endif() -if (MLN_QT_WITH_LOCATION) - find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Location REQUIRED) # location +if(MLN_QT_WITH_LOCATION) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Location REQUIRED) # location endif() -if (MLN_QT_WITH_WIDGETS) - if (Qt6_FOUND) +if(MLN_QT_WITH_WIDGETS) + if(Qt6_FOUND) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGLWidgets REQUIRED) else() find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGL REQUIRED) @@ -55,7 +56,7 @@ endif() message(STATUS "Using Qt${QT_VERSION_MAJOR}") # Debugging & ccache on Windows -if (MSVC) +if(MSVC) foreach(config DEBUG RELWITHDEBINFO) foreach(lang C CXX) set(flags_var "CMAKE_${lang}_FLAGS_${config}") @@ -73,9 +74,9 @@ if(MLN_QT_WITH_CLANG_TIDY) else() message(STATUS "Found clang-tidy at ${CLANG_TIDY_COMMAND}") endif() - # TODO: there are options which are only available on GCC(e.g. -Werror=maybe-uninitialized), - # that's why we need to disable this `unknown-warning-option` here. - # We could check if current compiler supports particular flag before enabling it. + # TODO: there are options which are only available on GCC (e.g. -Werror=maybe-uninitialized), + # that's why we need to disable this `unknown-warning-option` here. We could check if current + # compiler supports particular flag before enabling it. set(CLANG_TIDY_COMMAND "${CLANG_TIDY_COMMAND};--extra-arg=-Wno-error=unknown-warning-option") endif() diff --git a/examples/.clang-tidy b/examples/.clang-tidy new file mode 100644 index 0000000..9e41b59 --- /dev/null +++ b/examples/.clang-tidy @@ -0,0 +1,7 @@ +--- +InheritParentConfig: true +Checks: > + -cppcoreguidelines-avoid-magic-numbers, + -readability-magic-numbers, + -readability-static-accessed-through-instance +... diff --git a/examples/quick/CMakeLists.txt b/examples/quick/CMakeLists.txt index 91d509d..f282fa4 100644 --- a/examples/quick/CMakeLists.txt +++ b/examples/quick/CMakeLists.txt @@ -9,13 +9,19 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(Qt6 REQUIRED COMPONENTS Quick REQUIRED) qt_standard_project_setup() +if(QT_KNOWN_POLICY_QTP0002) + qt_policy(SET QTP0002 NEW) +endif() + find_package(QMapLibre COMPONENTS Location REQUIRED) -qt_add_executable(QMapLibreExampleQuick +qt_add_executable( + QMapLibreExampleQuick main.cpp ) -qt_add_qml_module(QMapLibreExampleQuick +qt_add_qml_module( + QMapLibreExampleQuick URI Example VERSION 1.0 RESOURCE_PREFIX "/" @@ -23,12 +29,15 @@ qt_add_qml_module(QMapLibreExampleQuick main.qml ) -set_target_properties(QMapLibreExampleQuick PROPERTIES - WIN32_EXECUTABLE ON - MACOSX_BUNDLE ON +set_target_properties( + QMapLibreExampleQuick + PROPERTIES + WIN32_EXECUTABLE ON + MACOSX_BUNDLE ON ) -target_link_libraries(QMapLibreExampleQuick +target_link_libraries( + QMapLibreExampleQuick PRIVATE Qt::Quick QMapLibre::Location @@ -38,9 +47,21 @@ qmaplibre_location_setup_plugins(QMapLibreExampleQuick) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") get_property(_qmlImport TARGET QMapLibreExampleQuick PROPERTY QT_QML_IMPORT_PATH) - add_custom_target(deploy + add_custom_target( + deploy COMMAND macdeployqt QMapLibreExampleQuick.app -qmldir=${CMAKE_SOURCE_DIR} -qmlimport=${_qmlImport} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_dependencies(deploy QMapLibreExampleQuick) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android") + include(FetchContent) + FetchContent_Declare( + android_openssl + DOWNLOAD_EXTRACT_TIMESTAMP true + URL https://github.com/KDAB/android_openssl/archive/refs/heads/master.zip + ) + FetchContent_MakeAvailable(android_openssl) + include(${android_openssl_SOURCE_DIR}/android_openssl.cmake) + + add_android_openssl_libraries(QMapLibreExampleQuick) endif() diff --git a/examples/quick/main.cpp b/examples/quick/main.cpp index 5c85da5..31e5de1 100644 --- a/examples/quick/main.cpp +++ b/examples/quick/main.cpp @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) { QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi); #endif - QGuiApplication app(argc, argv); + const QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/Example/main.qml"))); diff --git a/examples/quick/main.qml b/examples/quick/main.qml index 3307c0b..09765ce 100644 --- a/examples/quick/main.qml +++ b/examples/quick/main.qml @@ -7,6 +7,8 @@ import QtQuick.Window 6.5 import QtLocation 6.5 import QtPositioning 6.5 +import QtLocation.MapLibre 3.0 + Window { id: window width: Qt.platform.os === "android" ? Screen.width : 512 @@ -14,7 +16,7 @@ Window { visible: true property bool fullWindow: false // toggle full map with the 'F' key - property var coordinate: QtPositioning.coordinate(59.91, 10.75) // Oslo + property var coordinate: QtPositioning.coordinate(41.874, -75.789) Rectangle { color: "blue" @@ -58,6 +60,34 @@ Window { map.plugin: mapPlugin map.center: window.coordinate map.zoomLevel: 5 + + MapLibre.style: Style { + id: style + + SourceParameter { + id: radarSourceParam + styleId: "radar" + type: "image" + property string url: "https://maplibre.org/maplibre-gl-js/docs/assets/radar1.gif" + property var coordinates: [ + [-80.425, 46.437], + [-71.516, 46.437], + [-71.516, 37.936], + [-80.425, 37.936] + ] + } + + LayerParameter { + id: radarLayerParam + styleId: "radar-layer" + type: "raster" + property string source: "radar" + + paint: { + "raster-opacity": 0.9 + } + } + } } } } diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt index cf95d8a..0f299c6 100644 --- a/examples/widgets/CMakeLists.txt +++ b/examples/widgets/CMakeLists.txt @@ -4,7 +4,7 @@ project(QMapLibreExampleWidgets VERSION 1.0.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(APPLE) # suppress some warnings in Qt6 +if(APPLE) # suppress some warnings in Qt6 set(CMAKE_CXX_VISIBILITY_PRESET hidden) endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -14,7 +14,8 @@ qt_standard_project_setup() find_package(QMapLibre COMPONENTS Widgets REQUIRED) -qt_add_executable(QMapLibreExampleWidgets +qt_add_executable( + QMapLibreExampleWidgets main.cpp mainwindow.cpp mainwindow.hpp @@ -22,18 +23,22 @@ qt_add_executable(QMapLibreExampleWidgets window.hpp ) -set_target_properties(QMapLibreExampleWidgets PROPERTIES - WIN32_EXECUTABLE ON - MACOSX_BUNDLE ON +set_target_properties( + QMapLibreExampleWidgets + PROPERTIES + WIN32_EXECUTABLE ON + MACOSX_BUNDLE ON ) -target_link_libraries(QMapLibreExampleWidgets +target_link_libraries( + QMapLibreExampleWidgets PRIVATE QMapLibre::Widgets ) -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_custom_target(deploy +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + add_custom_target( + deploy COMMAND macdeployqt QMapLibreExampleWidgets.app WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) diff --git a/examples/widgets/main.cpp b/examples/widgets/main.cpp index 897342b..8dc33f8 100644 --- a/examples/widgets/main.cpp +++ b/examples/widgets/main.cpp @@ -7,7 +7,7 @@ #include int main(int argc, char **argv) { - QApplication app(argc, argv); + const QApplication app(argc, argv); MainWindow window; diff --git a/examples/widgets/mainwindow.cpp b/examples/widgets/mainwindow.cpp index d5a874a..f5126a3 100644 --- a/examples/widgets/mainwindow.cpp +++ b/examples/widgets/mainwindow.cpp @@ -7,24 +7,25 @@ #include "window.hpp" #include -#include #include MainWindow::MainWindow() { - auto *menuBar = new QMenuBar(this); - QMenu *menuWindow = menuBar->addMenu(tr("&Window")); - auto *actionAddNew = new QAction(menuWindow); - actionAddNew->setText(tr("Add new")); - menuWindow->addAction(actionAddNew); - connect(actionAddNew, &QAction::triggered, this, &MainWindow::onAddNew); - setMenuBar(menuBar); + m_menuBar = std::make_unique(this); + QMenu *menuWindow = m_menuBar->addMenu(tr("&Window")); + m_actionAddNew = std::make_unique(menuWindow); + m_actionAddNew->setText(tr("Add new")); + menuWindow->addAction(m_actionAddNew.get()); + connect(m_actionAddNew.get(), &QAction::triggered, this, &MainWindow::onAddNew); + setMenuBar(m_menuBar.get()); onAddNew(); } void MainWindow::onAddNew() { - if (!centralWidget()) - setCentralWidget(new Window(this)); - else + if (centralWidget() == nullptr) { + auto window = std::make_unique(this); + setCentralWidget(window.release()); // takes ownership + } else { QMessageBox::information(nullptr, tr("Cannot add new window"), tr("Already occupied. Undock first.")); + } } diff --git a/examples/widgets/mainwindow.hpp b/examples/widgets/mainwindow.hpp index a52c79d..9162d1a 100644 --- a/examples/widgets/mainwindow.hpp +++ b/examples/widgets/mainwindow.hpp @@ -6,6 +6,9 @@ #define MAINWINDOW_H #include +#include + +#include class MainWindow : public QMainWindow { Q_OBJECT @@ -15,6 +18,10 @@ class MainWindow : public QMainWindow { private slots: void onAddNew(); + +private: + std::unique_ptr m_menuBar{}; + std::unique_ptr m_actionAddNew{}; }; #endif diff --git a/examples/widgets/window.cpp b/examples/widgets/window.cpp index 7822330..8420d2e 100644 --- a/examples/widgets/window.cpp +++ b/examples/widgets/window.cpp @@ -6,8 +6,6 @@ #include "mainwindow.hpp" -#include - #include #include #include @@ -15,31 +13,38 @@ Window::Window(MainWindow *mainWindow) : QWidget(mainWindow), - m_mainWindow(mainWindow) { + m_mainWindowRef(mainWindow) { + QMapLibre::Styles styles; + styles.emplace_back("https://demotiles.maplibre.org/style.json", "Demo Tiles"); + QMapLibre::Settings settings; - settings.setProviderTemplate(QMapLibre::Settings::MapLibreProvider); - m_glWidget = new QMapLibre::GLWidget(settings); + settings.setStyles(styles); + settings.setDefaultZoom(5); + settings.setDefaultCoordinate(QMapLibre::Coordinate(43, 21)); + + m_glWidget = std::make_unique(settings); - auto *layout = new QVBoxLayout; - layout->addWidget(m_glWidget); - m_buttonDock = new QPushButton(tr("Undock"), this); - connect(m_buttonDock, &QPushButton::clicked, this, &Window::dockUndock); - layout->addWidget(m_buttonDock); + m_layout = std::make_unique(this); + m_layout->addWidget(m_glWidget.get()); + m_buttonDock = std::make_unique(tr("Undock"), this); + connect(m_buttonDock.get(), &QPushButton::clicked, this, &Window::dockUndock); + m_layout->addWidget(m_buttonDock.get()); - setLayout(layout); + setLayout(m_layout.get()); setWindowTitle(tr("Hello QMapLibre")); } void Window::keyPressEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_Escape) + if (e->key() == Qt::Key_Escape) { close(); - else + } else { QWidget::keyPressEvent(e); + } } void Window::dockUndock() { - if (parent()) { + if (parent() != nullptr) { setParent(nullptr); setAttribute(Qt::WA_DeleteOnClose); move(QGuiApplication::primaryScreen()->size().width() / 2 - width() / 2, @@ -47,11 +52,11 @@ void Window::dockUndock() { m_buttonDock->setText(tr("Dock")); show(); } else { - if (!m_mainWindow->centralWidget()) { - if (m_mainWindow->isVisible()) { + if (m_mainWindowRef->centralWidget() == nullptr) { + if (m_mainWindowRef->isVisible()) { setAttribute(Qt::WA_DeleteOnClose, false); m_buttonDock->setText(tr("Undock")); - m_mainWindow->setCentralWidget(this); + m_mainWindowRef->setCentralWidget(this); } else { QMessageBox::information(nullptr, tr("Cannot dock"), tr("Main window already closed")); } diff --git a/examples/widgets/window.hpp b/examples/widgets/window.hpp index d280ff4..d39d45a 100644 --- a/examples/widgets/window.hpp +++ b/examples/widgets/window.hpp @@ -5,12 +5,14 @@ #ifndef WINDOW_H #define WINDOW_H +#include + #include +#include #include -namespace QMapLibre { -class GLWidget; -} +#include + class MainWindow; class Window : public QWidget { @@ -26,9 +28,10 @@ private slots: void dockUndock(); private: - QMapLibre::GLWidget *m_glWidget; - QPushButton *m_buttonDock; - MainWindow *m_mainWindow; + std::unique_ptr m_glWidget{}; + std::unique_ptr m_layout{}; + std::unique_ptr m_buttonDock{}; + MainWindow *m_mainWindowRef{}; }; #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f76de0b..91a3446 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,12 +6,12 @@ set(CMAKECONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${MLN_QT_NAME}/) # Components add_subdirectory(core) set(MLN_QT_SUPPORTED_COMPONENTS "Core") -if (MLN_QT_WITH_LOCATION) +if(MLN_QT_WITH_LOCATION) add_subdirectory(location) list(APPEND MLN_QT_SUPPORTED_COMPONENTS "Location") message(STATUS "Building location module") endif() -if (MLN_QT_WITH_WIDGETS) +if(MLN_QT_WITH_WIDGETS) add_subdirectory(widgets) list(APPEND MLN_QT_SUPPORTED_COMPONENTS "Widgets") message(STATUS "Building widgets module") @@ -23,11 +23,14 @@ configure_package_config_file( "${CMAKE_CURRENT_BINARY_DIR}/${MLN_QT_NAME}Config.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} PATH_VARS CMAKE_INSTALL_PREFIX CMAKE_INSTALL_INCLUDEDIR - CMAKE_INSTALL_LIBDIR NO_CHECK_REQUIRED_COMPONENTS_MACRO) + CMAKE_INSTALL_LIBDIR NO_CHECK_REQUIRED_COMPONENTS_MACRO +) -write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${MLN_QT_NAME}ConfigVersion.cmake +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${MLN_QT_NAME}ConfigVersion.cmake VERSION ${MLN_QT_VERSION} - COMPATIBILITY AnyNewerVersion) + COMPATIBILITY AnyNewerVersion +) install( FILES diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 3dcb376..508bc67 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -48,11 +48,8 @@ target_sources( conversion_p.hpp geojson.cpp geojson_p.hpp map_observer.cpp map_observer_p.hpp - map.cpp map_p.hpp map_renderer.cpp map_renderer_p.hpp - renderer_backend.cpp renderer_backend_p.hpp - renderer_observer_p.hpp - scheduler.cpp scheduler_p.hpp + map.cpp map_p.hpp settings.cpp settings_p.hpp types.cpp utils.cpp @@ -80,7 +77,7 @@ set_target_properties( ) # Qt MOC -if (Qt6_FOUND AND COMMAND qt_enable_autogen_tool) +if(Qt6_FOUND AND COMMAND qt_enable_autogen_tool) qt_enable_autogen_tool(Core "moc" ON) endif() @@ -90,11 +87,6 @@ target_compile_definitions( PRIVATE QT_BUILD_MAPLIBRE_CORE_LIB ) -# static? -# target_compile_definitions( -# Core -# PUBLIC QT_MAPLIBRE_STATIC -# ) # Common include directories target_include_directories( @@ -106,6 +98,7 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/style ${CMAKE_CURRENT_BINARY_DIR}/include ${MLN_CORE_PATH}/src + ${MLN_CORE_PATH}/platform/qt/src ) # Common link libraries @@ -117,20 +110,26 @@ target_link_libraries( Qt${QT_VERSION_MAJOR}::Network PRIVATE $ - $ $ $ ) -if (NOT MLN_QT_WITH_INTERNAL_SQLITE) +if(NOT MLN_QT_WITH_INTERNAL_SQLITE) target_link_libraries( Core PUBLIC Qt${QT_VERSION_MAJOR}::Sql ) endif() +foreach(target ${MLN_QT_VENDOR_LIBRARIES}) + target_link_libraries( + Core + PRIVATE + $ + ) +endforeach() # Apple specifics -if (APPLE) +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set_target_properties( Core PROPERTIES @@ -156,7 +155,8 @@ endif() install( EXPORT ${MLN_QT_NAME}CoreTargets NAMESPACE ${MLN_QT_NAMESPACE} - DESTINATION ${CMAKECONFIG_INSTALL_DIR}) + DESTINATION ${CMAKECONFIG_INSTALL_DIR} +) install( DIRECTORY ${CMAKE_SOURCE_DIR}/vendor/maplibre-native/include/mbgl diff --git a/src/core/map.cpp b/src/core/map.cpp index 185f015..d3ff668 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -9,7 +9,8 @@ #include "conversion_p.hpp" #include "geojson_p.hpp" #include "map_observer_p.hpp" -#include "renderer_observer_p.hpp" + +#include "utils/renderer_observer.hpp" #include #include diff --git a/src/core/map_renderer.cpp b/src/core/map_renderer.cpp index dd3a7c9..6b16a9c 100644 --- a/src/core/map_renderer.cpp +++ b/src/core/map_renderer.cpp @@ -5,7 +5,7 @@ #include "map_renderer_p.hpp" -#include "scheduler_p.hpp" +#include "utils/scheduler.hpp" #include diff --git a/src/core/map_renderer_p.hpp b/src/core/map_renderer_p.hpp index 7332962..b9a087c 100644 --- a/src/core/map_renderer_p.hpp +++ b/src/core/map_renderer_p.hpp @@ -5,9 +5,10 @@ #pragma once -#include "renderer_backend_p.hpp" #include "settings.hpp" +#include "utils/renderer_backend.hpp" + #include #include #include diff --git a/src/core/renderer_backend.cpp b/src/core/renderer_backend.cpp deleted file mode 100644 index 0e01d16..0000000 --- a/src/core/renderer_backend.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2023 MapLibre contributors -// Copyright (C) 2019 Mapbox, Inc. - -// SPDX-License-Identifier: BSD-2-Clause - -#include "renderer_backend_p.hpp" - -#include -#include - -#include - -#include - -namespace QMapLibre { - -class RenderableResource final : public mbgl::gl::RenderableResource { -public: - explicit RenderableResource(RendererBackend &backend_) - : backend(backend_) {} - - void bind() override { - assert(mbgl::gfx::BackendScope::exists()); - backend.restoreFramebufferBinding(); - backend.setViewport(0, 0, backend.getSize()); - } - -private: - RendererBackend &backend; -}; - -RendererBackend::RendererBackend(const mbgl::gfx::ContextMode mode) - : mbgl::gl::RendererBackend(mode), - mbgl::gfx::Renderable({0, 0}, std::make_unique(*this)) {} - -RendererBackend::~RendererBackend() = default; - -void RendererBackend::updateAssumedState() { - assumeFramebufferBinding(ImplicitFramebufferBinding); - assumeViewport(0, 0, size); -} - -void RendererBackend::restoreFramebufferBinding() { - setFramebufferBinding(m_fbo); -} - -void RendererBackend::updateFramebuffer(quint32 fbo, const mbgl::Size &newSize) { - m_fbo = fbo; - size = newSize; -} - -/*! - Initializes an OpenGL extension function such as Vertex Array Objects (VAOs), - required by MapLibre Native engine. -*/ -mbgl::gl::ProcAddress RendererBackend::getExtensionFunctionPointer(const char *name) { - QOpenGLContext *thisContext = QOpenGLContext::currentContext(); - return thisContext->getProcAddress(name); -} - -} // namespace QMapLibre diff --git a/src/core/renderer_backend_p.hpp b/src/core/renderer_backend_p.hpp deleted file mode 100644 index e8fc337..0000000 --- a/src/core/renderer_backend_p.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 MapLibre contributors -// Copyright (C) 2019 Mapbox, Inc. - -// SPDX-License-Identifier: BSD-2-Clause - -#pragma once - -#include -#include - -#include - -namespace QMapLibre { - -class RendererBackend final : public mbgl::gl::RendererBackend, public mbgl::gfx::Renderable { -public: - explicit RendererBackend(mbgl::gfx::ContextMode mode); - ~RendererBackend() override; - - void updateFramebuffer(quint32 fbo, const mbgl::Size &newSize); - void restoreFramebufferBinding(); - - // mbgl::gfx::RendererBackend implementation -public: - mbgl::gfx::Renderable &getDefaultRenderable() override { return *this; } - -protected: - // No-op, implicit mode. - void activate() override {} - void deactivate() override {} - - // mbgl::gl::RendererBackend implementation -protected: - mbgl::gl::ProcAddress getExtensionFunctionPointer(const char *name) override; - void updateAssumedState() override; - -private: - quint32 m_fbo{}; - - Q_DISABLE_COPY(RendererBackend) -}; - -} // namespace QMapLibre diff --git a/src/core/renderer_observer_p.hpp b/src/core/renderer_observer_p.hpp deleted file mode 100644 index 5b02d50..0000000 --- a/src/core/renderer_observer_p.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2023 MapLibre contributors -// Copyright (C) 2019 Mapbox, Inc. - -// SPDX-License-Identifier: BSD-2-Clause - -#pragma once - -#include -#include -#include -#include -#include - -#include - -namespace QMapLibre { - -// Forwards RendererObserver signals to the given -// Delegate RendererObserver on the given RunLoop -class RendererObserver final : public mbgl::RendererObserver { -public: - RendererObserver(mbgl::util::RunLoop &mapRunLoop, mbgl::RendererObserver &delegate_) - : mailbox(std::make_shared(mapRunLoop)), - delegate(delegate_, mailbox) {} - - ~RendererObserver() final { mailbox->close(); } - - void onInvalidate() final { delegate.invoke(&mbgl::RendererObserver::onInvalidate); } - - void onResourceError(std::exception_ptr err) final { - delegate.invoke(&mbgl::RendererObserver::onResourceError, err); - } - - void onWillStartRenderingMap() final { delegate.invoke(&mbgl::RendererObserver::onWillStartRenderingMap); } - - void onWillStartRenderingFrame() final { delegate.invoke(&mbgl::RendererObserver::onWillStartRenderingFrame); } - - void onDidFinishRenderingFrame(RenderMode mode, bool repaintNeeded, bool placementChanged) final { - delegate.invoke(&mbgl::RendererObserver::onDidFinishRenderingFrame, mode, repaintNeeded, placementChanged); - } - - void onDidFinishRenderingMap() final { delegate.invoke(&mbgl::RendererObserver::onDidFinishRenderingMap); } - -private: - std::shared_ptr mailbox{}; - mbgl::ActorRef delegate; -}; - -} // namespace QMapLibre diff --git a/src/core/scheduler.cpp b/src/core/scheduler.cpp deleted file mode 100644 index 18252f5..0000000 --- a/src/core/scheduler.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2023 MapLibre contributors -// Copyright (C) 2019 Mapbox, Inc. - -// SPDX-License-Identifier: BSD-2-Clause - -#include "scheduler_p.hpp" - -#include - -#include - -namespace QMapLibre { - -Scheduler::Scheduler() = default; - -Scheduler::~Scheduler() { - MBGL_VERIFY_THREAD(tid); -} - -void Scheduler::schedule(std::function function) { - const std::lock_guard lock(m_taskQueueMutex); - m_taskQueue.push(std::move(function)); - - // Need to force the main thread to wake - // up this thread and process the events. - emit needsProcessing(); -} - -void Scheduler::processEvents() { - std::queue> taskQueue; - { - const std::unique_lock lock(m_taskQueueMutex); - std::swap(taskQueue, m_taskQueue); - } - - while (!taskQueue.empty()) { - auto& function = taskQueue.front(); - if (function) { - function(); - } - taskQueue.pop(); - } -} - -} // namespace QMapLibre diff --git a/src/core/scheduler_p.hpp b/src/core/scheduler_p.hpp deleted file mode 100644 index 4f5673f..0000000 --- a/src/core/scheduler_p.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 MapLibre contributors -// Copyright (C) 2019 Mapbox, Inc. - -// SPDX-License-Identifier: BSD-2-Clause - -#pragma once - -#include -#include - -#include - -#include -#include -#include - -namespace QMapLibre { - -class Scheduler : public QObject, public mbgl::Scheduler { - Q_OBJECT - -public: - Scheduler(); - ~Scheduler() override; - - // mbgl::Scheduler implementation. - void schedule(std::function function) final; - mapbox::base::WeakPtr makeWeakPtr() override { return weakFactory.makeWeakPtr(); } - - void processEvents(); - -signals: - void needsProcessing(); - -private: - MBGL_STORE_THREAD(tid); - - std::mutex m_taskQueueMutex; - std::queue> m_taskQueue; - mapbox::base::WeakPtrFactory weakFactory{this}; -}; - -} // namespace QMapLibre diff --git a/src/location/CMakeLists.txt b/src/location/CMakeLists.txt index 20d6227..66e4487 100644 --- a/src/location/CMakeLists.txt +++ b/src/location/CMakeLists.txt @@ -26,7 +26,7 @@ set_target_properties( ) # Qt MOC -if (Qt6_FOUND AND COMMAND qt_enable_autogen_tool) +if(Qt6_FOUND AND COMMAND qt_enable_autogen_tool) qt_enable_autogen_tool(Location "moc" ON) endif() @@ -62,7 +62,7 @@ target_link_libraries( ) # Apple specifics -if (APPLE) +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set_target_properties( Location PROPERTIES @@ -103,7 +103,11 @@ install( PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${MLN_QT_NAME}Location" ) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/macros.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${MLN_QT_NAME}LocationMacros.cmake" COPYONLY) +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/macros.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${MLN_QT_NAME}LocationMacros.cmake" + COPYONLY +) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${MLN_QT_NAME}LocationMacros.cmake diff --git a/src/location/plugins/CMakeLists.txt b/src/location/plugins/CMakeLists.txt index 949cae0..71f0bf9 100644 --- a/src/location/plugins/CMakeLists.txt +++ b/src/location/plugins/CMakeLists.txt @@ -1,14 +1,18 @@ # QtLocation plugin if(COMMAND qt_add_plugin) - qt_add_plugin(${MLN_QT_GEOSERVICES_PLUGIN} + qt_add_plugin( + ${MLN_QT_GEOSERVICES_PLUGIN} CLASS_NAME QGeoServiceProviderFactoryMapLibre OUTPUT_TARGETS GeoServicesPluginOutputTargets PLUGIN_TYPE geoservices qgeoserviceproviderplugin.cpp qgeoserviceproviderplugin.hpp ) else() - add_library(${MLN_QT_GEOSERVICES_PLUGIN} SHARED - qgeoserviceproviderplugin.cpp qgeoserviceproviderplugin.hpp) + add_library( + ${MLN_QT_GEOSERVICES_PLUGIN} + SHARED + qgeoserviceproviderplugin.cpp qgeoserviceproviderplugin.hpp + ) target_compile_definitions(${MLN_QT_GEOSERVICES_PLUGIN} PRIVATE QT_PLUGIN) endif() @@ -70,7 +74,8 @@ set(Plugin_Sources ) if(COMMAND qt_add_qml_module) - qt_add_qml_module(${MLN_QT_QML_PLUGIN} + qt_add_qml_module( + ${MLN_QT_QML_PLUGIN} URI QtLocation.MapLibre VERSION ${PROJECT_VERSION} PLUGIN_TARGET ${MLN_QT_QML_PLUGIN} @@ -82,18 +87,40 @@ if(COMMAND qt_add_qml_module) OUTPUT_TARGETS QmlPluginOutputTargets SOURCES ${Plugin_Sources} ) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/qmldir.in" "${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/qmldir" @ONLY) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/qmldir.in" + "${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/qmldir" + @ONLY + ) else() - add_library(${MLN_QT_QML_PLUGIN} SHARED ${Plugin_Sources} legacy/qml_module.cpp legacy/qml_registration.cpp) - target_compile_definitions(${MLN_QT_QML_PLUGIN} PRIVATE QT_PLUGIN) - target_include_directories(${MLN_QT_QML_PLUGIN} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + add_library( + ${MLN_QT_QML_PLUGIN} + SHARED + ${Plugin_Sources} + legacy/qml_module.cpp + legacy/qml_registration.cpp + ) + target_compile_definitions( + ${MLN_QT_QML_PLUGIN} + PRIVATE + QT_PLUGIN + ) + target_include_directories( + ${MLN_QT_QML_PLUGIN} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ) set_target_properties( ${MLN_QT_QML_PLUGIN} PROPERTIES AUTOMOC ON LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre" ) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/legacy/qmldir.in" "${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/qmldir" @ONLY) + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/legacy/qmldir.in" + "${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/qmldir" + @ONLY + ) endif() set_property(TARGET ${MLN_QT_QML_PLUGIN} PROPERTY EXPORT_NAME PluginQml) @@ -140,10 +167,10 @@ install( DESTINATION "qml/QtLocation/MapLibre" ) -if (COMMAND qt_add_qml_module) +if(COMMAND qt_add_qml_module) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/${MLN_QT_QML_PLUGIN}.qmltypes" DESTINATION "qml/QtLocation/MapLibre" -) + ) endif() diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 1de11e0..4e9dcea 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -41,7 +41,7 @@ set_target_properties( ) # Qt MOC -if (Qt6_FOUND AND COMMAND qt_enable_autogen_tool) +if(Qt6_FOUND AND COMMAND qt_enable_autogen_tool) qt_enable_autogen_tool(Widgets "moc" ON) endif() @@ -73,7 +73,7 @@ target_link_libraries( $ $ ) -if (Qt6_FOUND) +if(Qt6_FOUND) target_link_libraries( Widgets PUBLIC @@ -88,7 +88,7 @@ else() endif() # Apple specifics -if (APPLE) +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set_target_properties( Widgets PROPERTIES diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 758e38f..310b920 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,15 @@ -if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") +if( + CMAKE_SYSTEM_NAME STREQUAL "Android" + OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten" + OR CMAKE_SYSTEM_NAME STREQUAL "iOS" +) return() endif() add_subdirectory(core) -if (MLN_QT_WITH_LOCATION) +if(MLN_QT_WITH_LOCATION) add_subdirectory(qml) endif() -if (MLN_QT_WITH_WIDGETS) +if(MLN_QT_WITH_WIDGETS) add_subdirectory(widgets) endif() diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 2760229..958d1d4 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -1,4 +1,4 @@ -if (Qt5_FOUND) +if(Qt5_FOUND) return() endif() @@ -7,7 +7,7 @@ set(test_sources map_tester.cpp map_tester.hpp test_core.cpp ) -if (COMMAND qt_add_executable) +if(COMMAND qt_add_executable) qt_add_executable(test_mln_core ${test_sources}) else() add_executable(test_mln_core ${test_sources}) @@ -36,7 +36,10 @@ if(MLN_QT_WITH_CLANG_TIDY) set_target_properties(test_mln_core PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") endif() -add_test(NAME test_mln_core COMMAND $) +add_test( + NAME test_mln_core + COMMAND $ +) set_tests_properties( test_mln_core PROPERTIES diff --git a/test/qml/CMakeLists.txt b/test/qml/CMakeLists.txt index f317792..5f56983 100644 --- a/test/qml/CMakeLists.txt +++ b/test/qml/CMakeLists.txt @@ -1,11 +1,12 @@ -if (COMMAND qt_add_executable) +if(COMMAND qt_add_executable) qt_add_executable(test_mln_qml test_qml.cpp) else() add_executable(test_mln_qml test_qml.cpp) endif() find_package(Qt${QT_VERSION_MAJOR} COMPONENTS QuickTest REQUIRED) -target_link_libraries(test_mln_qml +target_link_libraries( + test_mln_qml PRIVATE Qt${QT_VERSION_MAJOR}::QuickTest $ @@ -15,7 +16,10 @@ if(MLN_QT_WITH_CLANG_TIDY) set_target_properties(test_mln_qml PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") endif() -add_test(NAME test_mln_qml COMMAND $ -input ${CMAKE_CURRENT_SOURCE_DIR}/qt${QT_VERSION_MAJOR}) +add_test( + NAME test_mln_qml + COMMAND $ -input ${CMAKE_CURRENT_SOURCE_DIR}/qt${QT_VERSION_MAJOR} +) set_tests_properties( test_mln_qml PROPERTIES diff --git a/test/widgets/CMakeLists.txt b/test/widgets/CMakeLists.txt index c49e983..961e9ed 100644 --- a/test/widgets/CMakeLists.txt +++ b/test/widgets/CMakeLists.txt @@ -3,7 +3,7 @@ set(test_sources gl_tester.cpp gl_tester.hpp test_widgets.cpp ) -if (COMMAND qt_add_executable) +if(COMMAND qt_add_executable) qt_add_executable(test_mln_widgets ${test_sources}) else() add_executable(test_mln_widgets ${test_sources}) @@ -33,4 +33,7 @@ if(MLN_QT_WITH_CLANG_TIDY) set_target_properties(test_mln_widgets PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") endif() -add_test(NAME test_mln_widgets COMMAND $) +add_test( + NAME test_mln_widgets + COMMAND $ +) diff --git a/vendor/maplibre-native b/vendor/maplibre-native index 85c0ab7..2b87bd9 160000 --- a/vendor/maplibre-native +++ b/vendor/maplibre-native @@ -1 +1 @@ -Subproject commit 85c0ab7e5145213194b2a4b73997f10fab1d1cd8 +Subproject commit 2b87bd9eb30ed8567c4a1dfb8a9c690a5464151a