From 9236c7e1c6ba6fa5f475aa2958d3bba6040b7e4a Mon Sep 17 00:00:00 2001 From: Tadej Novak Date: Sun, 28 Jan 2024 14:10:18 +0100 Subject: [PATCH] Add CMake presets for easier usage --- .github/workflows/macOS.yml | 59 ++---------- CMakeLists.txt | 26 ++++- CMakePresets.json | 14 +++ cmake/presets/Android.json | 65 +++++++++++++ cmake/presets/common.json | 35 +++++++ cmake/presets/iOS.json | 87 +++++++++++++++++ cmake/presets/macOS.json | 186 ++++++++++++++++++++++++++++++++++++ 7 files changed, 420 insertions(+), 52 deletions(-) create mode 100644 CMakePresets.json create mode 100644 cmake/presets/Android.json create mode 100644 cmake/presets/common.json create mode 100644 cmake/presets/iOS.json create mode 100644 cmake/presets/macOS.json diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml index 0a7c557..a42999e 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/macOS.yml @@ -47,32 +47,27 @@ jobs: - qt_series: 5 qt_version: 5.15.2 qt_modules: "" + preset: macOS-legacy-ccache compiler: default - deployment_target: 10.13 - deployment_arch: x86_64 - qt_series: 6 qt_version: 6.5.3 qt_modules: qtlocation qtpositioning + preset: macOS-ccache compiler: default - deployment_target: 11.0 - deployment_arch: x86_64 - qt_series: 6 qt_version: 6.6.1 qt_modules: qtlocation qtpositioning + preset: macOS-ccache compiler: default - deployment_target: 11.0 - deployment_arch: x86_64;arm64 - qt_series: 6 qt_version: 6.6.1 qt_modules: qtlocation qtpositioning + preset: macOS-clang-tidy compiler: llvm@17 - deployment_target: 11.0 - deployment_arch: x86_64 env: COMPILER: ${{ matrix.compiler }} - DEPLOYMENT_TARGET: ${{ matrix.deployment_target }} - DEPLOYMENT_ARCH: ${{ matrix.deployment_arch }} + PRESET: ${{ matrix.preset }} steps: - name: Checkout @@ -116,39 +111,10 @@ jobs: key: macOS_QMapLibre_${{ matrix.qt_version }}_${{ matrix.compiler }} max-size: 200M - - name: Build QMapLibre (Qt5) - if: matrix.qt_series == 5 + - name: Build QMapLibre + working-directory: source run: | - mkdir build && cd build - cmake ../source/ \ - -G Ninja \ - -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ - -DCMAKE_C_COMPILER_LAUNCHER="ccache" \ - -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ - -DCMAKE_INSTALL_PREFIX="../install" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="${DEPLOYMENT_TARGET}" - ninja - ninja test - ninja install - - - name: Build QMapLibre (Qt 6) - if: matrix.qt_series == 6 - env: - MLN_QT_WITH_CLANG_TIDY: ${{ matrix.compiler != 'default' }} - run: | - mkdir build && cd build - qt-cmake ../source/ \ - -G Ninja \ - -DCMAKE_BUILD_TYPE="RelWithDebInfo" \ - -DCMAKE_C_COMPILER_LAUNCHER="ccache" \ - -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ - -DCMAKE_INSTALL_PREFIX="../install" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="${DEPLOYMENT_TARGET}" \ - -DCMAKE_OSX_ARCHITECTURES="${DEPLOYMENT_ARCH}" \ - -DMLN_QT_WITH_CLANG_TIDY="${MLN_QT_WITH_CLANG_TIDY}" - ninja - ninja test - ninja install + cmake --workflow --preset ${PRESET} - name: Build QtQuick Example (Qt 6) if: matrix.qt_series == 6 @@ -184,13 +150,6 @@ jobs: ninja ninja install - - name: Compress installation - if: matrix.compiler == 'default' - run: | - pushd install - tar cjvf ../QMapLibre_macOS.tar.bz2 * - popd - - name: Compress examples if: matrix.qt_series == 6 && matrix.compiler == 'default' run: | @@ -205,7 +164,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: QMapLibre_macOS_${{ matrix.qt_version }} - path: QMapLibre_macOS.tar.bz2 + path: build/qt${{ matrix.qt_series }}-macOS/maplibre-native-qt_*.tar.bz2 - name: Upload examples if: matrix.qt_series == 6 && matrix.compiler == 'default' diff --git a/CMakeLists.txt b/CMakeLists.txt index c843c21..97c2f4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ message(STATUS "Version ${MLN_QT_VERSION}") # Project definition project( - MapLibreNativeQt + maplibre-native-qt VERSION "${MLN_QT_VERSION}" DESCRIPTION "MapLibre Native Qt Bindings" LANGUAGES CXX @@ -85,7 +85,7 @@ endif() if(ANDROID) message(STATUS "Building for ABI: ${ANDROID_ABI}") set(CMAKE_STATIC_LIBRARY_SUFFIX "_${ANDROID_ABI}.a") -elseif(CMAKE_SYSTEM_NAME STREQUAL iOS) +elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS") set(CMAKE_DEBUG_POSTFIX "_debug") elseif(MSVC OR CMAKE_SYSTEM_NAME STREQUAL "Windows") set(CMAKE_DEBUG_POSTFIX "d") @@ -116,3 +116,25 @@ if(MLN_QT_WITH_COVERAGE) include(cmake/coverage.cmake) setup_target_for_coverage(coverage ${CMAKE_CTEST_COMMAND} "${CMAKE_BINARY_DIR}/coverage" "-V") endif() + +# Packaging +set(CPACK_GENERATOR TBZ2) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(CPACK_SYSTEM_NAME "macOS") +else() + set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}") +endif() +set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}_Qt${QT_VERSION}_${CPACK_SYSTEM_NAME}") +set(CPACK_SOURCE_GENERATOR TBZ2) +set(CPACK_SOURCE_IGNORE_FILES + "/docs/" + "/geometry-test-data/" + "\\\\.clang" + "\\\\.DS_Store" + "\\\\.git" + "\\\\.mason" + "\\\\.pre-commit-config.yaml" + "codecov.yml" +) + +include(CPack) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..cfb313d --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,14 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "include": [ + "cmake/presets/common.json", + "cmake/presets/macOS.json", + "cmake/presets/iOS.json", + "cmake/presets/Android.json" + ] +} diff --git a/cmake/presets/Android.json b/cmake/presets/Android.json new file mode 100644 index 0000000..b8e3bbe --- /dev/null +++ b/cmake/presets/Android.json @@ -0,0 +1,65 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "Android", + "displayName": "Android configuration using Qt6", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build/qt6-Android", + "toolchainFile": "$penv{Qt6_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "Android-ccache", + "displayName": "Android configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "Android"] + } + ], + "buildPresets": [ + { + "name": "Android", + "displayName": "Android build using Qt6", + "configurePreset": "Android" + }, + { + "name": "Android-ccache", + "displayName": "Android build using Qt6 and ccache", + "configurePreset": "Android-ccache" + } + ], + "packagePresets": [ + { + "name": "Android", + "displayName": "Android package using Qt6", + "configurePreset": "Android" + }, + { + "name": "Android-ccache", + "displayName": "Android package using Qt6 and ccache", + "configurePreset": "Android-ccache" + } + ], + "workflowPresets": [ + { + "name": "Android-ccache", + "displayName": "Android workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "Android-ccache" + }, + { + "type": "build", + "name": "Android-ccache" + }, + { + "type": "package", + "name": "Android-ccache" + } + ] + } + ] +} diff --git a/cmake/presets/common.json b/cmake/presets/common.json new file mode 100644 index 0000000..ead509e --- /dev/null +++ b/cmake/presets/common.json @@ -0,0 +1,35 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "dev", + "hidden": true, + "warnings": { + "dev": true, + "deprecated": true, + "uninitialized": false, + "unusedCli": true, + "systemVars": true + }, + "errors": { + "dev": true, + "deprecated": true + } + }, + { + "name": "ccache", + "hidden": true, + "cacheVariables": { + "CMAKE_C_COMPILER_LAUNCHER": "ccache", + "CMAKE_CXX_COMPILER_LAUNCHER": "ccache" + } + } + ], + "testPresets": [ + { + "name": "default", + "hidden": true, + "output": { "outputOnFailure": true } + } + ] +} diff --git a/cmake/presets/iOS.json b/cmake/presets/iOS.json new file mode 100644 index 0000000..47eb982 --- /dev/null +++ b/cmake/presets/iOS.json @@ -0,0 +1,87 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "iOS", + "displayName": "iOS configuration using Qt6", + "generator": "Ninja Multi-Config", + "binaryDir": "${sourceParentDir}/build/qt6-iOS", + "toolchainFile": "$penv{Qt6_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "Release;Debug", + "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64", + "CMAKE_OSX_DEPLOYMENT_TARGET": "14.0" + } + }, + { + "name": "iOS-ccache", + "displayName": "iOS configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "iOS"] + } + ], + "buildPresets": [ + { + "name": "iOS", + "displayName": "iOS release build using Qt6", + "configurePreset": "iOS", + "configuration": "Release" + }, + { + "name": "iOS-debug", + "displayName": "iOS debug build using Qt6", + "configurePreset": "iOS", + "configuration": "Debug" + }, + { + "name": "iOS-ccache", + "displayName": "iOS release build using Qt6 and ccache", + "configurePreset": "iOS-ccache", + "configuration": "Release" + }, + { + "name": "iOS-debug-ccache", + "displayName": "iOS debug build using Qt6 and ccache", + "configurePreset": "iOS-ccache", + "configuration": "Debug" + } + ], + "packagePresets": [ + { + "name": "iOS", + "displayName": "iOS package using Qt6", + "configurePreset": "iOS", + "configurations": ["Release", "Debug"] + }, + { + "name": "iOS-ccache", + "displayName": "iOS package using Qt6 and ccache", + "configurePreset": "iOS-ccache", + "configurations": ["Release", "Debug"] + } + ], + "workflowPresets": [ + { + "name": "iOS-ccache", + "displayName": "iOS workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "iOS-ccache" + }, + { + "type": "build", + "name": "iOS-debug-ccache" + }, + { + "type": "build", + "name": "iOS-ccache" + }, + { + "type": "package", + "name": "iOS-ccache" + } + ] + } + ] +} diff --git a/cmake/presets/macOS.json b/cmake/presets/macOS.json new file mode 100644 index 0000000..bea729a --- /dev/null +++ b/cmake/presets/macOS.json @@ -0,0 +1,186 @@ +{ + "version": 6, + "include": ["common.json"], + "configurePresets": [ + { + "name": "macOS", + "displayName": "macOS configuration using Qt6", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build/qt6-macOS", + "toolchainFile": "$penv{Qt6_DIR}/lib/cmake/Qt6/qt.toolchain.cmake", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64", + "CMAKE_OSX_DEPLOYMENT_TARGET": "11.0" + } + }, + { + "name": "macOS-ccache", + "displayName": "macOS configuration using Qt6 and ccache", + "inherits": ["dev", "ccache", "macOS"] + }, + { + "name": "macOS-clang-tidy", + "displayName": "macOS configuration using Qt6, ccache and clang-tidy", + "inherits": ["macOS-ccache"], + "cacheVariables": { + "CMAKE_OSX_ARCHITECTURES": "x86_64", + "MLN_QT_WITH_CLANG_TIDY": "ON" + } + }, + { + "name": "macOS-legacy", + "displayName": "macOS configuration using Qt5", + "generator": "Ninja", + "binaryDir": "${sourceParentDir}/build/qt5-macOS", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_OSX_ARCHITECTURES": "x86_64", + "CMAKE_OSX_DEPLOYMENT_TARGET": "10.13" + } + }, + { + "name": "macOS-legacy-ccache", + "displayName": "macOS configuration using Qt5 and ccache", + "inherits": ["dev", "ccache", "macOS-legacy"] + } + ], + "buildPresets": [ + { + "name": "macOS", + "displayName": "macOS build using Qt6", + "configurePreset": "macOS" + }, + { + "name": "macOS-ccache", + "displayName": "macOS build using Qt6 and ccache", + "configurePreset": "macOS-ccache" + }, + { + "name": "macOS-legacy", + "displayName": "macOS build using Qt5", + "configurePreset": "macOS-legacy" + }, + { + "name": "macOS-legacy-ccache", + "displayName": "macOS build using Qt5 and ccache", + "configurePreset": "macOS-legacy-ccache" + } + ], + "testPresets": [ + { + "name": "macOS", + "displayName": "macOS tests using Qt6", + "configurePreset": "macOS", + "inherits": ["default"] + }, + { + "name": "macOS-ccache", + "displayName": "macOS tests using Qt6 and ccache", + "configurePreset": "macOS-ccache", + "inherits": ["default"] + }, + { + "name": "macOS-legacy", + "displayName": "macOS tests using Qt5", + "configurePreset": "macOS-legacy", + "inherits": ["default"] + }, + { + "name": "macOS-legacy-ccache", + "displayName": "macOS tests using Qt5 and ccache", + "configurePreset": "macOS-legacy-ccache", + "inherits": ["default"] + } + ], + "packagePresets": [ + { + "name": "macOS", + "displayName": "macOS package using Qt6", + "configurePreset": "macOS" + }, + { + "name": "macOS-ccache", + "displayName": "macOS package using Qt6 and ccache", + "configurePreset": "macOS-ccache" + }, + { + "name": "macOS-legacy", + "displayName": "macOS package using Qt5", + "configurePreset": "macOS-legacy" + }, + { + "name": "macOS-legacy-ccache", + "displayName": "macOS package using Qt5 and ccache", + "configurePreset": "macOS-legacy-ccache" + } + ], + "workflowPresets": [ + { + "name": "macOS-ccache", + "displayName": "macOS workflow using Qt6 and ccache", + "steps": [ + { + "type": "configure", + "name": "macOS-ccache" + }, + { + "type": "build", + "name": "macOS-ccache" + }, + { + "type": "test", + "name": "macOS-ccache" + }, + { + "type": "package", + "name": "macOS-ccache" + } + ] + }, + { + "name": "macOS-clang-tidy", + "displayName": "macOS workflow using Qt6, ccache and clang-tidy", + "steps": [ + { + "type": "configure", + "name": "macOS-clang-tidy" + }, + { + "type": "build", + "name": "macOS-ccache" + }, + { + "type": "test", + "name": "macOS-ccache" + }, + { + "type": "package", + "name": "macOS-ccache" + } + ] + }, + { + "name": "macOS-legacy-ccache", + "displayName": "macOS workflow using Qt5 and ccache", + "steps": [ + { + "type": "configure", + "name": "macOS-legacy-ccache" + }, + { + "type": "build", + "name": "macOS-legacy-ccache" + }, + { + "type": "test", + "name": "macOS-legacy-ccache" + }, + { + "type": "package", + "name": "macOS-legacy-ccache" + } + ] + } + ] +}