Skip to content

Commit d3796c9

Browse files
authored
Merge pull request #57 from ClausKlein/feature/prepare-cmake-workflow-presets
Fix cmake config pkg export
2 parents b33f7c6 + 1110f5e commit d3796c9

File tree

8 files changed

+354
-294
lines changed

8 files changed

+354
-294
lines changed

.cmake-format

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
format:
2+
line_width: 119
3+
tab_size: 2
4+
max_subgroups_hwrap: 4
5+
max_rows_cmdline: 8
6+
separate_ctrl_name_with_space: false
7+
separate_fn_name_with_space: false
8+
dangle_parens: true
9+
dangle_align: prefix
10+
line_ending: unix
11+
keyword_case: upper
12+
always_wrap:
13+
- file
14+
- install
15+
- write_basic_package_version_file
16+
17+
markup:
18+
enable_markup: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ build
3535
mkerr
3636
olderr
3737
.DS_store
38+
.vs
3839
.vscode
3940
stagedir

CMakeLists.txt

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66
cmake_minimum_required(VERSION 3.25...3.31)
77

88
project(beman_execution26 VERSION 0.0.1 LANGUAGES CXX)
9-
set(TARGET_NAME execution26)
10-
set(TARGET_PREFIX beman.${TARGET_NAME})
11-
set(TARGET_LIBRARY beman_${TARGET_NAME})
12-
set(TARGET_ALIAS beman::${TARGET_NAME})
13-
set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
149

15-
set(CMAKE_CXX_STANDARD 26)
10+
set(TARGET_NAME execution26)
11+
set(TARGET_NAMESPACE beman) # FIXME: not used in install(EXPORT ...) CK?
12+
set(TARGET_PREFIX ${TARGET_NAMESPACE}.${TARGET_NAME})
13+
set(TARGET_LIBRARY ${PROJECT_NAME})
14+
set(TARGET_ALIAS ${TARGET_LIBRARY}::${TARGET_LIBRARY})
15+
set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config)
16+
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets)
1617

1718
include(GNUInstallDirs)
18-
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake)
19+
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
20+
21+
if(NOT DEFINED CMAKE_CXX_STANDARD)
22+
set(CMAKE_CXX_STANDARD 23)
23+
endif()
24+
25+
if(NOT DEFINED CMAKE_PREFIX_PATH)
26+
set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
27+
endif()
1928

2029
add_subdirectory(src/beman/execution26)
2130

@@ -29,16 +38,18 @@ endif()
2938
include(CMakePackageConfigHelpers)
3039

3140
write_basic_package_version_file(
32-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
33-
VERSION ${PROJECT_VERSION}
34-
COMPATIBILITY AnyNewerVersion)
41+
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake
42+
VERSION ${CMAKE_PROJECT_VERSION}
43+
COMPATIBILITY AnyNewerVersion
44+
)
3545

3646
configure_package_config_file(
37-
"cmake/Config.cmake.in"
38-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
39-
INSTALL_DESTINATION ${INSTALL_CONFIGDIR})
47+
"cmake/Config.cmake.in" ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake
48+
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
49+
)
4050

4151
install(
42-
FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
43-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
44-
DESTINATION ${INSTALL_CONFIGDIR})
52+
FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}.cmake
53+
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_PACKAGE_NAME}-version.cmake
54+
DESTINATION ${INSTALL_CONFIGDIR}
55+
)

CMakePresets.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": 6,
33
"configurePresets": [
44
{
5-
"name": "_root-config",
5+
"name": "root-config",
66
"hidden": true,
77
"generator": "Ninja",
88
"binaryDir": "${sourceDir}/build/${presetName}",
@@ -19,35 +19,45 @@
1919
}
2020
},
2121
{
22-
"name": "_debug-base",
22+
"name": "debug-base-unix",
2323
"hidden": true,
2424
"cacheVariables": {
2525
"CMAKE_BUILD_TYPE": "Debug",
2626
"CMAKE_CXX_FLAGS": "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined"
27+
},
28+
"condition": {
29+
"type": "notEquals",
30+
"lhs": "${hostSystemName}",
31+
"rhs": "Windows"
2732
}
2833
},
2934
{
30-
"name": "_release-base",
35+
"name": "release-base-unix",
3136
"hidden": true,
3237
"cacheVariables": {
3338
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
3439
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Wno-shadow -Wconversion -Wsign-conversion -Wcast-align -Wcast-qual -Woverloaded-virtual -Wformat=2 -Wno-error"
40+
},
41+
"condition": {
42+
"type": "notEquals",
43+
"lhs": "${hostSystemName}",
44+
"rhs": "Windows"
3545
}
3646
},
3747
{
3848
"name": "debug",
3949
"displayName": "Debug Build",
4050
"inherits": [
41-
"_root-config",
42-
"_debug-base"
51+
"root-config",
52+
"debug-base-unix"
4353
]
4454
},
4555
{
4656
"name": "release",
4757
"displayName": "Release Build",
4858
"inherits": [
49-
"_root-config",
50-
"_release-base"
59+
"root-config",
60+
"release-base-unix"
5161
]
5262
}
5363
],
@@ -72,7 +82,7 @@
7282
],
7383
"testPresets": [
7484
{
75-
"name": "_test_base",
85+
"name": "test_base",
7686
"hidden": true,
7787
"output": {
7888
"outputOnFailure": true
@@ -84,12 +94,12 @@
8494
},
8595
{
8696
"name": "debug",
87-
"inherits": "_test_base",
97+
"inherits": "test_base",
8898
"configurePreset": "debug"
8999
},
90100
{
91101
"name": "release",
92-
"inherits": "_test_base",
102+
"inherits": "test_base",
93103
"configurePreset": "release"
94104
}
95105
],

cmake/Config.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
@PACKAGE_INIT@
55

66
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
7-
check_required_components("@PROJECT_NAME@")
7+
check_required_components("@TARGET_LIBRARY@")

examples/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
# cmake-format: on
55

6-
set(EXAMPLES
7-
when_all-cancel
8-
stop_token
9-
stopping
10-
allocator
11-
)
6+
list(APPEND EXAMPLES when_all-cancel stop_token stopping allocator)
127

138
foreach(EXAMPLE ${EXAMPLES})
149
set(EXAMPLE_TARGET ${TARGET_PREFIX}.examples.${EXAMPLE})

0 commit comments

Comments
 (0)