Skip to content

Commit 40bf91a

Browse files
authored
Update build system, use CPM (#13)
* Update build system, use CPM * Based on most recent changes to cmake_template
1 parent c13146b commit 40bf91a

38 files changed

+1849
-303
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
name: 'setup_cache'
3+
description: 'sets up the shared cache'
4+
inputs:
5+
compiler:
6+
required: true
7+
type: string
8+
build_type:
9+
required: true
10+
type: string
11+
generator:
12+
required: true
13+
type: string
14+
developer_mode:
15+
required: true
16+
type: string
17+
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Cache
23+
uses: actions/cache@v2
24+
with:
25+
# You might want to add .ccache to your cache configuration?
26+
path: |
27+
~/.cache/pip
28+
${{ env.HOME }}/.cache/vcpkg/archives
29+
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
30+
${{ env.LOCALAPPDATA }}\vcpkg\archives
31+
${{ env.APPDATA }}\vcpkg\archives
32+
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.generator }}-${{ inputs.developer_mode }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}
33+
restore-keys: |
34+
${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}
35+

.github/workflows/ci.yml

+101-73
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
name: ci
22
on:
33
pull_request:
4+
release:
5+
types: [published]
6+
47
push:
58
tags:
69
branches:
710
- main
11+
- develop
812

913
env:
10-
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11-
# Conan cache environment variables
12-
CONAN_SYSREQUIRES_MODE: enabled
13-
CONAN_USER_HOME: "${{ github.workspace }}/conan-cache"
14-
CONAN_USER_HOME_SHORT: "${{ github.workspace }}/conan-cache/short"
14+
CLANG_TIDY_VERSION: "15.0.2"
15+
VERBOSE: 1
1516

1617
jobs:
1718
Test:
@@ -32,116 +33,145 @@ jobs:
3233
- macos-10.15
3334
- windows-2019
3435
compiler:
35-
# you can specify the version after `-` like "llvm-13.0.0".
36-
- llvm
37-
- gcc-8
36+
# you can specify the version after `-` like "llvm-15.0.2".
37+
- llvm-15.0.2
38+
- gcc-11
3839
generator:
3940
- "Ninja Multi-Config"
4041
build_type:
4142
- Release
4243
- Debug
43-
developer_mode:
44+
package_maintainer_mode:
4445
- ON
4546
- OFF
46-
large_tests:
47+
build_shared:
4748
- OFF
4849

4950
exclude:
5051
# mingw is determined by this author to be too buggy to support
5152
- os: windows-2019
52-
compiler: gcc-8
53-
# These have anonalous failures, not sure what is up with no access to a physical Mac.
54-
- os: macos-10.15
55-
compiler: gcc-8
56-
build_type: Debug
57-
developer_mode: ON
53+
compiler: gcc-11
54+
55+
include:
56+
# Add appropriate variables for gcov version required. This will intentionally break
57+
# if you try to use a compiler that does not have gcov set
58+
- compiler: gcc-11
59+
gcov_executable: gcov
60+
enable_ipo: On
61+
62+
- compiler: llvm-15.0.2
63+
enable_ipo: Off
64+
gcov_executable: "llvm-cov gcov"
65+
5866
- os: macos-10.15
59-
compiler: llvm
60-
build_type: Release
61-
developer_mode: ON
67+
enable_ipo: Off
68+
enable_cppcheck: OFF
69+
enable_clang_tidy: OFF
6270

71+
- os: ubuntu-20.04
72+
enable_clang_tidy: On
73+
enable_cppcheck: On
6374

6475

65-
include:
66-
# setup gcov variables for extra compiler versions
67-
- compiler: llvm
68-
gcov: "llvm-cov gcov"
69-
- compiler: gcc-8
70-
gcov: "gcov-8"
71-
72-
# setup preferred package generators
73-
- developer_mode: OFF
74-
build_type: Release
76+
# Set up preferred package generators, for given build configurations
77+
- build_type: Release
78+
package_maintainer_mode: OFF
7579
package_generator: TBZ2
7680

77-
7881
# This exists solely to make sure a non-multiconfig build works
7982
- os: ubuntu-20.04
80-
compiler: gcc
81-
gcov: gcov
83+
compiler: gcc-11
8284
generator: "Unix Makefiles"
8385
build_type: Debug
84-
developer_mode: On
86+
gcov_executable: gcov
87+
package_maintainer_mode: On
88+
enable_ipo: Off
89+
enable_clang_tidy: On
90+
enable_cppcheck: On
8591

86-
- os: windows-2019
92+
93+
# Windows msvc builds
94+
- os: windows-2022
8795
compiler: msvc
88-
generator: "Visual Studio 16 2019"
96+
generator: "Visual Studio 17 2022"
8997
build_type: Debug
90-
developer_mode: On
91-
- os: windows-2019
98+
package_maintainer_mode: On
99+
enable_ipo: On
100+
enable_clang_tidy: Off
101+
enable_cppcheck: Off
102+
103+
104+
- os: windows-2022
92105
compiler: msvc
93-
generator: "Visual Studio 16 2019"
106+
generator: "Visual Studio 17 2022"
94107
build_type: Release
95-
developer_mode: On
96-
- os: windows-2019
108+
package_maintainer_mode: On
109+
enable_ipo: On
110+
enable_clang_tidy: Off
111+
enable_cppcheck: Off
112+
113+
114+
- os: windows-2022
97115
compiler: msvc
98-
generator: "Visual Studio 16 2019"
116+
generator: "Visual Studio 17 2022"
99117
build_type: Debug
100-
developer_mode: Off
101-
- os: windows-2019
118+
package_maintainer_mode: Off
119+
enable_clang_tidy: Off
120+
enable_cppcheck: Off
121+
122+
123+
- os: windows-2022
102124
compiler: msvc
103-
generator: "Visual Studio 16 2019"
125+
generator: "Visual Studio 17 2022"
104126
build_type: Release
105-
developer_mode: Off
127+
package_maintainer_mode: Off
106128
package_generator: ZIP
129+
enable_clang_tidy: Off
130+
enable_cppcheck: Off
107131

108132

133+
- os: windows-2022
134+
compiler: msvc
135+
generator: "Visual Studio 17 2022"
136+
build_type: Release
137+
package_maintainer_mode: On
138+
enable_ipo: On
139+
build_shared: On
140+
enable_clang_tidy: Off
141+
enable_cppcheck: Off
109142

110143

111144

112145
steps:
146+
- name: Check for llvm version mismatches
147+
if: ${{ contains(matrix.compiler, 'llvm') && !contains(matrix.compiler, env.CLANG_TIDY_VERSION) }}
148+
uses: actions/github-script@v3
149+
with:
150+
script: |
151+
core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen')
152+
113153
- uses: actions/checkout@v2
114-
- uses: actions/setup-python@v2
115-
- name: Cache
116-
uses: actions/cache@v2
154+
155+
- name: Setup Cache
156+
uses: ./.github/actions/setup_cache
117157
with:
118-
path: |
119-
~/vcpkg
120-
./build/vcpkg_installed
121-
${{ env.CONAN_USER_HOME }}
122-
~/.cache/pip
123-
${{ env.HOME }}/.cache/vcpkg/archives
124-
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
125-
${{ env.LOCALAPPDATA }}\vcpkg\archives
126-
${{ env.APPDATA }}\vcpkg\archives
127-
key: ${{ runner.os }}-${{ matrix.compiler }}-${{matrix.build_type}}-${{matrix.generator}}-${{matrix.developer_mode}}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./conanfile.txt')}}-${{ hashFiles('./vcpkg.json')}}
128-
restore-keys: |
129-
${{ runner.os }}-${{ matrix.compiler }}-${{matrix.build_type}}-${{matrix.generator}}-${{matrix.developer_mode}}
130-
131-
- run: pip3 install conan cmake ninja
158+
compiler: ${{ matrix.compiler }}
159+
build_type: ${{ matrix.build_type }}
160+
package_maintainer_mode: ${{ matrix.package_maintainer_mode }}
161+
generator: ${{ matrix.generator }}
132162

133163
- name: Setup Cpp
134164
uses: aminya/setup-cpp@v1
135165
with:
136166
compiler: ${{ matrix.compiler }}
137167
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
138168

139-
cmake: false
140-
ninja: false
141-
conan: false
169+
cmake: true
170+
ninja: true
142171
vcpkg: false
143172
ccache: true
144-
clangtidy: true
173+
clangtidy: ${{ env.CLANG_TIDY_VERSION }}
174+
145175

146176
cppcheck: true
147177

@@ -150,7 +180,7 @@ jobs:
150180

151181
- name: Configure CMake
152182
run: |
153-
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.developer_mode}} -DENABLE_LARGE_TESTS:BOOL=${{matrix.large_tests}} -DOPT_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}
183+
cmake -S . -B ./build -G "${{matrix.generator}}" -Djson2cpp_ENABLE_CLANG_TIDY:BOOL=${{ matrix.enable_clang_tidy }} -Djson2cpp_ENABLE_CPPCHECK:BOOL=${{ matrix.enable_cppcheck }} -Djson2cpp_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -Djson2cpp_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.package_maintainer_mode}} -Djson2cpp_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}
154184
155185
- name: Build
156186
# Execute the build. You can specify a specific target with "--target <NAME>"
@@ -164,19 +194,15 @@ jobs:
164194
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
165195
run: |
166196
ctest -C ${{matrix.build_type}}
167-
pwd
168-
which gcov
169-
gcov --version
170-
gcovr --version
171-
gcovr -j ${{env.nproc}} --root ../ --print-summary --xml-pretty --xml coverage.xml . --verbose --gcov-executable '${{matrix.gcov}}'
197+
gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}'
172198
173199
- name: Windows - Test and coverage
174200
if: runner.os == 'Windows'
175201
working-directory: ./build
176202
run: |
177203
OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}
178204
179-
- name: Build Package
205+
- name: CPack
180206
if: matrix.package_generator != ''
181207
working-directory: ./build
182208
run: |
@@ -190,13 +216,15 @@ jobs:
190216
files: |
191217
build/*-*${{ matrix.build_type }}*-*.*
192218
219+
193220
- name: Publish Tagged Release
194221
uses: softprops/action-gh-release@v1
195222
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.package_generator != '' }}
196223
with:
197224
files: |
198225
build/*-*${{ matrix.build_type }}*-*.*
199226
227+
200228
- name: Publish to codecov
201229
uses: codecov/codecov-action@v2
202230
with:

0 commit comments

Comments
 (0)