Skip to content

Commit

Permalink
Create cmake-multi-platform.yml (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulvs authored Feb 19, 2025
1 parent 921a602 commit ad414d1
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CMake on multiple platforms

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "*" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
# Windows + MSVC
- os: windows-latest
c_compiler: cl
cpp_compiler: cl

# Ubuntu + GCC
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++

# Ubuntu + Clang
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++

# Exclude invalid combos (e.g., trying gcc on Windows)
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: true # Important: pulls in any Git submodules

- name: Configure CMake
# Single-line command works on both Windows (PowerShell) & Linux (Bash).
run: cmake -S . -B build -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -Dqualisys_cpp_sdk_BUILD_TESTS=ON

- name: Build
# On Windows + MSVC (multi-config generator), --config picks Release/Debug.
# On Linux + Make/Ninja (single-config), --config is simply ignored, which is fine.
run: cmake --build build --config ${{ matrix.build_type }}

- name: Test
working-directory: build
# --build-config is needed for multi-config Windows. Linux ignores it, which is okay.
run: ctest --build-config ${{ matrix.build_type }} --output-on-failure

0 comments on commit ad414d1

Please sign in to comment.