Skip to content

Commit eba1049

Browse files
(WIP) Add CMake Presets and move compiler flags out of main CMakeLists.txt
1 parent c9e98f7 commit eba1049

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ set(HAVE_TERMCAP "${TERMCAP_FOUND}")
224224

225225
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${CMAKE_INSTALL_FULL_LIBDIR}/icinga2")
226226

227+
# TODO: Move all of this into CMake Presets
227228
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
228229
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Winconsistent-missing-override -Wrange-loop-construct")
229230

CMakePresets.json

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"version": 2,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 20,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "default",
11+
"hidden": true,
12+
"cacheVariables": {
13+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
14+
},
15+
"environment": {
16+
"CFLAGS" : "-Wall -Wextra -Wno-stringop-overflow",
17+
"CXXFLAGS" : ""
18+
}
19+
},
20+
{
21+
"name": "gcc",
22+
"hidden": true,
23+
"environment": {
24+
"CFLAGS" : "$penv{CFLAGS} -Wsuggest-override",
25+
"CXXFLAGS" : "$env{CFLAGS}"
26+
}
27+
},
28+
{
29+
"name": "clang",
30+
"hidden": true,
31+
"environment": {
32+
"CFLAGS" : "$penv{CFLAGS}",
33+
"CXXFLAGS" : "$env{CFLAGS}"
34+
}
35+
},
36+
{
37+
"name": "ninja",
38+
"hidden": true,
39+
"generator": "Ninja"
40+
},
41+
{
42+
"name": "make",
43+
"hidden": true,
44+
"generator": "Unix Makefiles"
45+
},
46+
{
47+
"name": "release",
48+
"hidden": true,
49+
"binaryDir": "${sourceDir}/build/release",
50+
"cacheVariables": {
51+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
52+
},
53+
"environment": {
54+
"CFLAGS" : "$penv{CFLAGS}",
55+
"CXXFLAGS" : "$env{CFLAGS}"
56+
}
57+
},
58+
{
59+
"name": "debug",
60+
"hidden": true,
61+
"binaryDir": "${sourceDir}/build/debug",
62+
"cacheVariables": {
63+
"CMAKE_BUILD_TYPE": "Debug"
64+
},
65+
"environment": {
66+
"CFLAGS" : "$penv{CFLAGS}",
67+
"CXXFLAGS" : "$env{CFLAGS}"
68+
}
69+
},
70+
{
71+
"name": "release-gcc",
72+
"inherits": [ "default", "gcc", "make", "release" ]
73+
}
74+
],
75+
"buildPresets": [
76+
{
77+
"name": "release",
78+
"configurePreset": "release"
79+
},
80+
{
81+
"name": "debug",
82+
"configurePreset": "debug"
83+
}
84+
]
85+
}

0 commit comments

Comments
 (0)