Skip to content

Commit 5b93840

Browse files
Added CMake presets for Boost, AWS SDK C++ and main application (#55)
All 3 projects now have the following CMake presets * 'debug_gcc13' - Debug configuration for GCC 13 toolset * 'release_gcc13' - RelWithDebInfo configuration for GCC 13 toolset * 'asan_gcc13' - Debug configuration with Address Sanitizer enabled for GCC 13 toolset * 'debug_clang17' - Debug configuration for Clang 17 toolset * 'release_clang17' - RelWithDebInfo configuration for Clang 17 toolset * 'asan_clang17' - Debug configuration with Address Sanitizer enabled for Clang 17 toolset For each project ('boost', 'aws-sdk-cpp' and 'percona-binlog-server') you can now enter its source directory cd <project_name> and run cmake . --preset <preset_name> and a new directory <project_name>-build-<preset_name> will appear alongside <project_name> After that, in order to build, you can run cmake --build <project_name>-build-<preset_name> --parallel And finally, to install it you can run cmake --install <project_name>-build-<preset_name> CMakePresets.json for the main project is put into the root of the source tree, alongside CMakeLists.txt. For Boost and AWS SDK C++ the files are put into the 'extra/cmake_presets' directory under corresponding subdirectories. Before starting configuring Boost / AWS SDK C++ these files need to be copied / symlinked into the roots of those project source trees. Significantly reworked GitHub Actions .yml file. * In order to keep build options in one place, GitHub Actions now also use CMake presets. * Fetching main project's source code is now performed before building dependency libraries. It is necessary because we need to have access to the dependency libraries CMakePresets.json files earlier. * Added "Info CMake" action that prints CMake version Changed the way how we instruct main application to look for Boost libraries during the configuration stage. Instead of specifying 'Boost_ROOT', we now use 'CMAKE_PREFIX_PATH' to specify a path where CMake can find 'BoostConfig.cmake'. This helps to avoid some CMake warnings generated in newer (>=3.30.0) versions of cmake. Updated build instructions in README.md to reflect CMake presets changes.
1 parent fc53420 commit 5b93840

5 files changed

Lines changed: 423 additions & 158 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 39 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -61,64 +61,33 @@ jobs:
6161
config:
6262
- {
6363
name: "GCC 13 Debug",
64-
build_type: "Debug",
65-
cc: "gcc-13",
66-
cxx: "g++-13",
67-
label: "Debug-gcc13",
64+
label: "debug_gcc13",
6865
run_mtr: true
6966
}
7067
- {
7168
name: "GCC 13 RelWithDebInfo",
72-
build_type: "RelWithDebInfo",
73-
cc: "gcc-13",
74-
cxx: "g++-13",
75-
label: "RelWithDebInfo-gcc13",
69+
label: "release_gcc13",
7670
run_mtr: true
7771
}
7872
- {
7973
name: "GCC 13 ASan",
80-
build_type: "Debug",
81-
cc: "gcc-13",
82-
cxx: "g++-13",
83-
sanitizer_cmake_flags: "-DWITH_ASAN=ON",
84-
aws_cmake_flags: "-DENABLE_ADDRESS_SANITIZER=ON",
85-
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-fsanitize=address",
86-
label: "ASan-gcc13",
74+
label: "asan_gcc13",
8775
run_mtr: true,
8876
mtr_options: "--sanitize"
8977
}
9078
- {
9179
name: "Clang 17 Debug",
92-
build_type: "Debug",
93-
cc: "clang-17",
94-
cxx: "clang++-17",
95-
libcxx_cmake_flags: "-DWITH_STDLIB_LIBCXX=ON",
96-
aws_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
97-
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
98-
label: "Debug-clang17",
80+
label: "debug_clang17",
9981
run_clang_tidy: true
10082
}
10183
- {
10284
name: "Clang 17 RelWithDebInfo",
103-
build_type: "RelWithDebInfo",
104-
cc: "clang-17",
105-
cxx: "clang++-17",
106-
libcxx_cmake_flags: "-DWITH_STDLIB_LIBCXX=ON",
107-
aws_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
108-
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++",
109-
label: "RelWithDebInfo-clang17",
85+
label: "release_clang17",
11086
run_clang_tidy: true
11187
}
11288
- {
11389
name: "Clang 17 ASan",
114-
build_type: "Debug",
115-
cc: "clang-17",
116-
cxx: "clang++-17",
117-
libcxx_cmake_flags: "-DWITH_STDLIB_LIBCXX=ON",
118-
aws_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=-stdlib=libc++ -DENABLE_ADDRESS_SANITIZER=ON",
119-
boost_cmake_flags: "-DCMAKE_CXX_FLAGS_INIT=\"-stdlib=libc++ -fsanitize=address\"",
120-
sanitizer_cmake_flags: "-DWITH_ASAN=ON",
121-
label: "ASan-clang17"
90+
label: "asan_clang17"
12291
# TODO: re-enable running MTR under "Clang 17 ASan"
12392
# run_mtr: true,
12493
# mtr_options: "--sanitize"
@@ -171,20 +140,24 @@ jobs:
171140
sudo apt-get update
172141
sudo apt-get install g++-13
173142
174-
- name: Info CC compiler
175-
run: ${{matrix.config.cc}} --version
143+
- name: Info CMake
144+
run: cmake --version
176145

177-
- name: Info CXX compiler
178-
run: ${{matrix.config.cxx}} --version
146+
- name: Info Preset
147+
run: echo Current preset ${{matrix.config.label}}
179148

180-
- name: Creating deps directory
181-
run: mkdir -p ${{runner.temp}}/deps
149+
- name: Checking out source tree
150+
uses: actions/checkout@v4
151+
with:
152+
path: src
153+
fetch-depth: 0
154+
fetch-tags: true
182155

183156
- name: Cache boost libraries
184157
id: cache-boost-static-libraries
185158
uses: actions/cache@v4
186159
with:
187-
path: ${{runner.temp}}/deps/boost-install-${{matrix.config.label}}
160+
path: ${{github.workspace}}/boost-install-${{matrix.config.label}}
188161
key: ${{format('boost-static-libraries-{0}-{1}-{2}-{3}', env.BOOST_MAJOR, env.BOOST_MINOR, env.BOOST_PATCH, matrix.config.label)}}
189162

190163
- name: Checking out Boost source tree
@@ -197,37 +170,31 @@ jobs:
197170
submodules: recursive
198171
fetch-tags: true
199172

173+
- name: Copying CMake presets for Boost
174+
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
175+
run: ln -s ${{github.workspace}}/src/extra/cmake_presets/boost/CMakePresets.json ${{github.workspace}}/boost
176+
200177
- name: Configure CMake for Boost
201178
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
202-
run: |
203-
cmake \
204-
-B ${{github.workspace}}/boost-build-${{matrix.config.label}} \
205-
-S ${{github.workspace}}/boost \
206-
-DCMAKE_INSTALL_PREFIX=${{runner.temp}}/deps/boost-install-${{matrix.config.label}} \
207-
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} \
208-
-DCMAKE_C_COMPILER=${{matrix.config.cc}} \
209-
-DCMAKE_CXX_COMPILER=${{matrix.config.cxx}} \
210-
${{matrix.config.boost_cmake_flags}} \
211-
-DBUILD_SHARED_LIBS=OFF \
212-
-DBUILD_TESTING=OFF
179+
run: cmake ${{github.workspace}}/boost --preset ${{matrix.config.label}}
213180

214181
- name: CMake info for Boost
215182
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
216183
run: cmake -L ${{github.workspace}}/boost-build-${{matrix.config.label}}
217184

218185
- name: Build for Boost
219186
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
220-
run: cmake --build ${{github.workspace}}/boost-build-${{matrix.config.label}} --config ${{matrix.config.build_type}} --parallel
187+
run: cmake --build ${{github.workspace}}/boost-build-${{matrix.config.label}} --parallel
221188

222189
- name: Install for Boost
223190
if: steps.cache-boost-static-libraries.outputs.cache-hit != 'true'
224-
run: cmake --install ${{github.workspace}}/boost-build-${{matrix.config.label}} --config ${{matrix.config.build_type}}
191+
run: cmake --install ${{github.workspace}}/boost-build-${{matrix.config.label}}
225192

226193
- name: Cache AWS SDK C++ libraries
227194
id: cache-aws-sdk-cpp-libraries
228195
uses: actions/cache@v4
229196
with:
230-
path: ${{runner.temp}}/deps/aws-sdk-cpp-install-${{matrix.config.label}}
197+
path: ${{github.workspace}}/aws-sdk-cpp-install-${{matrix.config.label}}
231198
key: ${{format('aws-cpp-sdk-libraries-{0}-{1}-{2}-{3}', env.AWS_SDK_CPP_MAJOR, env.AWS_SDK_CPP_MINOR, env.AWS_SDK_CPP_PATCH, matrix.config.label)}}
232199

233200
- name: Checking out AWS SDK C++ source tree
@@ -240,67 +207,35 @@ jobs:
240207
submodules: recursive
241208
fetch-tags: true
242209

210+
- name: Copying CMake presets for AWS SDK C++
211+
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
212+
run: ln -s ${{github.workspace}}/src/extra/cmake_presets/aws-sdk-cpp/CMakePresets.json ${{github.workspace}}/aws-sdk-cpp
213+
243214
- name: Configure CMake for AWS SDK C++
244215
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
245-
run: |
246-
cmake \
247-
-B ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}} \
248-
-S ${{github.workspace}}/aws-sdk-cpp \
249-
-DCMAKE_INSTALL_PREFIX=${{runner.temp}}/deps/aws-sdk-cpp-install-${{matrix.config.label}} \
250-
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} \
251-
-DCMAKE_C_COMPILER=${{matrix.config.cc}} \
252-
-DCMAKE_CXX_COMPILER=${{matrix.config.cxx}} \
253-
${{matrix.config.aws_cmake_flags}} \
254-
-DCPP_STANDARD=20 \
255-
-DENABLE_UNITY_BUILD=ON \
256-
-DBUILD_SHARED_LIBS=OFF \
257-
-DFORCE_SHARED_CRT=OFF \
258-
-DENABLE_TESTING=OFF \
259-
-DAUTORUN_UNIT_TESTS=OFF \
260-
-DBUILD_ONLY=s3-crt
216+
run: cmake ${{github.workspace}}/aws-sdk-cpp --preset ${{matrix.config.label}}
261217

262218
- name: CMake info for AWS SDK C++
263219
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
264220
run: cmake -L ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}}
265221

266222
- name: Build for AWS SDK C++
267223
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
268-
run: cmake --build ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}} --config ${{matrix.config.build_type}} --parallel
224+
run: cmake --build ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}} --parallel
269225

270226
- name: Install for AWS SDK C++
271227
if: steps.cache-aws-sdk-cpp-libraries.outputs.cache-hit != 'true'
272-
run: cmake --install ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}} --config ${{matrix.config.build_type}}
273-
274-
- name: Checking out source tree
275-
uses: actions/checkout@v4
276-
with:
277-
path: src
278-
fetch-depth: 0
279-
fetch-tags: true
228+
run: cmake --install ${{github.workspace}}/aws-sdk-cpp-build-${{matrix.config.label}}
280229

281230
- name: Configure CMake
282-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
283-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
284-
run: |
285-
cmake -Wdev -Werror=dev -Wdeprecated -Werror=deprecated \
286-
-B ${{github.workspace}}/build-${{matrix.config.label}} \
287-
-S ${{github.workspace}}/src \
288-
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} \
289-
-DCMAKE_C_COMPILER=${{matrix.config.cc}} \
290-
-DCMAKE_CXX_COMPILER=${{matrix.config.cxx}} \
291-
-DCPP_STANDARD=20 \
292-
${{matrix.config.libcxx_cmake_flags}} \
293-
${{matrix.config.sanitizer_cmake_flags}} \
294-
-DCMAKE_PREFIX_PATH=${{runner.temp}}/deps/aws-sdk-cpp-install-${{matrix.config.label}} \
295-
-DBoost_ROOT=${{runner.temp}}/deps/boost-install-${{matrix.config.label}} \
296-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
231+
run: cmake ${{github.workspace}}/src --preset ${{matrix.config.label}}
297232

298233
- name: CMake info
299-
run: cmake -L ${{github.workspace}}/build-${{matrix.config.label}}
234+
run: cmake -L ${{github.workspace}}/src-build-${{matrix.config.label}}
300235

301236
- name: Build
302237
# Build your program with the given configuration
303-
run: cmake --build ${{github.workspace}}/build-${{matrix.config.label}} --config ${{matrix.config.build_type}} --parallel
238+
run: cmake --build ${{github.workspace}}/src-build-${{matrix.config.label}} --parallel
304239

305240
- name: Info Clang Tidy
306241
if: matrix.config.run_clang_tidy
@@ -309,7 +244,7 @@ jobs:
309244
- name: Clang Tidy
310245
if: matrix.config.run_clang_tidy
311246
# Run Clang Tidy
312-
run: run-clang-tidy-17 -header-filter=.* -j=${{steps.cpu-cores.outputs.count}} -use-color -p=${{github.workspace}}/build-${{matrix.config.label}}
247+
run: run-clang-tidy-17 -header-filter=.* -j=${{steps.cpu-cores.outputs.count}} -use-color -p=${{github.workspace}}/src-build-${{matrix.config.label}}
313248

314249
- name: MTR tests
315250
if: matrix.config.run_mtr
@@ -320,19 +255,18 @@ jobs:
320255
# Linking the "binlog_streaming" from the source tree into the MTR suits directory on the system
321256
sudo ln -s ${{github.workspace}}/src/mtr/binlog_streaming /usr/lib/mysql-test/suite/binlog_streaming
322257
# Running MTR from the system package
323-
BINSRV=${{github.workspace}}/build-${{matrix.config.label}}/binlog_server ./mtr \
258+
BINSRV=${{github.workspace}}/src-build-${{matrix.config.label}}/binlog_server ./mtr \
324259
--client-bindir=/usr/lib/mysql-test/bin --vardir=${{runner.temp}}/mtrvardir \
325260
--force --max-test-fail=0 --retry=0 --nounit-tests --big-test --repeat=2 --parallel=${{steps.cpu-cores.outputs.count}} \
326261
--suite=binlog_streaming ${{matrix.config.mtr_options}}
327262
328263
- name: CTest
329-
working-directory: ${{github.workspace}}/build-${{matrix.config.label}}
264+
working-directory: ${{github.workspace}}/src-build-${{matrix.config.label}}
330265
# Execute tests defined by the CMake configuration.
331266
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
332-
run: ctest -C ${{matrix.config.build_type}} --parallel
267+
run: ctest --parallel
333268

334269
- name: Info Build artefacts
335270
run: |
336271
ls -la ${{github.workspace}}
337272
ls -la ${{runner.temp}}
338-
ls -la ${{runner.temp}}/deps

CMakePresets.json

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 21,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "common_hidden",
11+
"hidden": true,
12+
"generator": "Unix Makefiles",
13+
"binaryDir": "${sourceParentDir}/${sourceDirName}-build-${presetName}",
14+
"installDir": "${sourceParentDir}/${sourceDirName}-install-${presetName}",
15+
"cacheVariables": {
16+
"CMAKE_PREFIX_PATH": "${sourceParentDir}/aws-sdk-cpp-install-${presetName};${sourceParentDir}/boost-install-${presetName}",
17+
"CPP_STANDARD": "20",
18+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
19+
}
20+
},
21+
22+
{
23+
"name": "debug_hidden",
24+
"hidden": true,
25+
"cacheVariables": {
26+
"CMAKE_BUILD_TYPE": "Debug"
27+
}
28+
},
29+
{
30+
"name": "release_hidden",
31+
"hidden": true,
32+
"cacheVariables": {
33+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
34+
}
35+
},
36+
{
37+
"name": "asan_hidden",
38+
"hidden": true,
39+
"cacheVariables": {
40+
"CMAKE_BUILD_TYPE": "Debug",
41+
"WITH_ASAN": "ON"
42+
}
43+
},
44+
45+
{
46+
"name": "gcc13_hidden",
47+
"hidden": true,
48+
"cacheVariables": {
49+
"CMAKE_C_COMPILER": "gcc-13",
50+
"CMAKE_CXX_COMPILER": "g++-13"
51+
}
52+
},
53+
{
54+
"name": "clang17_hidden",
55+
"hidden": true,
56+
"cacheVariables": {
57+
"CMAKE_C_COMPILER": "clang-17",
58+
"CMAKE_CXX_COMPILER": "clang++-17",
59+
"WITH_STDLIB_LIBCXX": "ON"
60+
}
61+
},
62+
63+
{
64+
"name": "debug_gcc13",
65+
"inherits": [
66+
"common_hidden",
67+
"debug_hidden",
68+
"gcc13_hidden"
69+
],
70+
"displayName": "GCC 13 Debug"
71+
},
72+
{
73+
"name": "release_gcc13",
74+
"inherits": [
75+
"common_hidden",
76+
"release_hidden",
77+
"gcc13_hidden"
78+
],
79+
"displayName": "GCC 13 RelWithDebInfo"
80+
},
81+
{
82+
"name": "asan_gcc13",
83+
"inherits": [
84+
"common_hidden",
85+
"asan_hidden",
86+
"gcc13_hidden"
87+
],
88+
"displayName": "GCC 13 ASan"
89+
},
90+
91+
{
92+
"name": "debug_clang17",
93+
"inherits": [
94+
"common_hidden",
95+
"debug_hidden",
96+
"clang17_hidden"
97+
],
98+
"displayName": "Clang 17 Debug"
99+
},
100+
{
101+
"name": "release_clang17",
102+
"inherits": [
103+
"common_hidden",
104+
"release_hidden",
105+
"clang17_hidden"
106+
],
107+
"displayName": "Clang 17 RelWithDebInfo"
108+
},
109+
{
110+
"name": "asan_clang17",
111+
"inherits": [
112+
"common_hidden",
113+
"asan_hidden",
114+
"clang17_hidden"
115+
],
116+
"displayName": "Clang 17 ASan"
117+
}
118+
]
119+
}

0 commit comments

Comments
 (0)