Skip to content

Commit 01d9d7b

Browse files
authored
Feature/prepare cmake v4.3 (#221)
* Prepare use of cmake v4.3 * Fix typos * Quickfix: PROJECT_NAME as prefix for cmake variable names
1 parent c20c56d commit 01d9d7b

12 files changed

Lines changed: 81 additions & 54 deletions

File tree

.clang-format

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Language: Json
44
IndentWidth: 2
55
UseTab: Never
66
---
7-
BasedOnStyle: LLVM
87
Language: JavaScript
98
IndentWidth: 4
109
UseTab: Never

.codespellignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ cancelled
22
copyable
33
pullrequest
44
snd
5+
dur
56
statics
67
Claus

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
rev: v2.4.1
1717
hooks:
1818
- id: codespell
19-
files: ^.*\.(cmake|cpp|hpp|txt|md|json|in|yaml|yml|py|toml)$
19+
files: ^.*\.(cmake|cpp|cppm|hpp|txt|md|mds|json|js|in|yaml|yml|py|toml)$
2020
args: ["--write", "--ignore-words", ".codespellignore" ]
2121

2222
# Clang-format for C++
@@ -27,7 +27,7 @@ repos:
2727
rev: v21.1.8
2828
hooks:
2929
- id: clang-format
30-
types_or: [c++, c, json]
30+
types_or: [c++, c, json, javascript]
3131
exclude: docs/TODO.json
3232

3333
# CMake linting and formatting
@@ -48,7 +48,7 @@ repos:
4848
# Config file: pyproject.toml
4949
# first Python sort imports
5050
- repo: https://github.com/pycqa/isort
51-
rev: 7.0.0
51+
rev: 8.0.0
5252
hooks:
5353
- id: isort
5454

CMakeLists.txt

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
# gersemi: on
55

6-
cmake_minimum_required(VERSION 3.30...4.2)
6+
cmake_minimum_required(VERSION 3.30...4.3)
77

88
include(./cmake/prelude.cmake)
99

1010
#===================================================
11-
project(beman.execution VERSION 0.2.0 LANGUAGES CXX)
11+
project(beman.execution VERSION 0.3.0 LANGUAGES CXX)
1212
#===================================================
1313

1414
# Modules opt in only on compilers that support it: msvc, g++-15 and clang-20+
1515
include(./cmake/cxx-modules-rules.cmake)
1616

17-
set(TARGET_NAME beman.execution_headers) # used in src, and docs
18-
set(TARGET_NAMESPACE beman) # TODO(CK): still used in docs, is this really needed?
19-
set(TARGET_PREFIX ${PROJECT_NAME}) # NOTE: used in src, and docs?
20-
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets) # NOTE: must be set, is important for installation! CK
17+
set(BEMAN_EXECUTION_TARGET_NAME beman.execution_headers) # used in src, and docs
18+
set(BEMAN_EXECUTION_TARGET_PREFIX ${PROJECT_NAME}) # NOTE: used in src, and docs?
2119

2220
#===============================================================================
2321
if(BEMAN_USE_MODULES)
@@ -29,31 +27,34 @@ if(BEMAN_USE_MODULES)
2927

3028
# CMake requires the language standard to be specified as compile feature
3129
# when a target provides C++23 modules and the target will be installed
32-
add_library(${TARGET_PREFIX} STATIC) # FIXME: only static yet! CK
33-
add_library(beman::execution ALIAS ${TARGET_PREFIX})
30+
add_library(${BEMAN_EXECUTION_TARGET_PREFIX} STATIC) # FIXME: only static yet! CK
31+
add_library(beman::execution ALIAS ${BEMAN_EXECUTION_TARGET_PREFIX})
3432
target_compile_features(
35-
${TARGET_PREFIX}
33+
${BEMAN_EXECUTION_TARGET_PREFIX}
3634
PUBLIC cxx_std_${CMAKE_CXX_STANDARD}
3735
)
3836

3937
# TODO(CK): the export header should be used!
4038
include(GenerateExportHeader)
4139
generate_export_header(
42-
${TARGET_PREFIX}
43-
BASE_NAME ${TARGET_PREFIX}
40+
${BEMAN_EXECUTION_TARGET_PREFIX}
41+
BASE_NAME ${BEMAN_EXECUTION_TARGET_PREFIX}
4442
EXPORT_FILE_NAME beman/execution/modules_export.hpp
4543
)
4644
target_sources(
47-
${TARGET_PREFIX}
45+
${BEMAN_EXECUTION_TARGET_PREFIX}
4846
PUBLIC
4947
FILE_SET HEADERS
5048
BASE_DIRS include ${CMAKE_CURRENT_BINARY_DIR}
5149
FILES
5250
${CMAKE_CURRENT_BINARY_DIR}/beman/execution/modules_export.hpp
5351
)
54-
target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_MODULES)
52+
target_compile_definitions(
53+
${BEMAN_EXECUTION_TARGET_PREFIX}
54+
PUBLIC BEMAN_HAS_MODULES
55+
)
5556
set_target_properties(
56-
${TARGET_PREFIX}
57+
${BEMAN_EXECUTION_TARGET_PREFIX}
5758
PROPERTIES
5859
VERSION ${PROJECT_VERSION}
5960
SOVERSION ${PROJECT_VERSION_MAJOR}
@@ -63,20 +64,29 @@ if(BEMAN_USE_MODULES)
6364
# FIXME: Quickfix only to prevent linker problems on windows dll? CK
6465
if(WIN32 AND BUILD_SHARED_LIBS)
6566
set_target_properties(
66-
${TARGET_PREFIX}
67+
${BEMAN_EXECUTION_TARGET_PREFIX}
6768
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON
6869
)
6970
endif()
7071

7172
find_package(Threads REQUIRED)
72-
target_link_libraries(${TARGET_PREFIX} PUBLIC Threads::Threads)
73+
target_link_libraries(
74+
${BEMAN_EXECUTION_TARGET_PREFIX}
75+
PUBLIC Threads::Threads
76+
)
7377
else()
7478
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
7579
endif()
7680

7781
if(BEMAN_USE_MODULES AND BEMAN_HAS_IMPORT_STD)
78-
target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_IMPORT_STD)
79-
set_target_properties(${TARGET_PREFIX} PROPERTIES CXX_MODULE_STD ON)
82+
target_compile_definitions(
83+
${BEMAN_EXECUTION_TARGET_PREFIX}
84+
PUBLIC BEMAN_HAS_IMPORT_STD
85+
)
86+
set_target_properties(
87+
${BEMAN_EXECUTION_TARGET_PREFIX}
88+
PROPERTIES CXX_MODULE_STD ON
89+
)
8090
elseif(BEMAN_USE_MODULES)
8191
message(WARNING "Missing or disabled support for CMAKE_CXX_MODULE_STD!")
8292
endif()
@@ -99,8 +109,7 @@ add_subdirectory(src/beman/execution)
99109
#===============================================================================
100110
# NOTE: this must be done before tests! CK
101111
include(./cmake/beman-install-library.cmake)
102-
beman_install_library(${TARGET_PREFIX} TARGETS ${TARGET_NAME} ${TARGET_PREFIX}
103-
# TODO: DEPENDENCIES [===[beman.inplace_vector 1.0.0]===] [===[beman.scope 0.0.1 EXACT]===] fmt
112+
beman_install_library(${BEMAN_EXECUTION_TARGET_PREFIX} TARGETS ${BEMAN_EXECUTION_TARGET_NAME} ${BEMAN_EXECUTION_TARGET_PREFIX}
104113
DEPENDENCIES Threads
105114
)
106115
#===============================================================================

CMakePresets.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"CMAKE_CXX_EXTENSIONS": true,
1414
"CMAKE_CXX_STANDARD_REQUIRED": true,
1515
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
16+
"CMAKE_INSTALL_MESSAGE": "LAZY",
1617
"CMAKE_SKIP_TEST_ALL_DEPENDENCY": false,
1718
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "infra/cmake/use-fetch-content.cmake"
1819
}
@@ -105,6 +106,7 @@
105106
"_debug-base"
106107
],
107108
"cacheVariables": {
109+
"BEMAN_USE_STD_MODULE": false,
108110
"BEMAN_USE_MODULES": false,
109111
"CMAKE_TOOLCHAIN_FILE": "infra/cmake/appleclang-toolchain.cmake"
110112
}
@@ -117,6 +119,7 @@
117119
"_release-base"
118120
],
119121
"cacheVariables": {
122+
"BEMAN_USE_STD_MODULE": false,
120123
"BEMAN_USE_MODULES": false,
121124
"CMAKE_TOOLCHAIN_FILE": "infra/cmake/appleclang-toolchain.cmake"
122125
}

cmake/Config.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# cmake/Config.cmake.in -*-makefile-*-
1+
# cmake/Config.cmake.in -*-cmake-*-
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
include(CMakeFindDependencyMacro)

cmake/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ include(./cmake/prelude.cmake)
162162
project(beman.execution VERSION 0.2.0 LANGUAGES CXX)
163163
include(./cmake/cxx-modules-rules.cmake)
164164
165-
set(TARGET_PREFIX ${PROJECT_NAME})
165+
set(BEMAN_EXECUTION_TARGET_PREFIX ${PROJECT_NAME})
166166
167167
#===============================================================================
168168
if(BEMAN_USE_MODULES)
@@ -171,32 +171,32 @@ if(BEMAN_USE_MODULES)
171171
172172
# CMake requires the language standard to be specified as compile feature
173173
# when a target provides C++23 modules and the target will be installed
174-
add_library(${TARGET_PREFIX} STATIC)
175-
add_library(beman::execution ALIAS ${TARGET_PREFIX})
174+
add_library(${BEMAN_EXECUTION_TARGET_PREFIX} STATIC)
175+
add_library(beman::execution ALIAS ${BEMAN_EXECUTION_TARGET_PREFIX})
176176
target_compile_features(
177-
${TARGET_PREFIX}
177+
${BEMAN_EXECUTION_TARGET_PREFIX}
178178
PUBLIC cxx_std_${CMAKE_CXX_STANDARD}
179179
)
180180
181181
include(GenerateExportHeader)
182182
generate_export_header(
183-
${TARGET_PREFIX}
184-
BASE_NAME ${TARGET_PREFIX}
183+
${BEMAN_EXECUTION_TARGET_PREFIX}
184+
BASE_NAME ${BEMAN_EXECUTION_TARGET_PREFIX}
185185
EXPORT_FILE_NAME beman/execution/modules_export.hpp
186186
)
187187
target_sources(
188-
${TARGET_PREFIX}
188+
${BEMAN_EXECUTION_TARGET_PREFIX}
189189
PUBLIC
190190
FILE_SET HEADERS
191191
BASE_DIRS include ${CMAKE_CURRENT_BINARY_DIR}
192192
FILES
193193
${CMAKE_CURRENT_BINARY_DIR}/beman/execution/modules_export.hpp
194194
)
195-
target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_MODULES)
195+
target_compile_definitions(${BEMAN_EXECUTION_TARGET_PREFIX} PUBLIC BEMAN_HAS_MODULES)
196196
endif()
197197
198198
if(BEMAN_USE_MODULES AND CMAKE_CXX_MODULE_STD)
199-
target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_IMPORT_STD)
199+
target_compile_definitions(${BEMAN_EXECUTION_TARGET_PREFIX} PUBLIC BEMAN_HAS_IMPORT_STD)
200200
else()
201201
message(WARNING "Missing support for CMAKE_CXX_MODULE_STD!")
202202
endif()
@@ -206,7 +206,7 @@ endif()
206206
207207
# NOTE: this must be done before tests! CK
208208
include(beman-install-library)
209-
beman_install_library(${PROJECT_NAME} TARGETS ${TARGET_PREFIX} beman.exemplar_headers #
209+
beman_install_library(${PROJECT_NAME} TARGETS ${BEMAN_EXECUTION_TARGET_PREFIX} beman.exemplar_headers #
210210
# TODO(add): DEPENDENCIES [===[beman.inplace_vector 1.0.0]===] [===[beman.scope 0.0.1 EXACT]===] fmt
211211
)
212212
```

cmake/prelude.cmake

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@ endif()
1717

1818
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
1919

20+
# ---------------------------------------------------------------------------
21+
# The CMAKE_EXPERIMENTAL_CXX_IMPORT_STD is not longer needed except for OSX
2022
# ---------------------------------------------------------------------------
2123
if(NOT BEMAN_USE_STD_MODULE OR CMAKE_VERSION VERSION_GREATER_EQUAL 4.3)
22-
return()
24+
if(NOT APPLE)
25+
return()
26+
endif()
2327
endif()
2428
# ---------------------------------------------------------------------------
2529

2630
# gersemi: off
2731
# ---------------------------------------------------------------------------
2832
# check if import std; is supported by CMAKE_CXX_COMPILER
2933
# ---------------------------------------------------------------------------
30-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2)
34+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2 AND CMAKE_VERSION VERSION_LESS 4.3)
3135
if(PROJECT_NAME)
3236
message(
3337
WARNING
@@ -39,10 +43,10 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.2)
3943
endif()
4044
# gersemi: on
4145

42-
# TODO(CK): Do we need this HACK for linux too?
43-
# if(NOT APPLE)
44-
# return()
45-
# endif()
46+
# TODO(CK): Do we need this HACK still for linux too?
47+
if(NOT APPLE)
48+
return()
49+
endif()
4650

4751
# FIXME: clang++ we still needs to export CXX=clang++
4852
if("$ENV{CXX}" STREQUAL "" AND CMAKE_CXX_COMPILER)
@@ -76,6 +80,8 @@ if(
7680
add_link_options(-L${LLVM_DIR}/lib/c++)
7781
include_directories(SYSTEM ${LLVM_DIR}/include)
7882

83+
# /usr/local/Cellar/llvm/21.1.8_1/lib/c++/libc++.modules.json
84+
# "/usr/local/Cellar/llvm/21.1.8_1/share/libc++/v1/std.cppm",
7985
set(CMAKE_CXX_STDLIB_MODULES_JSON
8086
${LLVM_DIR}/lib/c++/libc++.modules.json
8187
)

docs/code/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ set(EXAMPLES)
1010
# endif()
1111

1212
foreach(EXAMPLE ${EXAMPLES})
13-
set(EXAMPLE_TARGET ${TARGET_PREFIX}.tutorial.${EXAMPLE})
13+
set(EXAMPLE_TARGET ${BEMAN_EXECUTION_TARGET_PREFIX}.tutorial.${EXAMPLE})
1414
add_executable(${EXAMPLE_TARGET})
1515
target_sources(${EXAMPLE_TARGET} PRIVATE ${EXAMPLE}.cpp)
1616
target_link_libraries(
1717
${EXAMPLE_TARGET}
18-
PRIVATE ${TARGET_NAMESPACE}::${TARGET_NAME}
18+
PRIVATE beman::${BEMAN_EXECUTION_TARGET_NAME}
1919
)
2020
endforeach()

docs/tutorial.mds

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pipe notation.
204204
result of the algorithm is the value returned from this
205205
invocation (if any). If the invocation of <code>_fun_</code>
206206
throws, the algorithm completes with an error
207-
provding an `std::exception_ptr` to caught exception. If
207+
providing an `std::exception_ptr` to caught exception. If
208208
<code>_sender_</code> doesn't complete accordingly to the
209209
algorithm's name, the completion is forwarded.
210210
</details>

0 commit comments

Comments
 (0)