Skip to content
name: CMake on multiple platforms
on:
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
steps:
- uses: actions/checkout@v4
- name: Cache CMake builds
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/build
key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt', '**/*.cpp', '**/*.h') }}
restore-keys: |
${{ runner.os }}-build-
- name: Configure CMake
run: |
cmake -B build \
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-S .
working-directory: ${{ github.workspace }}
- name: Build
run: cmake --build build --config ${{ matrix.build_type }}
working-directory: ${{ github.workspace }}
- name: Run Tests
run: ctest -C ${{ matrix.build_type }} --output-on-failure
working-directory: ${{ github.workspace }}/build
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Test Results
path: ${{ github.workspace }}/build/Testing/**/*.xml