Skip to content

Commit 0d1895f

Browse files
committed
Add my generic presets
1 parent 13bb730 commit 0d1895f

File tree

6 files changed

+266
-3
lines changed

6 files changed

+266
-3
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22

3-
if(CMAKE_CXX_STANDARD STREQUAL 26)
3+
if(CMAKE_CXX_STANDARD GREATER_EQUAL 23)
44
if(CMAKE_CXX_MODULE_STD)
55
set(CMAKE_CXX_SCAN_FOR_MODULES 1)
6+
# for cmake version 4.0.2
67
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
7-
"d0edc3af-4c50-42ea-a356-e2862fe7a444"
8+
"a9e1cf81-9932-4810-974b-6eccaf14e457"
89
)
910
add_definitions(-DHAS_STDLIB_MODULES)
1011
endif()
1112
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
1213
endif()
1314

14-
cmake_minimum_required(VERSION 3.28...4.0)
15+
cmake_minimum_required(VERSION 4.0)
1516

1617
project(
1718
beman.scope
@@ -43,6 +44,7 @@ endif()
4344

4445
include(CMakePrintHelpers)
4546
cmake_print_variables(
47+
CMAKE_CXX_STANDARD
4648
CMAKE_CXX_SCAN_FOR_MODULES
4749
CMAKE_CXX_MODULE_STD
4850
CMAKE_CXX_COMPILER_IMPORT_STD
@@ -84,6 +86,7 @@ if(CMAKE_CXX_SCAN_FOR_MODULES)
8486
BASE_DIRS include
8587
FILES include/beman/scope/beman.scope.cppm
8688
)
89+
target_compile_features(beman.scope PUBLIC cxx_std_23)
8790
else()
8891
add_library(beman.scope INTERFACE)
8992
target_sources(
@@ -93,6 +96,8 @@ else()
9396
BASE_DIRS include
9497
FILES include/beman/scope/scope.hpp
9598
)
99+
# prevent "not include "cxx_std_20" (or newer) among its `target_compile_features`; no C++ standard found"
100+
target_compile_features(beman.scope PUBLIC cxx_std_20)
96101
endif()
97102

98103
add_library(beman::scope ALIAS beman.scope)

CMakeUserPresets.json

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"version": 9,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 30,
6+
"patch": 0
7+
},
8+
"include": [
9+
"cmake/CMake${hostSystemName}Presets.json"
10+
],
11+
"buildPresets": [
12+
{
13+
"name": "debug",
14+
"configurePreset": "debug",
15+
"configuration": "Debug",
16+
"targets": [
17+
"install"
18+
]
19+
},
20+
{
21+
"name": "release",
22+
"configurePreset": "release",
23+
"configuration": "Release",
24+
"targets": [
25+
"all_verify_interface_header_sets",
26+
"install"
27+
]
28+
}
29+
],
30+
"testPresets": [
31+
{
32+
"name": "test_base",
33+
"hidden": true,
34+
"output": {
35+
"outputOnFailure": true
36+
},
37+
"execution": {
38+
"noTestsAction": "error",
39+
"stopOnFailure": false
40+
}
41+
},
42+
{
43+
"name": "debug",
44+
"inherits": "test_base",
45+
"configuration": "Debug",
46+
"configurePreset": "debug"
47+
},
48+
{
49+
"name": "release",
50+
"inherits": "test_base",
51+
"configuration": "Release",
52+
"configurePreset": "release"
53+
}
54+
],
55+
"packagePresets": [
56+
{
57+
"name": "release",
58+
"configurePreset": "release",
59+
"configurations": [
60+
"Release"
61+
],
62+
"generators": [
63+
"TGZ"
64+
]
65+
}
66+
],
67+
"workflowPresets": [
68+
{
69+
"name": "debug",
70+
"steps": [
71+
{
72+
"type": "configure",
73+
"name": "debug"
74+
},
75+
{
76+
"type": "build",
77+
"name": "debug"
78+
},
79+
{
80+
"type": "test",
81+
"name": "debug"
82+
}
83+
]
84+
},
85+
{
86+
"name": "release",
87+
"steps": [
88+
{
89+
"type": "configure",
90+
"name": "release"
91+
},
92+
{
93+
"type": "build",
94+
"name": "release"
95+
},
96+
{
97+
"type": "test",
98+
"name": "release"
99+
},
100+
{
101+
"type": "package",
102+
"name": "release"
103+
}
104+
]
105+
}
106+
]
107+
}

cmake/CMakeDarwinPresets.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": 6,
3+
"include": [
4+
"CMakeGenericPresets.json"
5+
],
6+
"configurePresets": [
7+
{
8+
"name": "debug-base-Darwin",
9+
"hidden": true,
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug"
12+
},
13+
"condition": {
14+
"type": "equals",
15+
"lhs": "${hostSystemName}",
16+
"rhs": "Darwin"
17+
}
18+
},
19+
{
20+
"name": "release-base-Darwin",
21+
"hidden": true,
22+
"cacheVariables": {
23+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
24+
},
25+
"condition": {
26+
"type": "equals",
27+
"lhs": "${hostSystemName}",
28+
"rhs": "Darwin"
29+
}
30+
},
31+
{
32+
"name": "debug",
33+
"displayName": "Debug Build",
34+
"inherits": [
35+
"root-config",
36+
"debug-base-Darwin"
37+
]
38+
},
39+
{
40+
"name": "release",
41+
"displayName": "Release Build",
42+
"inherits": [
43+
"root-config",
44+
"release-base-Darwin"
45+
]
46+
}
47+
]
48+
}

cmake/CMakeGenericPresets.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "root-config",
6+
"hidden": true,
7+
"generator": "Ninja",
8+
"binaryDir": "${sourceDir}/build/${presetName}",
9+
"installDir": "${sourceDir}/stagedir",
10+
"cacheVariables": {
11+
"CMAKE_PREFIX_PATH": {
12+
"type": "path",
13+
"value": "${sourceDir}/stagedir"
14+
},
15+
"CMAKE_CXX_EXTENSIONS": false,
16+
"CMAKE_CXX_STANDARD": "23",
17+
"CMAKE_CXX_STANDARD_REQUIRED": false,
18+
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
19+
"CMAKE_SKIP_TEST_ALL_DEPENDENCY": false
20+
}
21+
}
22+
]
23+
}

cmake/CMakeLinuxPresets.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": 6,
3+
"include": [
4+
"CMakeGenericPresets.json"
5+
],
6+
"configurePresets": [
7+
{
8+
"name": "debug-base-Linux",
9+
"hidden": true,
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug"
12+
},
13+
"condition": {
14+
"type": "equals",
15+
"lhs": "${hostSystemName}",
16+
"rhs": "Linux"
17+
}
18+
},
19+
{
20+
"name": "release-base-Linux",
21+
"hidden": true,
22+
"cacheVariables": {
23+
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
24+
},
25+
"condition": {
26+
"type": "notEquals",
27+
"lhs": "${hostSystemName}",
28+
"rhs": "Windows"
29+
}
30+
},
31+
{
32+
"name": "debug",
33+
"displayName": "Debug Build",
34+
"inherits": [
35+
"root-config",
36+
"debug-base-Linux"
37+
]
38+
},
39+
{
40+
"name": "release",
41+
"displayName": "Release Build",
42+
"inherits": [
43+
"root-config",
44+
"release-base-Linux"
45+
]
46+
}
47+
]
48+
}

cmake/CMakeWindowsPresets.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": 6,
3+
"include": [
4+
"CMakeGenericPresets.json"
5+
],
6+
"configurePresets": [
7+
{
8+
"name": "release",
9+
"description": "Windows preset for library developers",
10+
"generator": "Ninja Multi-Config",
11+
"binaryDir": "${sourceDir}/build",
12+
"inherits": [
13+
"root-config"
14+
],
15+
"cacheVariables": {
16+
"CMAKE_CXX_COMPILER": "cl"
17+
},
18+
"condition": {
19+
"type": "equals",
20+
"lhs": "${hostSystemName}",
21+
"rhs": "Windows"
22+
}
23+
},
24+
{
25+
"name": "debug",
26+
"description": "Windows preset for library developers",
27+
"inherits": [
28+
"release"
29+
]
30+
}
31+
]
32+
}

0 commit comments

Comments
 (0)