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 Feb 18, 2024
1 parent 80350b0 commit f3b3c94
Show file tree
Hide file tree
Showing 18 changed files with 971 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .github/actions/qt5-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/maplibre/linux-builder:centos7-gcc8-cmake3.19
FROM ghcr.io/maplibre/linux-builder:centos7-gcc8

# Copy and set the entry point
COPY entrypoint.sh /entrypoint.sh
Expand Down
14 changes: 4 additions & 10 deletions .github/actions/qt5-build/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ export CCACHE_DIR="$GITHUB_WORKSPACE/.ccache"
export PATH="$Qt5_Dir/bin:$PATH"
qmake --version

mkdir build && cd build
cmake ../source/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_INSTALL_PREFIX="../install"
ninja
# ninja test
ninja install
# Main project
pushd source
cmake --workflow --preset Linux-legacy-CI
popd
46 changes: 16 additions & 30 deletions .github/actions/qt6-build/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,24 @@ export CCACHE_DIR="$GITHUB_WORKSPACE/.ccache"
export PATH="$Qt6_DIR/bin:$PATH"
qmake --version

mkdir build && cd build
qt-cmake ../source/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_INSTALL_PREFIX="../install"
ninja
# ninja test
ninja install
cd ..
# Main project
pushd source
cmake --workflow --preset Linux-CI
popd

export PREFIX_PATH="$(pwd)/install"
mkdir install && pushd install
tar xf ../build/qt6-Linux/maplibre-native-qt_*.tar.bz2
mv maplibre-native-qt_* maplibre-native-qt
popd

export QMapLibre_DIR="$(pwd)/install/maplibre-native-qt"

# QtQuick example
mkdir build-example-quick && cd build-example-quick
qt-cmake ../source/examples/quick/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_PREFIX_PATH="$PREFIX_PATH"
ninja
cd ..
pushd source/examples/quick
cmake --workflow --preset default
popd

# QtWidgets example
mkdir build-example-widgets && cd build-example-widgets
qt-cmake ../source/examples/widgets/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_PREFIX_PATH="$PREFIX_PATH"
ninja
cd ..
pushd source/examples/widgets
cmake --workflow --preset default
popd
96 changes: 38 additions & 58 deletions .github/workflows/Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,36 @@ concurrency:

jobs:
build-and-test:
name: Build QMapLibre for Linux (Qt${{ matrix.qt_version}}, ${{ matrix.compiler }})
name: Build MapLibre Native Qt for Linux (Qt${{ matrix.qt_version}}, ${{ matrix.compiler }})
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- qt_series: 5
qt_version: 5.15.2
qt_modules: ""
preset: Linux-legacy-CI
compiler: default
- qt_series: 6
qt_version: 6.5.3
qt_modules: qtlocation qtpositioning
preset: Linux-CI
compiler: default
- qt_series: 6
qt_version: 6.6.2
qt_modules: qtlocation qtpositioning
preset: Linux-CI
compiler: default
- qt_series: 6
qt_version: 6.6.2
qt_modules: qtlocation qtpositioning
preset: Linux-coverage
compiler: gcc-13
gcov: gcov-13

env:
PRESET: ${{ matrix.preset }}

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -132,99 +139,79 @@ jobs:
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: Linux_QMapLibre_${{ matrix.qt_version }}_${{ matrix.compiler }}
key: Linux_${{ matrix.qt_version }}_${{ matrix.compiler }}
max-size: 200M

- name: Build QMapLibre (Qt5)
- name: Build (Qt5)
if: matrix.qt_series == 5
uses: ./source/.github/actions/qt5-build

- name: Build QMapLibre (Qt6)
- name: Build (Qt6)
if: matrix.qt_series == 6 && matrix.compiler == 'default'
uses: ./source/.github/actions/qt6-build

- name: Build QMapLibre (Qt6, custom compiler)
- name: Build (Qt6, custom compiler)
if: matrix.qt_series == 6 && matrix.compiler != 'default'
env:
CC: ${{ steps.install_compiler.outputs.cc }}
CXX: ${{ steps.install_compiler.outputs.cxx }}
GCOV: ${{ matrix.gcov }}
working-directory: source
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" \
-DMLN_QT_WITH_COVERAGE=ON \
-DGCOV_PATH="$(which ${GCOV})"
ninja
ninja install
export GCOV_PATH="$(which ${GCOV})"
cmake --workflow --preset ${PRESET}
- name: Run tests
if: matrix.qt_series == 6 && matrix.compiler != 'default'
uses: coactions/setup-xvfb@v1
with:
run: ctest --output-on-failure
working-directory: build
working-directory: build/qt6-Linux

- name: Run code coverage
if: matrix.qt_series == 6 && matrix.compiler != 'default'
uses: coactions/setup-xvfb@v1
with:
run: ninja coverage
working-directory: build
working-directory: build/qt6-Linux

- name: Build QtQuick Example (Qt6)
- name: Install
if: matrix.qt_series == 6 && matrix.compiler != 'default'
run: |
export PREFIX_PATH="$(pwd)/install"
mkdir build-example-quick && cd build-example-quick
qt-cmake ../source/examples/quick/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_PREFIX_PATH="$PREFIX_PATH"
ninja
- name: Build QtWidgets Example (Qt6)
mkdir install && cd install
tar xf ../build/qt${{ matrix.qt_series }}-Linux/maplibre-native-qt_*.tar.bz2
mv maplibre-native-qt_* maplibre-native-qt
- name: Build QtQuick Example
if: matrix.qt_series == 6 && matrix.compiler != 'default'
working-directory: source/examples/quick
run: |
export PREFIX_PATH="$(pwd)/install"
mkdir build-example-widgets && cd build-example-widgets
qt-cmake ../source/examples/widgets/ \
-G Ninja \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_PREFIX_PATH="$PREFIX_PATH"
ninja
- name: Compress installation
if: matrix.compiler == 'default'
export QMapLibre_DIR="$GITHUB_WORKSPACE/install/maplibre-native-qt"
cmake --workflow --preset default
- name: Build QtWidgets Example
if: matrix.qt_series == 6 && matrix.compiler != 'default'
working-directory: source/examples/widgets
run: |
pushd install
tar cjvf ../QMapLibre_Linux.tar.bz2 *
popd
export QMapLibre_DIR="$GITHUB_WORKSPACE/install/maplibre-native-qt"
cmake --workflow --preset default
- name: Upload installation
if: matrix.compiler == 'default'
uses: actions/upload-artifact@v4
with:
name: QMapLibre_Linux_${{ matrix.qt_version }}
path: QMapLibre_Linux.tar.bz2
name: Linux_${{ matrix.qt_version }}
path: build/qt${{ matrix.qt_series }}-Linux/maplibre-native-qt_*.tar.bz2

- name: Upload coverage reports to Codecov
if: matrix.qt_series == 6 && matrix.compiler != 'default'
uses: codecov/codecov-action@v3
with:
files: build/coverage.info
files: build/qt${{ matrix.qt_series }}-Linux/coverage.info
verbose: true

release:
name: Release QMapLibre
name: Release
if: github.ref_type == 'tag'
runs-on: ubuntu-22.04
needs: build-and-test
Expand All @@ -238,18 +225,11 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: QMapLibre_Linux_${{ matrix.qt_version }}

- name: Make tarball
env:
TAG_NAME: ${{ github.ref_name }}
QT_VERSION: ${{ matrix.qt_version }}
run: |
mv QMapLibre_Linux.tar.bz2 QMapLibre_${TAG_NAME}_Qt${QT_VERSION}_Linux.tar.bz2
name: Linux_${{ matrix.qt_version }}

- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_Linux.tar.bz2
artifacts: maplibre-native-qt_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_Linux.tar.bz2
allowUpdates: true
draft: true
50 changes: 14 additions & 36 deletions .github/workflows/iOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ concurrency:

jobs:
build:
name: Build QMapLibre for iOS (Qt${{ matrix.qt_version}})
name: Build MapLibre Native Qt for iOS (Qt${{ matrix.qt_version}})
runs-on: macos-14
strategy:
matrix:
include:
- qt_version: 6.5.3
deployment_target: 14.0
preset: iOS-ccache
- qt_version: 6.6.2
deployment_target: 14.0
preset: iOS-ccache

env:
DEPLOYMENT_TARGET: ${{ matrix.deployment_target }}
PRESET: ${{ matrix.preset }}

steps:
- name: Checkout
Expand Down Expand Up @@ -90,38 +90,23 @@ jobs:
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: iOS_QMapLibre_${{ matrix.qt_version }}
key: iOS_${{ matrix.qt_version }}
max-size: 200M

- name: Build QMapLibre
- name: Build
working-directory: source
run: |
mkdir build && cd build
qt-cmake ../source/ \
-G"Ninja Multi-Config" \
-DCMAKE_CONFIGURATION_TYPES="Release;Debug" \
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_INSTALL_PREFIX="../install" \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="${DEPLOYMENT_TARGET}" \
-DQT_HOST_PATH="$(readlink -f "$Qt6_DIR/../macos")"
ninja
ninja install
- name: Compress installation
run: |
pushd install
tar cjvf ../QMapLibre_iOS.tar.bz2 *
popd
export QT_HOST_PATH="$(readlink -f "$Qt6_DIR/../macos")"
cmake --workflow --preset ${PRESET}
- name: Upload installation
uses: actions/upload-artifact@v4
with:
name: QMapLibre_iOS_${{ matrix.qt_version }}
path: QMapLibre_iOS.tar.bz2
name: iOS_${{ matrix.qt_version }}
path: build/qt6-iOS/maplibre-native-qt_*_iOS.tar.bz2

release:
name: Release QMapLibre
name: Release
if: github.ref_type == 'tag'
runs-on: macos-14
needs: build
Expand All @@ -135,18 +120,11 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
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: iOS_${{ matrix.qt_version }}

- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_iOS.tar.bz2
artifacts: maplibre-native-qt_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_iOS.tar.bz2
allowUpdates: true
draft: true
Loading

0 comments on commit f3b3c94

Please sign in to comment.