| 1 |
# This workflow is for CMake-based build/test running on multiple platforms. |
| 2 |
name: cmake build |
| 3 |
|
| 4 |
on: [push, pull_request] |
| 5 |
|
| 6 |
jobs: |
| 7 |
build: |
| 8 |
name: ${{ matrix.os }} ${{ matrix.c_compiler }} ${{ matrix.build_type }} thr:${{ matrix.enable_threads }} dll:${{ matrix.shared_libs }} |
| 9 |
runs-on: ${{ matrix.os }} |
| 10 |
|
| 11 |
strategy: |
| 12 |
# Deliver the feedback for all matrix combinations. |
| 13 |
fail-fast: false |
| 14 |
|
| 15 |
matrix: |
| 16 |
os: [ macos-latest, ubuntu-latest, windows-latest ] |
| 17 |
c_compiler: [ cl, clang, gcc ] |
| 18 |
build_type: [ Debug, Release ] |
| 19 |
gc_assertions: [ off, on ] |
| 20 |
enable_threads: [ off, on ] |
| 21 |
shared_libs: [ off, on ] |
| 22 |
exclude: |
| 23 |
- os: macos-latest |
| 24 |
c_compiler: cl |
| 25 |
- os: macos-latest |
| 26 |
c_compiler: gcc |
| 27 |
- os: ubuntu-latest |
| 28 |
c_compiler: cl |
| 29 |
- build_type: Debug |
| 30 |
gc_assertions: off |
| 31 |
- build_type: Release |
| 32 |
gc_assertions: on |
| 33 |
- os: windows-latest # TODO: support dependency on libatomic_ops |
| 34 |
c_compiler: cl |
| 35 |
enable_threads: on |
| 36 |
include: |
| 37 |
- os: windows-latest |
| 38 |
c_compiler: gcc |
| 39 |
cmake_generator_opt: '-G "Unix Makefiles"' |
| 40 |
- os: windows-latest |
| 41 |
c_compiler: clang |
| 42 |
cmake_generator_opt: '-G "Unix Makefiles"' |
| 43 |
|
| 44 |
steps: |
| 45 |
- uses: actions/checkout@v6 |
| 46 |
|
| 47 |
- name: Set reusable strings |
| 48 |
# Turn repeated input strings into step outputs. |
| 49 |
id: strings |
| 50 |
shell: bash |
| 51 |
run: | |
| 52 |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" |
| 53 |
|
| 54 |
- name: Configure CMake |
| 55 |
# Configure CMake in a 'build' subdirectory. |
| 56 |
run: > |
| 57 |
cmake -B ${{ steps.strings.outputs.build-output-dir }} |
| 58 |
${{ matrix.cmake_generator_opt }} |
| 59 |
-DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} |
| 60 |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} |
| 61 |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} |
| 62 |
-Dbuild_tests=ON |
| 63 |
-Denable_gc_assertions=${{ matrix.gc_assertions }} |
| 64 |
-Denable_threads=${{ matrix.enable_threads }} |
| 65 |
-Denable_werror=ON |
| 66 |
-Werror=dev |
| 67 |
-S ${{ github.workspace }} |
| 68 |
|
| 69 |
- name: Build |
| 70 |
# Build the code with the given configuration. |
| 71 |
run: > |
| 72 |
cmake --build ${{ steps.strings.outputs.build-output-dir }} |
| 73 |
--config ${{ matrix.build_type }} --verbose --parallel |
| 74 |
|
| 75 |
- name: Test |
| 76 |
working-directory: ${{ steps.strings.outputs.build-output-dir }} |
| 77 |
# Execute tests defined by the CMake configuration. |
| 78 |
run: ctest --build-config ${{ matrix.build_type }} --verbose --parallel 8 |