summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-02-20 15:29:18 (GMT)
committerBrad King <brad.king@kitware.com>2024-02-20 15:29:18 (GMT)
commit583641ac92b83f91341e701c057ec5e6da8eb8fc (patch)
treebc31e9a5f295123ed19fa78102537e5f96db17be
parent00d908a01f2bd3ea7349757b0b8202e3239c7461 (diff)
parent8b6fc81fc3f48ff8a14e0af887ff5c5329c5fd26 (diff)
downloadCMake-583641ac92b83f91341e701c057ec5e6da8eb8fc.zip
CMake-583641ac92b83f91341e701c057ec5e6da8eb8fc.tar.gz
CMake-583641ac92b83f91341e701c057ec5e6da8eb8fc.tar.bz2
Merge topic 'cxxmodules-transitive-target-usage' into release-3.28
8b6fc81fc3 cmTarget: copy link libraries from the right properties d4a517f82a Tests/CXXModules: add a test with transitive targets Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !9265
-rw-r--r--Source/cmTarget.cxx2
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/CMakeLists.txt71
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/forward.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/importable.cxx28
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/include/include.h3
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/includes/includes.h3
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/no_modules.cxx3
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/private.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/subdir/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/test/CMakeLists.txt16
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/CMakeLists.txt80
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/forward.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/importable.cxx28
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/include/include.h3
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/includes/includes.h3
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/no_modules.cxx3
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/private.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/subdir/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/test/CMakeLists.txt16
-rw-r--r--Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CXXModules/examples/import-modules/use.cxx4
22 files changed, 308 insertions, 1 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index abbf29e..fd2d5d1 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1783,7 +1783,7 @@ void cmTarget::CopyImportedCxxModulesEntries(cmTarget const* tgt)
cmMakeRange(tgt->impl->ImportedCxxModulesCompileOptions.Entries));
this->impl->LinkLibraries.Entries.clear();
this->impl->LinkLibraries.CopyFromEntries(
- cmMakeRange(tgt->impl->LinkLibraries.Entries));
+ cmMakeRange(tgt->impl->ImportedCxxModulesLinkLibraries.Entries));
// Copy the C++ module fileset entries from `tgt`'s `INTERFACE` to this
// target's `PRIVATE`.
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index aaf289c..2f91d6a 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -262,6 +262,7 @@ if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(export-include-directories-build)
run_cxx_module_test(export-usage-build)
run_cxx_module_test(export-bmi-and-interface-build)
+ run_cxx_module_test(export-transitive-targets-build)
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
@@ -276,6 +277,9 @@ if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
set(test_suffix export-bmi-and-interface-build)
run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DWITH_BMIS=1)
+
+ set(test_suffix export-transitive-targets-build)
+ run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DTRANSITIVE_TARGETS=1)
endif ()
endif ()
@@ -293,6 +297,7 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(export-include-directories-install)
run_cxx_module_test(export-usage-install)
run_cxx_module_test(export-bmi-and-interface-install)
+ run_cxx_module_test(export-transitive-targets-install)
if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND
"bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION)
@@ -308,6 +313,9 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
set(test_suffix export-bmi-and-interface-install)
run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DWITH_BMIS=1)
+
+ set(test_suffix export-transitive-targets-install)
+ run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DTRANSITIVE_TARGETS=1)
set(RunCMake_CXXModules_INSTALL 1)
endif ()
endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/CMakeLists.txt
new file mode 100644
index 0000000..99ec585
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/CMakeLists.txt
@@ -0,0 +1,71 @@
+cmake_minimum_required(VERSION 3.24...3.28)
+project(cxx_modules_export_transitive_targets CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(usage_reqs INTERFACE
+ include/include.h
+ includes/includes.h)
+target_compile_definitions(usage_reqs
+ INTERFACE
+ FROM_USAGE_REQS)
+target_include_directories(usage_reqs
+ INTERFACE
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/includes>")
+
+add_library(export_transitive_targets STATIC)
+target_sources(export_transitive_targets
+ PRIVATE
+ forward.cxx
+ PRIVATE
+ FILE_SET modules_private TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ private.cxx
+ PUBLIC
+ FILE_SET modules TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx
+ subdir/importable.cxx
+ )
+target_compile_features(export_transitive_targets PUBLIC cxx_std_20)
+target_link_libraries(export_transitive_targets PRIVATE usage_reqs)
+
+add_library(no_modules STATIC no_modules.cxx)
+
+install(TARGETS usage_reqs export_transitive_targets no_modules
+ EXPORT CXXModules
+ FILE_SET modules DESTINATION "lib/cxx/miu")
+export(EXPORT CXXModules
+ NAMESPACE CXXModules::
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/export_transitive_targets-targets.cmake"
+ CXX_MODULES_DIRECTORY "export_transitive_targets-cxx-modules")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_transitive_targets-config.cmake"
+ "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_transitive_targets-targets.cmake\")
+set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
+")
+
+set(generator
+ -G "${CMAKE_GENERATOR}")
+if (CMAKE_GENERATOR_TOOLSET)
+ list(APPEND generator
+ -T "${CMAKE_GENERATOR_TOOLSET}")
+endif ()
+if (CMAKE_GENERATOR_PLATFORM)
+ list(APPEND generator
+ -A "${CMAKE_GENERATOR_PLATFORM}")
+endif ()
+
+add_test(NAME export_transitive_targets_build
+ COMMAND
+ "${CMAKE_COMMAND}"
+ "-Dexpected_source_dir=${CMAKE_CURRENT_SOURCE_DIR}"
+ "-Dexpected_binary_dir=${CMAKE_CURRENT_BINARY_DIR}"
+ "-Dexport_transitive_targets_DIR=${CMAKE_CURRENT_BINARY_DIR}"
+ ${generator}
+ -S "${CMAKE_CURRENT_SOURCE_DIR}/test"
+ -B "${CMAKE_CURRENT_BINARY_DIR}/test")
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/forward.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/forward.cxx
new file mode 100644
index 0000000..7f53271
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/forward.cxx
@@ -0,0 +1,6 @@
+import priv;
+
+int forwarding()
+{
+ return from_private();
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/importable.cxx
new file mode 100644
index 0000000..77210ef
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/importable.cxx
@@ -0,0 +1,28 @@
+module;
+
+#include "include/include.h"
+
+#ifndef include_h_included
+# error "include define not found"
+#endif
+
+#include "includes/includes.h"
+
+#ifndef includes_h_included
+# error "includes define not found"
+#endif
+
+#ifndef FROM_USAGE_REQS
+# error "missing `FROM_USAGE_REQS` define"
+#endif
+
+export module importable;
+
+extern "C++" {
+int forwarding();
+}
+
+export int from_import()
+{
+ return forwarding();
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/include/include.h b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/include/include.h
new file mode 100644
index 0000000..e3eee34
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/include/include.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define include_h_included
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/includes/includes.h b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/includes/includes.h
new file mode 100644
index 0000000..96bf33b
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/includes/includes.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define includes_h_included
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/no_modules.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/no_modules.cxx
new file mode 100644
index 0000000..eea854f
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/no_modules.cxx
@@ -0,0 +1,3 @@
+void no_modules()
+{
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/private.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/private.cxx
new file mode 100644
index 0000000..c5b719a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/private.cxx
@@ -0,0 +1,6 @@
+export module priv;
+
+export int from_private()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/subdir/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/subdir/importable.cxx
new file mode 100644
index 0000000..07d6af6
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/subdir/importable.cxx
@@ -0,0 +1,6 @@
+export module subdir_importable;
+
+export int from_subdir()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/test/CMakeLists.txt
new file mode 100644
index 0000000..8e70576
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-build/test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.28)
+project(cxx_modules_library NONE)
+
+find_package(export_transitive_targets REQUIRED)
+
+if (NOT TARGET CXXModules::export_transitive_targets)
+ message(FATAL_ERROR
+ "Missing imported target")
+endif ()
+
+get_property(transitive_targets TARGET CXXModules::export_transitive_targets
+ PROPERTY IMPORTED_CXX_MODULES_LINK_LIBRARIES)
+if (NOT transitive_targets STREQUAL "$<COMPILE_ONLY:CXXModules::usage_reqs>")
+ message(FATAL_ERROR
+ "Incorrect transitive link library in C++ module interface CXXModules::export_transitive_targets:\n ${transitive_targets}")
+endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/CMakeLists.txt
new file mode 100644
index 0000000..dd1eb01
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/CMakeLists.txt
@@ -0,0 +1,80 @@
+cmake_minimum_required(VERSION 3.24...3.28)
+project(cxx_modules_export_transitive_targets CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(usage_reqs INTERFACE
+ include/include.h
+ includes/includes.h)
+target_compile_definitions(usage_reqs
+ INTERFACE
+ FROM_USAGE_REQS)
+target_include_directories(usage_reqs
+ INTERFACE
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/includes>"
+ "$<INSTALL_INTERFACE:include>")
+
+add_library(export_transitive_targets STATIC)
+target_sources(export_transitive_targets
+ PRIVATE
+ forward.cxx
+ PRIVATE
+ FILE_SET modules_private TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ private.cxx
+ PUBLIC
+ FILE_SET modules TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx
+ subdir/importable.cxx
+ )
+target_compile_features(export_transitive_targets PUBLIC cxx_std_20)
+target_link_libraries(export_transitive_targets PRIVATE usage_reqs)
+
+add_library(no_modules STATIC no_modules.cxx)
+
+install(TARGETS usage_reqs export_transitive_targets no_modules
+ EXPORT CXXModules
+ FILE_SET modules DESTINATION "lib/cxx/miu"
+ INCLUDES DESTINATION "elsewhere")
+install(DIRECTORY include
+ DESTINATION "include")
+install(DIRECTORY includes
+ DESTINATION "elsewhere")
+install(EXPORT CXXModules
+ NAMESPACE CXXModules::
+ DESTINATION "lib/cmake/export_transitive_targets"
+ FILE "export_transitive_targets-targets.cmake"
+ CXX_MODULES_DIRECTORY "export_transitive_targets-cxx-modules")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_transitive_targets-config.cmake"
+ "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_transitive_targets-targets.cmake\")
+set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1)
+")
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_transitive_targets-config.cmake"
+ DESTINATION "lib/cmake/export_transitive_targets")
+
+set(generator
+ -G "${CMAKE_GENERATOR}")
+if (CMAKE_GENERATOR_TOOLSET)
+ list(APPEND generator
+ -T "${CMAKE_GENERATOR_TOOLSET}")
+endif ()
+if (CMAKE_GENERATOR_PLATFORM)
+ list(APPEND generator
+ -A "${CMAKE_GENERATOR_PLATFORM}")
+endif ()
+
+add_test(NAME export_transitive_targets_build
+ COMMAND
+ "${CMAKE_COMMAND}"
+ "-Dexpected_source_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu"
+ "-Dexpected_binary_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/bmi"
+ "-Dexport_transitive_targets_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_transitive_targets"
+ ${generator}
+ -S "${CMAKE_CURRENT_SOURCE_DIR}/test"
+ -B "${CMAKE_CURRENT_BINARY_DIR}/test")
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/forward.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/forward.cxx
new file mode 100644
index 0000000..7f53271
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/forward.cxx
@@ -0,0 +1,6 @@
+import priv;
+
+int forwarding()
+{
+ return from_private();
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/importable.cxx
new file mode 100644
index 0000000..77210ef
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/importable.cxx
@@ -0,0 +1,28 @@
+module;
+
+#include "include/include.h"
+
+#ifndef include_h_included
+# error "include define not found"
+#endif
+
+#include "includes/includes.h"
+
+#ifndef includes_h_included
+# error "includes define not found"
+#endif
+
+#ifndef FROM_USAGE_REQS
+# error "missing `FROM_USAGE_REQS` define"
+#endif
+
+export module importable;
+
+extern "C++" {
+int forwarding();
+}
+
+export int from_import()
+{
+ return forwarding();
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/include/include.h b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/include/include.h
new file mode 100644
index 0000000..e3eee34
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/include/include.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define include_h_included
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/includes/includes.h b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/includes/includes.h
new file mode 100644
index 0000000..96bf33b
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/includes/includes.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define includes_h_included
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/no_modules.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/no_modules.cxx
new file mode 100644
index 0000000..eea854f
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/no_modules.cxx
@@ -0,0 +1,3 @@
+void no_modules()
+{
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/private.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/private.cxx
new file mode 100644
index 0000000..c5b719a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/private.cxx
@@ -0,0 +1,6 @@
+export module priv;
+
+export int from_private()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/subdir/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/subdir/importable.cxx
new file mode 100644
index 0000000..07d6af6
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/subdir/importable.cxx
@@ -0,0 +1,6 @@
+export module subdir_importable;
+
+export int from_subdir()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/test/CMakeLists.txt
new file mode 100644
index 0000000..8e70576
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/export-transitive-targets-install/test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.28)
+project(cxx_modules_library NONE)
+
+find_package(export_transitive_targets REQUIRED)
+
+if (NOT TARGET CXXModules::export_transitive_targets)
+ message(FATAL_ERROR
+ "Missing imported target")
+endif ()
+
+get_property(transitive_targets TARGET CXXModules::export_transitive_targets
+ PROPERTY IMPORTED_CXX_MODULES_LINK_LIBRARIES)
+if (NOT transitive_targets STREQUAL "$<COMPILE_ONLY:CXXModules::usage_reqs>")
+ message(FATAL_ERROR
+ "Incorrect transitive link library in C++ module interface CXXModules::export_transitive_targets:\n ${transitive_targets}")
+endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt
index 16bc6d8..0b125ba 100644
--- a/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt
+++ b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt
@@ -11,6 +11,8 @@ elseif (INCLUDE_PROPERTIES)
set(package_name "export_include_directories")
elseif (FROM_NINJA)
set(package_name "export_from_ninja")
+elseif (TRANSITIVE_TARGETS)
+ set(package_name "export_transitive_targets")
else ()
set(package_name "export_interfaces")
endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx b/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx
index 2da1913..a012f38 100644
--- a/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx
+++ b/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx
@@ -4,6 +4,10 @@
# endif
#endif
+#ifdef FROM_USAGE_REQS
+# error "compile definitions leaked from private module requirements"
+#endif
+
import importable;
int main(int argc, char* argv[])