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 )
1212endif ()
13- set (CMAKE_CXX_STANDARD_REQUIRED OFF )
14- set (CMAKE_CXX_SCAN_FOR_MODULES 1)
1513
1614cmake_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 )
4846add_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
7281include (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
0 commit comments