Skip to content

Commit 4a37611

Browse files
authored
linux doesn't have multi-configuration for ninja/make in single-config mode
Updated the CMake workflow to simplify variable handling and improve clarity in build directory management.
1 parent 616c7d5 commit 4a37611

1 file changed

Lines changed: 18 additions & 24 deletions

File tree

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
2-
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
31
name: CMake on multiple platforms
42

53
on:
@@ -13,20 +11,14 @@ jobs:
1311
runs-on: ${{ matrix.os }}
1412

1513
strategy:
16-
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
1714
fail-fast: false
18-
19-
# Set up a matrix to run the following 3 configurations:
20-
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
21-
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
22-
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
23-
#
24-
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
2515
matrix:
2616
os: [ubuntu-latest, windows-latest]
2717
build_type: [Debug, Release]
2818
c_compiler: [gcc, clang, cl]
19+
2920
include:
21+
# Windows
3022
- os: windows-latest
3123
c_compiler: cl
3224
cpp_compiler: cl
@@ -36,42 +28,44 @@ jobs:
3628
- os: windows-latest
3729
c_compiler: gcc
3830
cpp_compiler: g++
31+
32+
# Linux
3933
- os: ubuntu-latest
4034
c_compiler: gcc
4135
cpp_compiler: g++
4236
- os: ubuntu-latest
4337
c_compiler: clang
4438
cpp_compiler: clang++
39+
4540
exclude:
4641
- os: ubuntu-latest
4742
c_compiler: cl
4843

4944
steps:
5045
- uses: actions/checkout@v4
5146

52-
- name: Set reusable strings
53-
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
54-
id: strings
47+
- name: Set build dir
48+
id: vars
5549
shell: bash
56-
run: |
57-
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
50+
run: echo "dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
5851

5952
- name: Configure CMake
60-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
61-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
6253
run: >
63-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
54+
cmake -B ${{ steps.vars.outputs.dir }}
6455
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
6556
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6657
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6758
-S ${{ github.workspace }}
6859
6960
- name: Build
70-
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
71-
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
61+
run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }}
7262

7363
- name: Test
74-
working-directory: ${{ steps.strings.outputs.build-output-dir }}
75-
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
76-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
77-
run: ctest --build-config ${{ matrix.build_type }} --verbose
64+
working-directory: ${{ steps.vars.outputs.dir }}
65+
shell: bash
66+
run: |
67+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
68+
ctest --build-config ${{ matrix.build_type }} --verbose
69+
else
70+
ctest --verbose
71+
fi

0 commit comments

Comments
 (0)