mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 13:20:47 -06:00
Tests/RunCMake/CXXModules: add a test for issue #25112
Add a test case for C++ `OBJECT` libraries providing modules to consumers.
This commit is contained in:
@@ -142,6 +142,7 @@ string(REPLACE "," ";" CMake_TEST_MODULE_COMPILATION "${CMake_TEST_MODULE_COMPIL
|
|||||||
if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
|
||||||
run_cxx_module_test(simple)
|
run_cxx_module_test(simple)
|
||||||
run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
|
run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
|
||||||
|
run_cxx_module_test(object-library)
|
||||||
run_cxx_module_test(generated)
|
run_cxx_module_test(generated)
|
||||||
run_cxx_module_test(deep-chain)
|
run_cxx_module_test(deep-chain)
|
||||||
run_cxx_module_test(duplicate)
|
run_cxx_module_test(duplicate)
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
CMake Warning \(dev\) at CMakeLists.txt:[0-9]* \(target_sources\):
|
||||||
|
CMake's C\+\+ module support is experimental. It is meant only for
|
||||||
|
experimentation and feedback to CMake developers.
|
||||||
|
This warning is for project developers. Use -Wno-dev to suppress it.
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
project(cxx_modules_objlib CXX)
|
||||||
|
|
||||||
|
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
|
||||||
|
|
||||||
|
add_library(objlib OBJECT)
|
||||||
|
target_sources(objlib
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET CXX_MODULES
|
||||||
|
BASE_DIRS
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
FILES
|
||||||
|
importable.cxx)
|
||||||
|
target_compile_features(objlib PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
add_executable(objmain)
|
||||||
|
target_sources(objmain
|
||||||
|
PRIVATE
|
||||||
|
main.cxx)
|
||||||
|
target_link_libraries(objmain PRIVATE objlib)
|
||||||
|
|
||||||
|
add_test(NAME objmain COMMAND objmain)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export module importable;
|
||||||
|
|
||||||
|
export int from_import()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import importable;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
return from_import();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user