diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2022-07-19 20:10:20 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2022-08-02 14:53:38 (GMT) |
commit | c49d5f137be2c068c5ca1359726fdca0b8c4f8f5 (patch) | |
tree | 1827498e0b2eb82f37112ddf49b8a334089d6931 | |
parent | 297e0f4dce189183ff07cc8a79de6ae72c81974b (diff) | |
download | CMake-c49d5f137be2c068c5ca1359726fdca0b8c4f8f5.zip CMake-c49d5f137be2c068c5ca1359726fdca0b8c4f8f5.tar.gz CMake-c49d5f137be2c068c5ca1359726fdca0b8c4f8f5.tar.bz2 |
RunCMake/CXXModules: add a "deep-chain" test
This tests that transitive usages are propogated properly across long
import chains between targets.
9 files changed, 116 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index ca1bc81..3f17c1f 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -131,6 +131,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF) run_cxx_module_test(generated) run_cxx_module_test(public-req-private) + run_cxx_module_test(deep-chain) endif () # Tests which use named modules in shared libraries. diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt b/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt new file mode 100644 index 0000000..5e4392a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMakeLists.txt:7 \(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. + +CMake Warning \(dev\): + C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is + experimental. It is meant only for compiler developers to try. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt new file mode 100644 index 0000000..515b240 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/CMakeLists.txt @@ -0,0 +1,66 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_deep_chain CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_library(a STATIC) +target_sources(a + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + a.cxx) +target_compile_features(a PUBLIC cxx_std_20) + +add_library(b STATIC) +target_sources(b + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + b.cxx) +target_compile_features(b PUBLIC cxx_std_20) +target_link_libraries(b PUBLIC a) + +add_library(c STATIC) +target_sources(c + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + c.cxx) +target_compile_features(c PUBLIC cxx_std_20) +target_link_libraries(c PUBLIC b) + +add_library(d STATIC) +target_sources(d + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + d.cxx) +target_compile_features(d PUBLIC cxx_std_20) +target_link_libraries(d PUBLIC c) + +add_library(e STATIC) +target_sources(e + PUBLIC + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + e.cxx) +target_compile_features(e PUBLIC cxx_std_20) +target_link_libraries(e PUBLIC d) + +add_executable(exe) +target_link_libraries(exe PRIVATE e) +target_sources(exe + PRIVATE + main.cxx) + +add_test(NAME exe COMMAND exe) diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/a.cxx b/Tests/RunCMake/CXXModules/examples/deep-chain/a.cxx new file mode 100644 index 0000000..9edaec9 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/a.cxx @@ -0,0 +1,6 @@ +export module a; + +export int a() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/b.cxx b/Tests/RunCMake/CXXModules/examples/deep-chain/b.cxx new file mode 100644 index 0000000..38ab0c2 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/b.cxx @@ -0,0 +1,7 @@ +export module b; +import a; + +export int b() +{ + return a(); +} diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/c.cxx b/Tests/RunCMake/CXXModules/examples/deep-chain/c.cxx new file mode 100644 index 0000000..580a458 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/c.cxx @@ -0,0 +1,7 @@ +export module c; +import b; + +export int c() +{ + return b(); +} diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/d.cxx b/Tests/RunCMake/CXXModules/examples/deep-chain/d.cxx new file mode 100644 index 0000000..78bc5ba --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/d.cxx @@ -0,0 +1,7 @@ +export module d; +import c; + +export int d() +{ + return c(); +} diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/e.cxx b/Tests/RunCMake/CXXModules/examples/deep-chain/e.cxx new file mode 100644 index 0000000..e019440 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/e.cxx @@ -0,0 +1,7 @@ +export module e; +import d; + +export int e() +{ + return d(); +} diff --git a/Tests/RunCMake/CXXModules/examples/deep-chain/main.cxx b/Tests/RunCMake/CXXModules/examples/deep-chain/main.cxx new file mode 100644 index 0000000..0b7c15d --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/deep-chain/main.cxx @@ -0,0 +1,6 @@ +import e; + +int main(int argc, char* argv[]) +{ + return e(); +} |