Skip to content

Commit

Permalink
Rework github actions to use cmake presets
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeLepape committed Jan 3, 2024
1 parent 18c42b4 commit 9e7e289
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
34 changes: 6 additions & 28 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,16 @@ jobs:
# 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.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
preset: [GCC-Debug, GCC-Release, Clang-Debug, Clang-Release]
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: ubuntu-latest
c_compiler: clang
- os: windows-latest
c_compiler: cl
- preset: Clang-Debug
- preset: Clang-Release

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -61,15 +43,11 @@ jobs:
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
-S ${{ github.workspace }}
--preset ${{ matrix.preset }}
- name: Build
# 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).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} -j

# - name: Test
# working-directory: ${{ steps.strings.outputs.build-output-dir }}
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"editor.tabSize": 2
},
"[json]": {
"editor.tabSize": 4
"editor.tabSize": 4,
"files.insertFinalNewline": true
},
"files.associations": {
".clang-tidy": "yaml",
Expand Down
8 changes: 4 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "GCC-Debug",
"displayName": "Build with gcc in debug mode",
"generator": "Ninja",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
Expand All @@ -18,7 +18,7 @@
{
"name": "GCC-Release",
"displayName": "Build with gcc in release mode",
"generator": "Ninja",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
Expand All @@ -32,7 +32,7 @@
{
"name": "Clang-Debug",
"displayName": "Build with clang in debug mode",
"generator": "Ninja",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
Expand All @@ -46,7 +46,7 @@
{
"name": "Clang-Release",
"displayName": "Build with clang in release mode",
"generator": "Ninja",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
Expand Down

0 comments on commit 9e7e289

Please sign in to comment.