Tests/CXXModules: add a test using TARGET_OBJECTS from modules

See: #25732
This commit is contained in:
Ben Boeckel 2024-03-06 01:13:01 -05:00
parent 944f10d768
commit 4ddf0453d5
4 changed files with 42 additions and 0 deletions

View File

@ -220,6 +220,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
unset(RunCMake_CXXModules_NO_TEST)
run_cxx_module_test(same-src-name)
run_cxx_module_test(scan_properties)
run_cxx_module_test(target-objects)
endif ()
# Tests which require compile commands support.

View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.28)
project(cxx_modules_target_objects CXX)
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
add_library(target_objects)
target_sources(target_objects
PRIVATE
FILE_SET CXX_MODULES
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
importable.cxx)
target_compile_features(target_objects PRIVATE cxx_std_20)
add_executable(main)
target_sources(main
PRIVATE
main.cxx
"$<TARGET_OBJECTS:target_objects>")
add_test(NAME main COMMAND main)

View File

@ -0,0 +1,13 @@
export module importable;
export int from_import()
{
return 0;
}
extern "C++" {
int f()
{
return from_import();
}
}

View File

@ -0,0 +1,6 @@
int f();
int main(int argc, char* argv[])
{
return f();
}