-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (91 loc) · 3.68 KB
/
cmake.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Build and test (CMake)
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
branches:
- '*'
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
# Install GTest on non Windows nodes
- name: Install GTest
if: matrix.os != 'windows-latest'
working-directory: ${{github.workspace}}
run: |
git clone --branch v1.12.x https://github.com/google/googletest.git
cd googletest
cmake -B build -DBUILD_SHARED_LIBS=ON -DINSTALL_GTEST=ON -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake --build build --config ${{env.BUILD_TYPE}}
sudo cmake --install build --prefix=/usr/local
# Install GTest on Windows only
- name: Install GTest (Windows)
if: matrix.os == 'windows-latest'
shell: cmd
working-directory: ${{github.workspace}}
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
git clone --branch v1.12.x https://github.com/google/googletest.git
cd googletest
cmake -B build -DBUILD_SHARED_LIBS=ON -DINSTALL_GTEST=ON
cmake --build build --config ${{env.BUILD_TYPE}}
cmake --install build --prefix=${{github.workspace}}/googletest/build
- name: Configure CMake
if: matrix.os != 'windows-latest'
working-directory: ${{github.workspace}}
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_TESTING=True -DTARGET_ARCH=x64
- name: Build
if: matrix.os != 'windows-latest'
# Build your program with the given configuration
run: cmake --build build --config ${{env.BUILD_TYPE}}
# Windows only
- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
cmake -B build_x64 -DENABLE_TESTING=True -DCMAKE_PREFIX_PATH=${{github.workspace}}\googletest\build -A x64
# Windows only
- name: Build (Windows)
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}
shell: cmd
# Build your program with the given configuration
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
cmake --build build_x64 --config ${{env.BUILD_TYPE}}
# Test non Windows
- name: Test
if: matrix.os != 'windows-latest'
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
run: ctest -C ${{env.BUILD_TYPE}} --verbose
# Test x64 bit Windows
- name: Test_x64
if: matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}/build_x64
# Execute tests defined by the CMake configuration.
run: ctest -C ${{env.BUILD_TYPE}} --verbose
# Uploade coverage report only for Linux
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
verbose: true
gcov: true