Skip to content

Commit 4ce823a

Browse files
committed
added cmake presets for enabling additional compiler warnings (as in VC)
1 parent 1cf1942 commit 4ce823a

File tree

2 files changed

+232
-0
lines changed

2 files changed

+232
-0
lines changed

CMakePresets.json

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"version": 2,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 14,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "cmake-pedantic",
11+
"hidden": true,
12+
"warnings": {
13+
"dev": true,
14+
"deprecated": true,
15+
"uninitialized": true,
16+
"unusedCli": true,
17+
"systemVars": false
18+
},
19+
"errors": {
20+
"dev": true,
21+
"deprecated": true
22+
}
23+
},
24+
{
25+
"name": "dev-mode",
26+
"hidden": true,
27+
"inherits": "cmake-pedantic",
28+
"cacheVariables": {
29+
"CrowCpp_DEVELOPER_MODE": "ON"
30+
}
31+
},
32+
{
33+
"name": "cppcheck",
34+
"hidden": true,
35+
"cacheVariables": {
36+
"CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr"
37+
}
38+
},
39+
{
40+
"name": "clang-tidy",
41+
"hidden": true,
42+
"cacheVariables": {
43+
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=^${sourceDir}/"
44+
}
45+
},
46+
{
47+
"name": "ci-std",
48+
"description": "This preset makes sure the project actually builds with at least the specified standard",
49+
"hidden": true,
50+
"cacheVariables": {
51+
"CMAKE_CXX_EXTENSIONS": "OFF",
52+
"CMAKE_CXX_STANDARD": "17",
53+
"CMAKE_CXX_STANDARD_REQUIRED": "ON"
54+
}
55+
},
56+
{
57+
"name": "flags-gcc-clang",
58+
"description": "These flags are supported by both GCC and Clang",
59+
"hidden": true,
60+
"cacheVariables": {
61+
"CMAKE_CXX_FLAGS": "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS=1 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast",
62+
"CMAKE_EXE_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now,-z,nodlopen",
63+
"CMAKE_SHARED_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now,-z,nodlopen"
64+
}
65+
},
66+
{
67+
"name": "flags-appleclang",
68+
"hidden": true,
69+
"cacheVariables": {
70+
"CMAKE_CXX_FLAGS": "-fstack-protector-strong -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast"
71+
}
72+
},
73+
{
74+
"name": "flags-msvc",
75+
"description": "Note that all the flags after /W4 are required for MSVC to conform to the language standard",
76+
"hidden": true,
77+
"cacheVariables": {
78+
"CMAKE_CXX_FLAGS": "/sdl /guard:cf /utf-8 /diagnostics:caret /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w45038 /W4 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc",
79+
"CMAKE_EXE_LINKER_FLAGS": "/machine:x64 /guard:cf"
80+
}
81+
},
82+
{
83+
"name": "ci-linux",
84+
"inherits": ["flags-gcc-clang", "ci-std"],
85+
"generator": "Unix Makefiles",
86+
"hidden": true,
87+
"cacheVariables": {
88+
"CMAKE_BUILD_TYPE": "Release"
89+
}
90+
},
91+
{
92+
"name": "ci-darwin",
93+
"inherits": ["flags-appleclang", "ci-std"],
94+
"generator": "Xcode",
95+
"hidden": true
96+
},
97+
{
98+
"name": "ci-win64",
99+
"inherits": ["flags-msvc", "ci-std"],
100+
"generator": "Visual Studio 17 2022",
101+
"architecture": "x64",
102+
"hidden": true
103+
},
104+
{
105+
"name": "coverage-linux",
106+
"binaryDir": "${sourceDir}/build/coverage",
107+
"inherits": "ci-linux",
108+
"hidden": true,
109+
"cacheVariables": {
110+
"ENABLE_COVERAGE": "ON",
111+
"CMAKE_BUILD_TYPE": "Coverage",
112+
"CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions",
113+
"CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage",
114+
"CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage"
115+
}
116+
},
117+
{
118+
"name": "ci-coverage",
119+
"inherits": ["coverage-linux", "dev-mode"],
120+
"cacheVariables": {
121+
"COVERAGE_HTML_COMMAND": ""
122+
}
123+
},
124+
{
125+
"name": "ci-sanitize",
126+
"binaryDir": "${sourceDir}/build/sanitize",
127+
"inherits": ["ci-linux", "dev-mode"],
128+
"cacheVariables": {
129+
"CMAKE_BUILD_TYPE": "Sanitize",
130+
"CMAKE_CXX_FLAGS_SANITIZE": "-U_FORTIFY_SOURCE -O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common"
131+
}
132+
},
133+
{
134+
"name": "ci-build",
135+
"binaryDir": "${sourceDir}/build",
136+
"hidden": true
137+
},
138+
{
139+
"name": "ci-multi-config",
140+
"description": "Speed up multi-config generators by generating only one configuration instead of the defaults",
141+
"hidden": true,
142+
"cacheVariables": {
143+
"CMAKE_CONFIGURATION_TYPES": "Release"
144+
}
145+
},
146+
{
147+
"name": "ci-macos",
148+
"inherits": ["ci-build", "ci-darwin", "dev-mode", "ci-multi-config"]
149+
},
150+
{
151+
"name": "ci-ubuntu",
152+
"inherits": ["ci-build", "ci-linux", "clang-tidy", "cppcheck", "dev-mode"]
153+
},
154+
{
155+
"name": "ci-windows",
156+
"inherits": ["ci-build", "ci-win64", "dev-mode", "ci-multi-config"]
157+
}
158+
]
159+
}

CMakeUserPresets.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"version": 2,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 14,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "dev-common",
11+
"hidden": true,
12+
"inherits": ["dev-mode", "clang-tidy", "cppcheck"],
13+
"cacheVariables": {
14+
"BUILD_MCSS_DOCS": "ON"
15+
}
16+
},
17+
{
18+
"name": "dev-linux",
19+
"binaryDir": "${sourceDir}/build/dev-linux",
20+
"inherits": ["dev-common", "ci-linux"],
21+
"cacheVariables": {
22+
"CMAKE_BUILD_TYPE": "Debug",
23+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
24+
}
25+
},
26+
{
27+
"name": "dev-darwin",
28+
"binaryDir": "${sourceDir}/build/dev-darwin",
29+
"inherits": ["dev-common", "ci-darwin"]
30+
},
31+
{
32+
"name": "dev-win64",
33+
"binaryDir": "${sourceDir}/build/dev-win64",
34+
"inherits": ["dev-common", "ci-win64"],
35+
"environment": {
36+
"UseMultiToolTask": "true",
37+
"EnforceProcessCountAcrossBuilds": "true"
38+
}
39+
},
40+
{
41+
"name": "dev",
42+
"binaryDir": "${sourceDir}/build/dev",
43+
"inherits": "dev-darwin"
44+
},
45+
{
46+
"name": "dev-coverage",
47+
"binaryDir": "${sourceDir}/build/coverage",
48+
"inherits": ["dev-mode", "coverage-linux"]
49+
}
50+
],
51+
"buildPresets": [
52+
{
53+
"name": "dev",
54+
"configurePreset": "dev",
55+
"configuration": "Debug",
56+
"jobs": 10
57+
}
58+
],
59+
"testPresets": [
60+
{
61+
"name": "dev",
62+
"configurePreset": "dev",
63+
"configuration": "Debug",
64+
"output": {
65+
"outputOnFailure": true
66+
},
67+
"execution": {
68+
"jobs": 10,
69+
"noTestsAction": "error"
70+
}
71+
}
72+
]
73+
}

0 commit comments

Comments
 (0)