Tests/CXXModules: add a test using TARGET_OBJECTS
from modules
See: #25732
This commit is contained in:
parent
944f10d768
commit
4ddf0453d5
@ -220,6 +220,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
|||||||
unset(RunCMake_CXXModules_NO_TEST)
|
unset(RunCMake_CXXModules_NO_TEST)
|
||||||
run_cxx_module_test(same-src-name)
|
run_cxx_module_test(same-src-name)
|
||||||
run_cxx_module_test(scan_properties)
|
run_cxx_module_test(scan_properties)
|
||||||
|
run_cxx_module_test(target-objects)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Tests which require compile commands support.
|
# Tests which require compile commands support.
|
||||||
|
@ -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)
|
@ -0,0 +1,13 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C++" {
|
||||||
|
int f()
|
||||||
|
{
|
||||||
|
return from_import();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
int f();
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
return f();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user