Skip to content

Commit 93b4714

Browse files
committed
Reusable: Add option to choose minimal CMake version to use
1 parent 9fcaad5 commit 93b4714

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/reusable.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ on:
3131
required: false
3232
type: boolean
3333
default: true
34+
min_cmake_version:
35+
description: "Minimal required CMake version, defaults to 3.16."
36+
required: false
37+
type: string
38+
default: '3.16'
3439
enable_cygwin:
3540
description: "When enabled, Cygwin jobs will be added. Enabled by default."
3641
required: false
@@ -713,8 +718,44 @@ jobs:
713718
- { os: ubuntu-latest, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' }
714719
- { os: windows-2025, build_shared: ON, build_type: Debug, generator: 'Visual Studio 17 2022' }
715720
- { os: windows-2025, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 17 2022' }
721+
- { name: "Linux CMake", cmake_version: '${{inputs.minimal_cmake_version}}',
722+
os: ubuntu-latest, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' }
716723

717724
steps:
725+
- name: Cache CMake
726+
if: matrix.cmake_version
727+
id: cache-cmake
728+
uses: actions/cache@v4
729+
with:
730+
path: /tmp/cmake
731+
key: ${{runner.os}}-cmake-${{matrix.cmake_version}}
732+
733+
- name: Install CMake dependencies
734+
if: matrix.cmake_version
735+
run: |
736+
sudo apt-get -o Acquire::Retries=3 -y -q --no-install-suggests --no-install-recommends install curl libcurl4-openssl-dev libarchive-dev
737+
echo /tmp/cmake/bin >> $GITHUB_PATH
738+
739+
- name: Build CMake
740+
if: matrix.cmake_version && steps.cache-cmake.outputs.cache-hit != 'true'
741+
run: |
742+
version=${{matrix.cmake_version}}
743+
filename="cmake-$version.tar.gz"
744+
cd "$(mktemp -d)"
745+
wget https://cmake.org/files/v${version%.*}/$filename
746+
tar -xf $filename --strip-components=1
747+
flags=(
748+
"-DCMAKE_BUILD_TYPE=Release"
749+
"-DCMAKE_INSTALL_PREFIX=/tmp/cmake"
750+
"-B" "__build"
751+
"-Wno-dev" # Make configuring more silent
752+
"-DCMAKE_USE_SYSTEM_CURL=1" # Avoid failures caused by newer (system) OpenSSL in CMake < 3.10
753+
"-DCMAKE_CXX_FLAGS='-include cstdint -include limits'" # Fix missing includes in CMake < 3.10
754+
)
755+
cmake "${flags[@]}" .
756+
cmake --build __build -- -j 3
757+
cmake --build __build --target install
758+
718759
- uses: actions/checkout@v4
719760

720761
- name: Fetch Boost.CI

0 commit comments

Comments
 (0)