Skip to content

Commit 293528a

Browse files
committed
cmake: add presets file to ease use of asan
problem: build configurations can be complicated to manage, especially for sanitizers and similar. solution: cmake supports a CMakePresets.json file to define commonly used build and test configurations. Add one of these that has the correct configuration for configuring, building and testing both in the default mode and with address sanitizer.
1 parent f35b14a commit 293528a

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

CMakePresets.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 23,
6+
"patch": 0
7+
},
8+
"include": [
9+
"otherThings.json",
10+
"moreThings.json"
11+
],
12+
"configurePresets": [
13+
{
14+
"name": "default",
15+
"displayName": "Default Config",
16+
"description": "Default build using Ninja generator",
17+
"generator": "Ninja",
18+
"binaryDir": "${sourceDir}/build/default",
19+
"cacheVariables": {},
20+
"environment": {},
21+
"vendor": {}
22+
},
23+
{
24+
"name": "asan",
25+
"displayName": "Debug with address sanitizer",
26+
"description": "ASAN build using Ninja generator",
27+
"inherits": "default",
28+
"binaryDir": "${sourceDir}/build/asan",
29+
"cacheVariables": {
30+
"SANITIZE_ADDRESS": "ON"
31+
}
32+
}
33+
],
34+
"buildPresets": [
35+
{
36+
"name": "default",
37+
"configurePreset": "default"
38+
},
39+
{
40+
"name": "asan",
41+
"configurePreset": "asan"
42+
}
43+
],
44+
"testPresets": [
45+
{
46+
"name": "default",
47+
"configurePreset": "default",
48+
"output": {
49+
"outputOnFailure": true
50+
},
51+
"execution": {
52+
"noTestsAction": "error",
53+
"stopOnFailure": true
54+
}
55+
},
56+
{
57+
"name": "Asan",
58+
"configurePreset": "asan",
59+
"output": {
60+
"outputOnFailure": true,
61+
"verbosity": "verbose"
62+
},
63+
"environment": {
64+
"ASAN_OPTIONS": "detect_leaks=0,start_deactivated=true,replace_str=true,verify_asan_link_order=false"
65+
},
66+
"execution": {
67+
"noTestsAction": "error",
68+
"stopOnFailure": true
69+
}
70+
}
71+
],
72+
"packagePresets": [
73+
{
74+
"name": "default",
75+
"configurePreset": "default",
76+
"generators": []
77+
}
78+
],
79+
"workflowPresets": [],
80+
"vendor": {}
81+
}

0 commit comments

Comments
 (0)