Skip to content

Commit 3572928

Browse files
committed
cleanup after review
1 parent 8882fa2 commit 3572928

File tree

2 files changed

+50
-41
lines changed

2 files changed

+50
-41
lines changed

CMakeLists.txt

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2-
if(NOT DEFINED CMAKE_CXX_STANDARD)
3-
set(CMAKE_CXX_STANDARD 20)
4-
endif()
52

6-
# TODO(CK): set(CMAKE_CXX_MODULE_STD 1)
7-
if(CMAKE_CXX_MODULE_STD)
8-
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
9-
"d0edc3af-4c50-42ea-a356-e2862fe7a444"
10-
)
11-
set(CMAKE_CXX_STANDARD 26)
3+
if(CMAKE_CXX_STANDARD STREQUAL 26)
4+
set(CMAKE_CXX_SCAN_FOR_MODULES 1)
5+
set(CMAKE_CXX_MODULE_STD 1)
6+
if(CMAKE_CXX_MODULE_STD)
7+
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
8+
"d0edc3af-4c50-42ea-a356-e2862fe7a444"
9+
)
10+
endif()
11+
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
1212
endif()
13-
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
14-
set(CMAKE_CXX_SCAN_FOR_MODULES 1)
1513

1614
cmake_minimum_required(VERSION 3.28...4.0)
1715

@@ -44,9 +42,8 @@ option(
4442
${PROJECT_IS_TOP_LEVEL}
4543
)
4644

47-
add_library(beman.scope)
45+
add_library(beman.scope INTERFACE)
4846
add_library(beman::scope ALIAS beman.scope)
49-
target_compile_features(beman.scope PRIVATE cxx_std_20)
5047

5148
# gersemi: off
5249

@@ -57,17 +54,29 @@ set_target_properties(
5754
EXPORT_NAME scope
5855
)
5956

60-
target_sources(
61-
beman.scope
62-
PUBLIC
63-
FILE_SET HEADERS
64-
BASE_DIRS include
65-
FILES include/beman/scope/scope.hpp
66-
PUBLIC
67-
FILE_SET CXX_MODULES
68-
BASE_DIRS include
69-
FILES include/beman/scope/beman.scope.cppm
70-
)
57+
if(CMAKE_CXX_SCAN_FOR_MODULES)
58+
target_compile_features(beman.scope PRIVATE cxx_std_23)
59+
target_sources(
60+
beman.scope
61+
PUBLIC
62+
FILE_SET HEADERS
63+
BASE_DIRS include
64+
FILES include/beman/scope/scope.hpp
65+
PUBLIC
66+
FILE_SET CXX_MODULES
67+
BASE_DIRS include
68+
FILES include/beman/scope/beman.scope.cppm
69+
)
70+
else()
71+
target_compile_features(beman.scope INTERFACE cxx_std_20)
72+
target_sources(
73+
beman.scope
74+
INTERFACE
75+
FILE_SET HEADERS
76+
BASE_DIRS include
77+
FILES include/beman/scope/scope.hpp
78+
)
79+
endif()
7180

7281
include(GNUInstallDirs)
7382

@@ -77,7 +86,6 @@ install(
7786
EXPORT beman.scope-targets
7887

7988
FILE_SET CXX_MODULES
80-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
8189
FILE_SET HEADERS
8290
)
8391

tests/CMakeLists.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ include(FetchContent)
55
FetchContent_Declare(
66
Catch2
77
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
8-
GIT_TAG v3.8.0
8+
GIT_TAG v3.8.1
99
SYSTEM
10-
# MAYBY: FIND_PACKAGE_ARGS 3.8.0
10+
# FIXME: FIND_PACKAGE_ARGS 3.8.1
1111
)
1212
FetchContent_MakeAvailable(Catch2)
1313

@@ -17,20 +17,21 @@ message("Tests to be built: ${ALL_TESTNAMES}")
1717

1818
include(Catch)
1919

20-
add_executable(test.module)
21-
target_sources(test.module PRIVATE module.test.cpp)
22-
# MAYBE: target_compile_features(test.module PRIVATE cxx_std_23)
23-
target_link_libraries(test.module PRIVATE beman::scope)
24-
25-
add_test(NAME test.module COMMAND test.module)
26-
27-
# XXX NO! target_compile_options(test.module PRIVATE "-fmodules")
28-
# target_link_libraries(
29-
# test.module
30-
# PUBLIC FILE_SET TYPE CXX_MODULES include/beman/scope/beman.scope.cppm
31-
# PRIVATE Catch2::Catch2WithMain beman::scope
32-
# )
33-
# catch_discover_tests(test.module)
20+
if(CMAKE_CXX_SCAN_FOR_MODULES)
21+
add_executable(test.module)
22+
target_sources(test.module PRIVATE module.test.cpp)
23+
target_compile_features(test.module PRIVATE cxx_std_23)
24+
target_link_libraries(test.module PRIVATE beman::scope)
25+
add_test(NAME test.module COMMAND test.module)
26+
27+
# XXX NO! target_compile_options(test.module PRIVATE "-fmodules")
28+
# target_link_libraries(
29+
# test.module
30+
# PUBLIC FILE_SET TYPE CXX_MODULES include/beman/scope/beman.scope.cppm
31+
# PRIVATE Catch2::Catch2WithMain beman::scope
32+
# )
33+
# catch_discover_tests(test.module)
34+
endif()
3435

3536
foreach(testname ${ALL_TESTNAMES})
3637
add_executable(test.${testname})

0 commit comments

Comments
 (0)