-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (85 loc) · 3.77 KB
/
cmake-multi-platform.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: CMake with ccache on multiple platforms and compilers
on:
push:
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ${{ matrix.sys.os }}
strategy:
fail-fast: false
matrix:
sys:
# Compilation failes with the following error: ccache: error: Could not find compiler "D:\a\_temp\msys64\clang64\bin\clang++.exe" in PATH
# - { os: windows-latest, shell: 'msys2 {0}', generator: Ninja }
- { os: windows-latest, shell: 'msys2 {0}', generator: Unix Makefiles }
- { os: ubuntu-latest, shell: bash, generator: Ninja }
- { os: ubuntu-latest, shell: bash, generator: Unix Makefiles }
- { os: macos-latest, shell: bash, generator: Ninja }
- { os: macos-latest, shell: bash, generator: Unix Makefiles }
compiler:
- { c: gcc, cpp: g++, msys: mingw64 }
- { c: clang, cpp: clang++, msys: clang64 }
build_type: [Debug]
include:
# Behaves weird on github runner, either because of Windows Server, VS Enterprise, or sources being on D:\ drive, i.e.
# Objects from first build get into cache, but second build compiler calls do not get into hits or miss statistics, while
# it can be seen that ccache is being called. On the other hand this configuration has been tested on multiple machines
# with Windows 10 Pro, VS Community edition and source stored on C:\ drive.
- sys: { os: windows-latest, shell: bash, generator: Visual Studio 17 2022 }
compiler: { c: cl, cpp: cl }
build_type: Debug
- sys: { os: macos-latest, shell: bash, generator: Xcode }
compiler: { c: clang, cpp: clang++ }
build_type: Debug
defaults:
run:
shell: ${{ matrix.sys.shell }}
steps:
- uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/[email protected]
with:
restore: false
save: false
verbose: 2
variant: ccache
- name: Install ninja (ubuntu)
if: ${{ matrix.sys.os == 'ubuntu-latest' && matrix.sys.generator == 'Ninja' }}
run: |
sudo apt update
sudo apt -y install ninja-build
- name: Install ninja (macos)
if: ${{ matrix.sys.os == 'macos-latest' && matrix.sys.generator == 'Ninja' }}
run: |
brew install ninja
- name: Install MSYS2 (windows)
if: ${{ matrix.sys.shell == 'msys2 {0}' }}
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.compiler.msys }}
update: true
install: >-
make
ccache
pacboy: >-
toolchain:p
cmake:p
ninja:p
- name: Set reusable strings
id: strings
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "source-dir=${{ github.workspace }}/example" >> "$GITHUB_OUTPUT"
- name: Configure CMake
run: |
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler.cpp }} -DCMAKE_C_COMPILER=${{ matrix.compiler.c }} -S "${{ steps.strings.outputs.source-dir }}" -B "${{ steps.strings.outputs.build-output-dir }}" -G "${{matrix.sys.generator}}"
- name: Build (empty cache)
run: |
cmake --build "${{ steps.strings.outputs.build-output-dir }}" --config ${{ matrix.build_type }} --verbose
ccache --show-stats
- name: Build (cached)
run: |
cmake --build "${{ steps.strings.outputs.build-output-dir }}" --config ${{ matrix.build_type }} --target clean --verbose
cmake --build "${{ steps.strings.outputs.build-output-dir }}" --config ${{ matrix.build_type }} --verbose
ccache --show-stats