Tests/CXXModules: add test case for import std support

This commit is contained in:
Ben Boeckel
2024-02-24 17:30:41 -05:00
parent 3273b18972
commit bf0b457461
3 changed files with 28 additions and 0 deletions

View File

@@ -175,6 +175,7 @@ endfunction ()
# - `partitions`: module partitions are supported
# - `internal_partitions`: internal module partitions are supported
# - `bmionly`: the compiler supports BMI-only builds
# - `import_std23`: the compiler supports `import std` for C++23
#
# Generator-based:
# - `compile_commands`: the generator supports `compile_commands.json`
@@ -221,6 +222,11 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(same-src-name)
run_cxx_module_test(scan_properties)
run_cxx_module_test(target-objects)
if ("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES AND
"import_std23" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(import-std)
endif ()
endif ()
# Tests which require compile commands support.

View File

@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.29)
project(cxx_modules_import_std CXX)
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
set(CMAKE_CXX_MODULE_STD 1)
add_executable(main
main.cxx)
target_compile_features(main PRIVATE cxx_std_23)
add_test(NAME main COMMAND main)

View File

@@ -0,0 +1,10 @@
import std;
int main(int argc, char* argv[])
{
if (argc > 0 && argv[0]) {
std::string argv0 = argv[0];
std::cout << "program: " << argv0 << std::endl;
}
return 0;
}