Skip to content

Commit 53ec9ea

Browse files
authored
Create cmake-multi-platform.yml
1 parent faf8fbd commit 53ec9ea

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CMake on multiple platforms
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest]
17+
build_type: [Release]
18+
c_compiler: [gcc, clang, cl]
19+
include:
20+
- os: windows-latest
21+
c_compiler: cl
22+
cpp_compiler: cl
23+
- os: ubuntu-latest
24+
c_compiler: gcc
25+
cpp_compiler: g++
26+
- os: ubuntu-latest
27+
c_compiler: clang
28+
cpp_compiler: clang++
29+
exclude:
30+
- os: windows-latest
31+
c_compiler: gcc
32+
- os: windows-latest
33+
c_compiler: clang
34+
- os: ubuntu-latest
35+
c_compiler: cl
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Set reusable strings
42+
id: strings
43+
shell: bash
44+
run: |
45+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
46+
47+
- name: Configure CMake
48+
run: >
49+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
50+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
51+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
52+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
53+
-S ${{ github.workspace }}
54+
55+
- name: Build
56+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
57+
58+
- name: Run Google Tests
59+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
60+
run: |
61+
# Localize the test executable (adjust "tests" to match your actual executable name)
62+
./tests

0 commit comments

Comments
 (0)