Skip to content

Commit 1e3b907

Browse files
committed
Prepare use of CMAKE_CXX_MODULE_STD
1 parent 5f1d499 commit 1e3b907

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
# TODO(CK): set(CMAKE_CXX_MODULE_STD 1)
3+
if(CMAKE_CXX_MODULE_STD)
4+
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD
5+
"d0edc3af-4c50-42ea-a356-e2862fe7a444"
6+
)
7+
set(CMAKE_CXX_STANDARD 26)
8+
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
9+
endif()
210

3-
cmake_minimum_required(VERSION 3.25)
11+
cmake_minimum_required(VERSION 3.25...4.0)
412

513
project(
614
beman.scope
@@ -33,6 +41,7 @@ option(
3341

3442
add_library(beman.scope)
3543
add_library(beman::scope ALIAS beman.scope)
44+
target_compile_features(beman.scope PRIVATE cxx_std_23)
3645

3746
# gersemi: off
3847

tests/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ FetchContent_Declare(
66
Catch2
77
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
88
GIT_TAG v3.8.0
9+
SYSTEM
10+
# MABY: FIND_PACKAGE_ARGS 3.8.0
911
)
1012
FetchContent_MakeAvailable(Catch2)
1113

@@ -17,8 +19,11 @@ include(Catch)
1719

1820
add_executable(test.module)
1921
target_sources(test.module PRIVATE module.test.cpp)
20-
target_compile_features(test.module PRIVATE cxx_std_20)
21-
target_compile_options(test.module PRIVATE "-fmodules")
22+
target_compile_features(test.module PRIVATE cxx_std_23)
23+
add_test(NAME test.module COMMAND test.module)
24+
target_link_libraries(test.module PRIVATE beman::scope)
25+
26+
# XXX target_compile_options(test.module PRIVATE "-fmodules")
2227
# target_link_libraries(
2328
# test.module
2429
# PUBLIC FILE_SET TYPE CXX_MODULES include/beman/scope/beman.scope.cppm

tests/module.test.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22

3+
// TODO(CK): import std;
4+
35
import beman.scope;
46
// #include <stdexcept>
57
// #include <string>
8+
// FIXME: #include <print>
69
#include <cassert>
710

811
// #define CATCH_CONFIG_MAIN
@@ -13,15 +16,16 @@ import beman.scope;
1316
// noisy_resource() { std::print( "construct noisy\n" ); }
1417
// ~noisy_resource() { std::print( "destroy noisy\n" ); }
1518
// };
19+
// clang-format on
1620

17-
//TEST_CASE("module-test", "[scope_module_test]") {
18-
int main()
19-
{
21+
// TEST_CASE("module-test", "[scope_module_test]") {
22+
int main() {
2023
bool exit_ran, success_ran, fail_ran = false;
2124
{
22-
beman::scope::scope_exit _([&exit_ran] { exit_ran = true; });
25+
beman::scope::scope_exit _([&exit_ran] { exit_ran = true; });
2326
beman::scope::scope_success _([&success_ran] { success_ran = true; });
24-
beman::scope::scope_fail _([&fail_ran] { fail_ran = true; });
27+
beman::scope::scope_fail _([&fail_ran] { fail_ran = true; });
28+
// FIXME:
2529
// auto resource_ptr = beman::scope::unique_resource(new noisy_resource(),
2630
// // Cleanup function
2731
// [](noisy_resource* ptr) { delete ptr; });
@@ -30,5 +34,4 @@ int main()
3034
assert(exit_ran == true);
3135
assert(success_ran == true);
3236
assert(fail_ran == false);
33-
34-
}
37+
}

0 commit comments

Comments
 (0)