Skip to content

Commit ecfa44c

Browse files
committed
Refactor to use CMake presets
1 parent d8d5669 commit ecfa44c

27 files changed

Lines changed: 249 additions & 100 deletions

.github/workflows/main.yml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ jobs:
8989
9090
- name: Configure CMake
9191
run: |
92-
./gen-linux-x64-release.sh
92+
cp CMakeUserPresets.json.posix.template CMakeUserPresets.json
93+
cmake --preset default
9394
9495
- name: Upload vcpkg failure logs
9596
if: failure()
@@ -99,26 +100,22 @@ jobs:
99100
path: vcpkg/buildtrees/**/*.log
100101
if-no-files-found: ignore
101102

102-
- name: Build Release targets
103+
- name: Build
103104
run: |
104-
cmake --build build/Release
105+
cmake --build --preset default
105106
106107
- name: Run tests
107108
run: |
108-
export ISC_USER=sysdba
109-
export ISC_PASSWORD=masterkey
110-
export FBCPP_TEST_SERVER=localhost
111-
export FBCPP_TEST_DIR=/tmp
112-
./build/Release/out/bin/fb-cpp-test
109+
ctest --preset default --verbose
113110
114111
- name: Build documentation
115112
run: |
116-
cmake --build build/Release --target docs
113+
cmake --build --preset default --target docs
117114
118115
- name: Upload documentation artifact
119116
uses: actions/upload-pages-artifact@v4
120117
with:
121-
path: build/Release/doc/docs/html
118+
path: build/Debug/doc/docs/html
122119

123120
build-windows:
124121
runs-on: windows-latest
@@ -169,7 +166,8 @@ jobs:
169166
- name: Configure CMake
170167
shell: cmd
171168
run: |
172-
.\gen-windows.bat
169+
copy CMakeUserPresets.json.windows.template CMakeUserPresets.json
170+
cmake --preset default
173171
174172
- name: Upload vcpkg failure logs
175173
if: failure()
@@ -179,18 +177,15 @@ jobs:
179177
path: vcpkg/buildtrees/**/*.log
180178
if-no-files-found: ignore
181179

182-
- name: Build Release targets
180+
- name: Build
183181
shell: cmd
184182
run: |
185-
cmake --build build --config Release
183+
cmake --build --preset default
186184
187185
- name: Run tests
188186
shell: cmd
189187
run: |
190-
set ISC_USER=sysdba
191-
set ISC_PASSWORD=masterkey
192-
set FBCPP_TEST_SERVER=localhost
193-
build\out\bin\Release\fb-cpp-test.exe
188+
ctest --preset default --verbose
194189
195190
build-macos:
196191
runs-on: macos-latest
@@ -240,7 +235,8 @@ jobs:
240235
241236
- name: Configure CMake
242237
run: |
243-
./gen-osx-arm64-release.sh
238+
cp CMakeUserPresets.json.posix.template CMakeUserPresets.json
239+
cmake --preset default
244240
245241
- name: Upload vcpkg failure logs
246242
if: failure()
@@ -250,16 +246,13 @@ jobs:
250246
path: vcpkg/buildtrees/**/*.log
251247
if-no-files-found: ignore
252248

253-
- name: Build Release targets
249+
- name: Build
254250
run: |
255-
cmake --build build/Release
251+
cmake --build --preset default
256252
257253
- name: Run tests
258254
run: |
259-
export ISC_USER=sysdba
260-
export ISC_PASSWORD=masterkey
261-
export FBCPP_TEST_SERVER=localhost
262-
./build/Release/out/bin/fb-cpp-test
255+
ctest --preset default --verbose
263256
264257
deploy-docs:
265258
runs-on: ubuntu-latest

.github/workflows/pull-request.yml

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
workflow_dispatch:
78

89
jobs:
910
clang-format-check:
@@ -80,7 +81,8 @@ jobs:
8081
8182
- name: Configure CMake
8283
run: |
83-
./gen-linux-x64-release.sh
84+
cp CMakeUserPresets.json.posix.template CMakeUserPresets.json
85+
cmake --preset default
8486
8587
- name: Upload vcpkg failure logs
8688
if: failure()
@@ -90,21 +92,17 @@ jobs:
9092
path: vcpkg/buildtrees/**/*.log
9193
if-no-files-found: ignore
9294

93-
- name: Build Release targets
95+
- name: Build
9496
run: |
95-
cmake --build build/Release
97+
cmake --build --preset default
9698
9799
- name: Run tests
98100
run: |
99-
export ISC_USER=sysdba
100-
export ISC_PASSWORD=masterkey
101-
export FBCPP_TEST_SERVER=localhost
102-
export FBCPP_TEST_DIR=/tmp
103-
./build/Release/out/bin/fb-cpp-test
101+
ctest --preset default --verbose
104102
105103
- name: Build documentation
106104
run: |
107-
cmake --build build/Release --target docs
105+
cmake --build --preset default --target docs
108106
109107
build-windows:
110108
runs-on: windows-latest
@@ -155,7 +153,8 @@ jobs:
155153
- name: Configure CMake
156154
shell: cmd
157155
run: |
158-
.\gen-windows.bat
156+
copy CMakeUserPresets.json.windows.template CMakeUserPresets.json
157+
cmake --preset default
159158
160159
- name: Upload vcpkg failure logs
161160
if: failure()
@@ -165,18 +164,17 @@ jobs:
165164
path: vcpkg/buildtrees/**/*.log
166165
if-no-files-found: ignore
167166

168-
- name: Build Release targets
167+
- name: Build
169168
shell: cmd
170169
run: |
171-
cmake --build build --config Release
170+
cmake --build --preset default
172171
173172
- name: Run tests
174173
shell: cmd
175174
run: |
176175
set ISC_USER=sysdba
177176
set ISC_PASSWORD=masterkey
178-
set FBCPP_TEST_SERVER=localhost
179-
build\out\bin\Release\fb-cpp-test.exe
177+
ctest --preset default --verbose
180178
181179
build-macos:
182180
runs-on: macos-latest
@@ -226,7 +224,8 @@ jobs:
226224
227225
- name: Configure CMake
228226
run: |
229-
./gen-osx-arm64-release.sh
227+
cp CMakeUserPresets.json.posix.template CMakeUserPresets.json
228+
cmake --preset default
230229
231230
- name: Upload vcpkg failure logs
232231
if: failure()
@@ -236,13 +235,10 @@ jobs:
236235
path: vcpkg/buildtrees/**/*.log
237236
if-no-files-found: ignore
238237

239-
- name: Build Release targets
238+
- name: Build
240239
run: |
241-
cmake --build build/Release
240+
cmake --build --preset default
242241
243242
- name: Run tests
244243
run: |
245-
export ISC_USER=sysdba
246-
export ISC_PASSWORD=masterkey
247-
export FBCPP_TEST_SERVER=localhost
248-
./build/Release/out/bin/fb-cpp-test
244+
ctest --preset default --verbose

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
build/
22
temp/
33
.env
4+
.env.bat
5+
/CMakeUserPresets.json

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
},
66
"cmake.sourceDirectory": "${workspaceFolder}",
77
"cmake.buildDirectory": "${workspaceFolder}/build/${buildType}",
8+
"cmake.useCMakePresets": "auto",
89
"cmake.generator": "Ninja",
910
"cmake.configureSettings": {
1011
"CMAKE_VERBOSE_MAKEFILE": "ON",

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
```
1717
1818
### Build
19-
- If .cpp files are added, it's necessary to run `./gen-linux-x64-debug.sh` (non-Windows) or `gen-windows.bat` (Windows) from the repo root.
20-
- Use `cmake --build build/Debug/` (non-Windows) or `cmake --build build --config Debug` (Windows) from the repo root.
19+
- If .cpp files are added, it's necessary to run `cmake --preset default` from the repo root.
20+
- Use `cmake --build --preset default` from the repo root.
2121
2222
### Tests
2323
- Test code can use Boost.Multiprecision without conditional compilation.
24-
- Run the Boost.Test suite with `./run-tests.sh` (non-Windows) or `run-tests.bat` (Windows).
25-
Boost.Test options can be used (for example, `./run-tests.sh --log_level=all` or `run-tests.bat --log_level=all`).
24+
- Run the Boost.Test suite with `ctest --preset default --verbose`.
25+
- Boost.Test options can be used with environments variables like `BOOST_TEST_LOG_LEVEL=all`.

CMakePresets.json

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "ninja-base",
6+
"displayName": "Ninja with vcpkg (base)",
7+
"description": "Base preset for Ninja builds with vcpkg and local overlay triplets",
8+
"hidden": true,
9+
"generator": "Ninja",
10+
"cacheVariables": {
11+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
12+
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/cmake/triplets",
13+
"VCPKG_ROOT": "${sourceDir}/vcpkg",
14+
"VCPKG_INSTALLED_DIR": "${sourceDir}/build/vcpkg_installed",
15+
"CMAKE_VERBOSE_MAKEFILE": "ON"
16+
}
17+
},
18+
{
19+
"name": "posix-ninja-debug",
20+
"displayName": "Linux/MacOS Debug (Ninja)",
21+
"inherits": [
22+
"ninja-base"
23+
],
24+
"binaryDir": "${sourceDir}/build/Debug",
25+
"cacheVariables": {
26+
"CMAKE_BUILD_TYPE": "Debug"
27+
}
28+
},
29+
{
30+
"name": "posix-ninja-release",
31+
"displayName": "Linux/MacOS Release (Ninja)",
32+
"inherits": [
33+
"ninja-base"
34+
],
35+
"binaryDir": "${sourceDir}/build/Release",
36+
"cacheVariables": {
37+
"CMAKE_BUILD_TYPE": "Release"
38+
}
39+
},
40+
{
41+
"name": "windows-vs2022",
42+
"displayName": "Windows (Visual Studio 2022)",
43+
"description": "Multi-config build with the Visual Studio 17 2022 generator",
44+
"generator": "Visual Studio 17 2022",
45+
"architecture": {
46+
"value": "x64",
47+
"strategy": "external"
48+
},
49+
"binaryDir": "${sourceDir}/build",
50+
"cacheVariables": {
51+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
52+
"VCPKG_ROOT": "${sourceDir}/vcpkg"
53+
}
54+
}
55+
],
56+
"buildPresets": [
57+
{
58+
"name": "posix-ninja-debug",
59+
"configurePreset": "posix-ninja-debug"
60+
},
61+
{
62+
"name": "posix-ninja-release",
63+
"configurePreset": "posix-ninja-release"
64+
},
65+
{
66+
"name": "windows-vs2022-debug",
67+
"configurePreset": "windows-vs2022",
68+
"configuration": "Debug"
69+
},
70+
{
71+
"name": "windows-vs2022-release",
72+
"configurePreset": "windows-vs2022",
73+
"configuration": "Release"
74+
}
75+
],
76+
"testPresets": [
77+
{
78+
"name": "posix-ninja-debug",
79+
"configurePreset": "posix-ninja-debug"
80+
},
81+
{
82+
"name": "posix-ninja-release",
83+
"configurePreset": "posix-ninja-release"
84+
},
85+
{
86+
"name": "windows-vs2022-debug",
87+
"configurePreset": "windows-vs2022",
88+
"configuration": "Debug"
89+
},
90+
{
91+
"name": "windows-vs2022-release",
92+
"configurePreset": "windows-vs2022",
93+
"configuration": "Release"
94+
}
95+
]
96+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "default",
6+
"inherits": [
7+
"posix-ninja-debug"
8+
]
9+
}
10+
],
11+
"buildPresets": [
12+
{
13+
"name": "default",
14+
"inherits": [
15+
"posix-ninja-debug"
16+
]
17+
}
18+
],
19+
"testPresets": [
20+
{
21+
"name": "default",
22+
"inherits": [
23+
"posix-ninja-debug"
24+
],
25+
"environment": {
26+
"FBCPP_TEST_SERVER": "localhost",
27+
"ISC_USER": "sysdba",
28+
"ISC_PASSWORD": "masterkey"
29+
}
30+
}
31+
]
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": 3,
3+
"configurePresets": [
4+
{
5+
"name": "default",
6+
"inherits": [
7+
"windows-vs2022"
8+
]
9+
}
10+
],
11+
"buildPresets": [
12+
{
13+
"name": "default",
14+
"inherits": [
15+
"windows-vs2022-debug"
16+
]
17+
}
18+
],
19+
"testPresets": [
20+
{
21+
"name": "default",
22+
"inherits": [
23+
"windows-vs2022-debug"
24+
],
25+
"environment": {
26+
"FBCPP_TEST_SERVER": "localhost",
27+
"ISC_USER": "sysdba",
28+
"ISC_PASSWORD": "masterkey"
29+
}
30+
}
31+
]
32+
}

0 commit comments

Comments
 (0)