Skip to content

Commit 0e7ff62

Browse files
Update GitHub Actions workflows to use CMake presets (#1223)
* Initial plan * Update GitHub Actions to use CMake presets for compilers workflow Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: carsonRadtke <10507970+carsonRadtke@users.noreply.github.com>
1 parent b14edaa commit 0e7ff62

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

.github/workflows/cmake/action.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
name: Composite CMake
22
inputs:
3+
cmake_preset:
4+
required: false
5+
type: string
6+
description: 'CMake preset name to use (if provided, other cmake_* inputs are ignored)'
37
cmake_generator:
48
required: false
59
type: string
610
default: 'Unix Makefiles'
711
cmake_build_type:
8-
required: true
12+
required: false
913
type: string
1014
default: ''
1115
cmake_cxx_compiler:
1216
required: false
1317
type: string
1418
gsl_cxx_standard:
15-
required: true
19+
required: false
1620
type: number
1721
extra_cmake_args:
1822
required: false
1923
type: string
2024
default: ''
2125
build_cmd:
22-
required: true
26+
required: false
2327
type: string
2428
default: 'make'
2529
test_cmd:
@@ -35,21 +39,40 @@ inputs:
3539
runs:
3640
using: composite
3741
steps:
38-
- name: Create build directory
42+
- name: Configure CMake (with preset)
43+
if: ${{ inputs.cmake_preset != '' }}
44+
run: cmake --preset ${{ inputs.cmake_preset }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ${{ inputs.extra_cmake_args }}
45+
shell: ${{ inputs.shell }}
46+
47+
- name: Create build directory (without preset)
48+
if: ${{ inputs.cmake_preset == '' }}
3949
run: mkdir build
4050
shell: ${{ inputs.shell }}
4151

42-
- name: Configure CMake
52+
- name: Configure CMake (without preset)
53+
if: ${{ inputs.cmake_preset == '' }}
4354
working-directory: build
4455
run: cmake -G "${{ inputs.cmake_generator }}" -DCMAKE_BUILD_TYPE=${{ inputs.cmake_build_type }} -DCMAKE_CXX_COMPILER=${{ inputs.cmake_cxx_compiler }} -DGSL_CXX_STANDARD=${{ inputs.gsl_cxx_standard }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ${{ inputs.extra_cmake_args }} ..
4556
shell: ${{ inputs.shell }}
4657

47-
- name: Build
58+
- name: Build (with preset)
59+
if: ${{ inputs.cmake_preset != '' }}
60+
run: cmake --build --preset ${{ inputs.cmake_preset }}
61+
shell: ${{ inputs.shell }}
62+
63+
- name: Build (without preset)
64+
if: ${{ inputs.cmake_preset == '' }}
4865
working-directory: build
4966
run: ${{ inputs.build_cmd }}
5067
shell: ${{ inputs.shell }}
5168

52-
- name: Test
69+
- name: Test (with preset)
70+
if: ${{ inputs.cmake_preset != '' }}
71+
run: ctest --preset ${{ inputs.cmake_preset }} --output-on-failure --no-compress-output
72+
shell: ${{ inputs.shell }}
73+
74+
- name: Test (without preset)
75+
if: ${{ inputs.cmake_preset == '' }}
5376
working-directory: build
5477
run: ${{ inputs.test_cmd }}
5578
shell: ${{ inputs.shell }}

.github/workflows/compilers.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ jobs:
3535
- name: Run CMake (configure, build, test)
3636
uses: ./.github/workflows/cmake
3737
with:
38-
cmake_build_type: ${{ matrix.build_type }}
39-
cmake_cxx_compiler: g++-${{ matrix.gcc_version }}
40-
gsl_cxx_standard: ${{ matrix.cxx_version }}
38+
cmake_preset: gcc-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }}
4139

4240
clang:
4341
strategy:
@@ -58,9 +56,7 @@ jobs:
5856
- name: Run CMake (configure, build, test)
5957
uses: ./.github/workflows/cmake
6058
with:
61-
cmake_build_type: ${{ matrix.build_type }}
62-
cmake_cxx_compiler: clang++-${{ matrix.clang_version }}
63-
gsl_cxx_standard: ${{ matrix.cxx_version }}
59+
cmake_preset: clang-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }}
6460

6561
xcode:
6662
strategy:
@@ -78,9 +74,7 @@ jobs:
7874
- name: Run CMake (configure, build, test)
7975
uses: ./.github/workflows/cmake
8076
with:
81-
cmake_build_type: ${{ matrix.build_type }}
82-
cmake_cxx_compiler: clang++
83-
gsl_cxx_standard: ${{ matrix.cxx_version }}
77+
cmake_preset: clang-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }}
8478
extra_cmake_args: '-DCMAKE_CXX_FLAGS="-isysroot \"$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk\""'
8579

8680
VisualStudio:
@@ -99,11 +93,7 @@ jobs:
9993
- name: Run CMake (configure, build, test)
10094
uses: ./.github/workflows/cmake
10195
with:
102-
cmake_generator: ${{ matrix.generator }}
103-
cmake_build_type: ${{ matrix.build_type }}
104-
gsl_cxx_standard: ${{ matrix.cxx_version }}
96+
cmake_preset: msvc-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }}
10597
extra_cmake_args: ${{ matrix.extra_args }}
106-
build_cmd: msbuild GSL.sln
107-
test_cmd: ctest . --output-on-failure --no-compress-output
10898
shell: pwsh
10999

0 commit comments

Comments
 (0)