Skip to content

Commit 393a439

Browse files
authored
Create cmake-multi-platform.yml
1 parent 5ee168e commit 393a439

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CMake on multiple platforms
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
15+
fail-fast: false
16+
17+
# Set up a matrix to run the following 3 configurations:
18+
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
19+
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
20+
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
21+
#
22+
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
23+
matrix:
24+
os: [ubuntu-latest, windows-latest]
25+
build_type: [Release]
26+
c_compiler: [gcc, clang, cl]
27+
include:
28+
- os: windows-latest
29+
c_compiler: cl
30+
cpp_compiler: cl
31+
- os: ubuntu-latest
32+
c_compiler: gcc
33+
cpp_compiler: g++
34+
- os: ubuntu-latest
35+
c_compiler: clang
36+
cpp_compiler: clang++
37+
exclude:
38+
- os: windows-latest
39+
c_compiler: gcc
40+
- os: windows-latest
41+
c_compiler: clang
42+
- os: ubuntu-latest
43+
c_compiler: cl
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- name: Set reusable strings
49+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
50+
id: strings
51+
shell: bash
52+
run: |
53+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
54+
55+
- name: Configure CMake
56+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
57+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
58+
run: >
59+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
60+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
61+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
62+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
63+
-DMODBUS_EXAMPLE=ON
64+
-DMODBUS_TEST=ON
65+
-S ${{ github.workspace }}
66+
67+
- name: Build
68+
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
69+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
70+
71+
- name: Test
72+
working-directory: ${{ steps.strings.outputs.build-output-dir }}
73+
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
74+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
75+
run: build/tests/Google_Tests_run

0 commit comments

Comments
 (0)