Skip to content

Commit

Permalink
Add CMake presets for easier usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ntadej committed Jan 28, 2024
1 parent de21698 commit 75f7e9f
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 49 deletions.
55 changes: 8 additions & 47 deletions .github/workflows/macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-ccache
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
Expand Down Expand Up @@ -116,39 +111,12 @@ jobs:
key: macOS_QMapLibre_${{ matrix.qt_version }}_${{ matrix.compiler }}
max-size: 200M

- name: Build QMapLibre (Qt5)
if: matrix.qt_series == 5
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
- name: Build QMapLibre
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 ../source/ --workflow --preset ${PRESET}
- name: Build QtQuick Example (Qt 6)
if: matrix.qt_series == 6
Expand Down Expand Up @@ -184,13 +152,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: |
Expand All @@ -205,7 +166,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'
Expand Down
26 changes: 24 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
14 changes: 14 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
65 changes: 65 additions & 0 deletions cmake/presets/Android.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
35 changes: 35 additions & 0 deletions cmake/presets/common.json
Original file line number Diff line number Diff line change
@@ -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 }
}
]
}
87 changes: 87 additions & 0 deletions cmake/presets/iOS.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
Loading

0 comments on commit 75f7e9f

Please sign in to comment.