Skip to content

Commit e901281

Browse files
committed
Create cmake-multi-platform.yml
CI for Modbus ! Signed-off-by: Mateusz Mazur <mateusz.mazur@e.email>
1 parent 48c9ace commit e901281

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
with:
48+
submodules: "recursive"
49+
fetch-depth: 1
50+
51+
- name: Install dependencies
52+
run: |
53+
sudo apt-get update
54+
sudo apt-get install -y libnet1-dev
55+
if: matrix.os == 'ubuntu-latest'
56+
57+
- name: Set reusable strings
58+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
59+
id: strings
60+
shell: bash
61+
run: |
62+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
63+
64+
- name: Configure CMake
65+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
66+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
67+
run: >
68+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
69+
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
70+
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
71+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
72+
-DMODBUS_EXAMPLE=ON
73+
-DMODBUS_TESTS=ON
74+
-DMODBUS_COMMUNICATION=${{ matrix.os == 'windows-latest' && 'OFF' || matrix.os == 'ubuntu-latest' && 'ON' }}
75+
-S ${{ github.workspace }}
76+
77+
- name: Build
78+
# 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).
79+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
80+
81+
- name: Test
82+
run: ${{ steps.strings.outputs.build-output-dir }}/tests/Google_Tests_run

0 commit comments

Comments
 (0)