-
Notifications
You must be signed in to change notification settings - Fork 196
217 lines (183 loc) · 8.17 KB
/
cmake-multi-platform.yml
File metadata and controls
217 lines (183 loc) · 8.17 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# 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.
fail-fast: false
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [windows-latest, ubuntu-latest]
build_type: [Release]
c_compiler: [gcc, cl, clang]
cxx_standard: [11, 17, 20]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v5
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCSV_CXX_STANDARD=${{ matrix.cxx_standard }}
-DCSV_BUILD_SINGLE_INCLUDE_TEST=ON
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# 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).
# single_include_test is excluded from the default "all" target and is built explicitly in the next step.
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Single-header smoke test
if: matrix.os != 'windows-latest'
# Explicitly build the single-header smoke-test target so CI validates the freshly generated amalgamated header.
# TODO: Re-enable on Windows after fixing single_include_test target generation/project discovery.
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target single_include_test
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# 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).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
single-threaded:
name: Single-threaded build (CSV_ENABLE_THREADS=OFF)
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v5
with:
submodules: recursive
- name: Configure CMake (single-threaded)
run: >
cmake -B ${{ github.workspace }}/build-single-thread
-DCSV_ENABLE_THREADS=OFF
-DCSV_CXX_STANDARD=20
-DCMAKE_BUILD_TYPE=Release
-S ${{ github.workspace }}
- name: Build (single-threaded)
run: cmake --build ${{ github.workspace }}/build-single-thread --config Release
- name: Test (single-threaded)
working-directory: ${{ github.workspace }}/build-single-thread
run: ctest --build-config Release --output-on-failure
single-threaded-emscripten:
name: Single-threaded Emscripten build (CSV_ENABLE_THREADS=OFF)
runs-on: ubuntu-latest
env:
# TODO: Set to '1' to re-enable wasm runtime tests once a lightweight
# Emscripten smoke subset is in place and stable in CI.
CSV_EMSCRIPTEN_RUN_TESTS: '0'
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v5
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Set up Emscripten
uses: mymindstorm/setup-emsdk@667eb33f24e84e7f362c16d8d7fff0629a73e15e # v14
with:
version: latest
- name: Configure CMake (single-threaded emscripten)
run: >
emcmake cmake -B ${{ github.workspace }}/build-single-thread-emscripten
-DCSV_ENABLE_THREADS=OFF
-DCSV_CXX_STANDARD=20
-DCSV_BUILD_SINGLE_INCLUDE_TEST=ON
-DCMAKE_CROSSCOMPILING_EMULATOR=node
-DCMAKE_BUILD_TYPE=Release
-S ${{ github.workspace }}
- name: Build (single-threaded emscripten)
run: cmake --build ${{ github.workspace }}/build-single-thread-emscripten --config Release
- name: Test (single-threaded emscripten)
if: env.CSV_EMSCRIPTEN_RUN_TESTS == '1'
working-directory: ${{ github.workspace }}/build-single-thread-emscripten
run: ctest --build-config Release --output-on-failure
- name: Skip tests (single-threaded emscripten)
if: env.CSV_EMSCRIPTEN_RUN_TESTS != '1'
run: echo "Skipping Emscripten ctest (build-only coverage). Set CSV_EMSCRIPTEN_RUN_TESTS=1 to re-enable."
simd-branches:
name: SIMD branch verification (${{ matrix.simd_mode }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
simd_mode: [avx2, sse2, no-simd]
include:
- simd_mode: avx2
# Force AVX2 so __AVX2__ branch is compiled deterministically.
cmake_no_simd: "OFF"
cmake_extra_flags: "-DCMAKE_CXX_FLAGS=-mavx2"
- simd_mode: sse2
# Force SSE2-only path by disabling auto-detected AVX2.
# -mno-avx2 prevents __AVX2__ from being defined so the SSE2 branch compiles.
cmake_no_simd: "OFF"
cmake_extra_flags: "-DCMAKE_CXX_FLAGS=-mno-avx2"
- simd_mode: no-simd
cmake_no_simd: "ON"
cmake_extra_flags: ""
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v5
with:
submodules: recursive
- name: Configure CMake (${{ matrix.simd_mode }})
run: >
cmake -B ${{ github.workspace }}/build-simd-${{ matrix.simd_mode }}
-DCSV_CXX_STANDARD=20
-DCSV_ENABLE_THREADS=ON
-DCSV_NO_SIMD=${{ matrix.cmake_no_simd }}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_COMPILER=g++
-DCMAKE_C_COMPILER=gcc
${{ matrix.cmake_extra_flags }}
-S ${{ github.workspace }}
- name: Build (${{ matrix.simd_mode }})
run: cmake --build ${{ github.workspace }}/build-simd-${{ matrix.simd_mode }} --config Release
- name: Test (${{ matrix.simd_mode }})
working-directory: ${{ github.workspace }}/build-simd-${{ matrix.simd_mode }}
run: ctest --build-config Release --output-on-failure