Skip to content

Commit c31617f

Browse files
use cmake presets instead of cmake settings (#1219)
* use cmake presets instead of cmake settings This change uses a cmake presets file in an effort allow for agentic AI to better switch between project settings. It replaces the old CMakeSettings.json for the more flexible CMakePresets.json. * 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 <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: carsonRadtke <[email protected]> * remove unused cmake options * address PR feedback from copilot * fix build break --------- Co-authored-by: Copilot <[email protected]>
1 parent 4fb5912 commit c31617f

File tree

5 files changed

+478
-74
lines changed

5 files changed

+478
-74
lines changed

.github/workflows/cmake/action.yml

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,25 @@
11
name: Composite CMake
22
inputs:
3-
cmake_generator:
4-
required: false
5-
type: string
6-
default: 'Unix Makefiles'
7-
cmake_build_type:
3+
cmake_preset:
84
required: true
95
type: string
10-
default: ''
11-
cmake_cxx_compiler:
12-
required: false
13-
type: string
14-
gsl_cxx_standard:
15-
required: true
16-
type: number
176
extra_cmake_args:
187
required: false
198
type: string
209
default: ''
21-
build_cmd:
22-
required: true
23-
type: string
24-
default: 'make'
25-
test_cmd:
26-
required: false
27-
type: string
28-
default: 'make test'
29-
shell:
30-
required: false
31-
type: string
32-
default: 'bash'
33-
3410

3511
runs:
3612
using: composite
3713
steps:
38-
- name: Create build directory
39-
run: mkdir build
40-
shell: ${{ inputs.shell }}
41-
4214
- name: Configure CMake
43-
working-directory: build
44-
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 }} ..
45-
shell: ${{ inputs.shell }}
15+
run: cmake --preset ${{ inputs.cmake_preset }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ${{ inputs.extra_cmake_args }}
16+
shell: bash
4617

47-
- name: Build
48-
working-directory: build
49-
run: ${{ inputs.build_cmd }}
50-
shell: ${{ inputs.shell }}
18+
- name: Build (with preset)
19+
run: cmake --build --preset ${{ inputs.cmake_preset }}
20+
shell: bash
5121

52-
- name: Test
53-
working-directory: build
54-
run: ${{ inputs.test_cmd }}
55-
shell: ${{ inputs.shell }}
22+
- name: Test (with preset)
23+
run: ctest --preset ${{ inputs.cmake_preset }} --output-on-failure --no-compress-output
24+
shell: pwsh
5625

.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

.github/workflows/copilot-setup-steps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
run: sudo apt-get update && sudo apt-get install -y clang cmake make
1616

1717
- name: Configure CMake (C++14)
18-
run: cmake -B build-cxx14 . -DGSL_CXX_STANDARD=14 -DGSL_TEST=ON -G "Unix Makefiles"
18+
run: cmake --preset clang-14-debug
1919

2020
- name: Configure CMake (C++20)
21-
run: cmake -B build-cxx20 . -DGSL_CXX_STANDARD=20 -DGSL_TEST=ON -G "Unix Makefiles"
21+
run: cmake --preset clang-20-debug
2222

0 commit comments

Comments
 (0)