File tree Expand file tree Collapse file tree 2 files changed +40
-21
lines changed
Expand file tree Collapse file tree 2 files changed +40
-21
lines changed Original file line number Diff line number Diff line change @@ -31,30 +31,54 @@ option(
3131 ${PROJECT_IS_TOP_LEVEL}
3232)
3333
34- add_library (beman.scope)
35- add_library (beman::scope ALIAS beman.scope)
36-
3734# gersemi: off
3835
36+ message (
37+ "Compiler is: ${CMAKE_CXX_COMPILER_ID} version: ${CMAKE_CXX_COMPILER_VERSION} "
38+ )
39+
40+ # Modules opt in only on compilers that support g++-15 and clang-20
41+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20)
42+ set (CMAKE_CXX_SCAN_FOR_MODULES 1)
43+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
44+ set (CMAKE_CXX_SCAN_FOR_MODULES 1)
45+ endif ()
46+
47+ if (CMAKE_CXX_SCAN_FOR_MODULES)
48+ add_library (beman.scope)
49+ # target_compile_features(beman.scope PRIVATE cxx_std_23)
50+ target_sources (
51+ beman.scope
52+ PUBLIC
53+ FILE_SET HEADERS
54+ BASE_DIRS include
55+ FILES include /beman/scope/scope.hpp
56+ PUBLIC
57+ FILE_SET CXX_MODULES
58+ BASE_DIRS include
59+ FILES include /beman/scope/beman.scope.cppm
60+ )
61+ else ()
62+ add_library (beman.scope INTERFACE )
63+ # target_compile_features(beman.scope INTERFACE cxx_std_20)
64+ target_sources (
65+ beman.scope
66+ INTERFACE
67+ FILE_SET HEADERS
68+ BASE_DIRS include
69+ FILES include /beman/scope/scope.hpp
70+ )
71+ endif ()
72+
73+ add_library (beman::scope ALIAS beman.scope)
74+
3975set_target_properties (
4076 beman.scope
4177 PROPERTIES
4278 VERIFY_INTERFACE_HEADER_SETS ON
4379 EXPORT_NAME scope
4480)
4581
46- target_sources (
47- beman.scope
48- PUBLIC
49- FILE_SET HEADERS
50- BASE_DIRS include
51- FILES include /beman/scope/scope.hpp
52- PUBLIC
53- FILE_SET CXX_MODULES
54- BASE_DIRS include
55- FILES include /beman/scope/beman.scope.cppm
56- )
57-
5882include (GNUInstallDirs)
5983
6084install (
Original file line number Diff line number Diff line change @@ -9,14 +9,9 @@ FetchContent_Declare(
99)
1010FetchContent_MakeAvailable(Catch2)
1111
12- message (
13- "Compiler is: ${CMAKE_CXX_COMPILER_ID} version: ${CMAKE_CXX_COMPILER_VERSION} "
14- )
1512
1613# module tests will only compile with gcc15 or clang20 and above
17- if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20)
18- set (ALL_TESTNAMES scope_success scope_exit scope_fail unique_resource module)
19- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
14+ if (CMAKE_CXX_SCAN_FOR_MODULES)
2015 set (ALL_TESTNAMES scope_success scope_exit scope_fail unique_resource module)
2116else ()
2217 set (ALL_TESTNAMES scope_success scope_exit scope_fail unique_resource)
You can’t perform that action at this time.
0 commit comments