Skip to content

Commit f840e29

Browse files
Add simple CI with github actions
1 parent 8ced279 commit f840e29

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CMake CI for cross-platform libraries
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
12+
strategy:
13+
fail-fast: false
14+
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+
runs-on: ${{ matrix.os }}
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Set directory strings
43+
id: directories
44+
shell: bash
45+
run: |
46+
main_dir="${{ github.workspace }}"
47+
echo "main-dir=$main_dir" >> "$GITHUB_OUTPUT"
48+
echo "build-dir=$main_dir/build" >> "$GITHUB_OUTPUT"
49+
50+
- name: Configure CMake
51+
run: >
52+
cmake -B ${{ steps.directories.outputs.build-dir }}
53+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
54+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
55+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
56+
-S ${{ steps.directories.outputs.main-dir }}
57+
58+
- name: Build with CMake
59+
run: cmake --build ${{ steps.directories.outputs.build-dir }} --config ${{ matrix.build_type }}
60+
61+
- name: Test with Ctest
62+
working-directory: ${{ steps.directories.outputs.build-dir }}
63+
run: ctest -V --build-config ${{ matrix.build_type }}

0 commit comments

Comments
 (0)