diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2024-05-02 02:09:43 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2024-05-02 02:09:43 (GMT) |
commit | 1fba6d32333f6755760a79f44d26f453b3c0e6a0 (patch) | |
tree | fa5bcd275c0f4e1b175c58eee44d9a38812c74ec | |
parent | 9fd37ca65e59d61ea04ab93c32c189701030f19d (diff) | |
parent | ec35251510ac92c48a2763d8b063cae40fe1f237 (diff) | |
download | CMake-1fba6d32333f6755760a79f44d26f453b3c0e6a0.zip CMake-1fba6d32333f6755760a79f44d26f453b3c0e6a0.tar.gz CMake-1fba6d32333f6755760a79f44d26f453b3c0e6a0.tar.bz2 |
Merge branch 'cxxmodules-build-export-different-directory-3.28' into cxxmodules-build-export-different-directory
* cxxmodules-build-export-different-directory-3.28:
cmDyndepCollation: look at all `export(TARGETS)` calls
11 files changed, 153 insertions, 2 deletions
diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx index e7ec7ef..bfe3a75 100644 --- a/Source/cmDyndepCollation.cxx +++ b/Source/cmDyndepCollation.cxx @@ -243,8 +243,10 @@ Json::Value CollationInformationExports(cmGeneratorTarget const* gt) } } - auto const& all_build_exports = gt->Makefile->GetExportBuildFileGenerators(); - for (auto const& exp : all_build_exports) { + auto const& all_build_exports = + gt->GetGlobalGenerator()->GetBuildExportSets(); + for (auto const& exp_entry : all_build_exports) { + auto const* exp = exp_entry.second; std::vector<cmExportBuildFileGenerator::TargetExport> targets; exp->GetTargets(targets); diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index 15805ec..23c32c0 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -265,6 +265,7 @@ if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(export-include-directories-old-cmake-build) run_cxx_module_test(export-usage-build) run_cxx_module_test(export-bmi-and-interface-build) + run_cxx_module_test(export-command-sepdir-build) run_cxx_module_test(export-transitive-targets-build) run_cxx_module_test(export-transitive-modules1-build) run_cxx_module_test(export-transitive-modules-build export-transitive-modules-build "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-transitive-modules1-build-build" ) @@ -284,6 +285,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-command-sepdir-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DEXPORT_COMMAND_SEPDIR=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) @@ -310,6 +314,7 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(export-include-directories-old-cmake-install) run_cxx_module_test(export-usage-install) run_cxx_module_test(export-bmi-and-interface-install) + run_cxx_module_test(export-command-sepdir-install) run_cxx_module_test(export-transitive-targets-install) run_cxx_module_test(export-transitive-modules1-install) run_cxx_module_test(export-transitive-modules-install export-transitive-modules-install "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/export-transitive-modules1-install-install" ) @@ -330,6 +335,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-command-sepdir-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DEXPORT_COMMAND_SEPDIR=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) diff --git a/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/CMakeLists.txt new file mode 100644 index 0000000..4f3fcf8 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.24...3.28) +project(cxx_modules_export_sepdir CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_subdirectory(subdir) + +install(TARGETS export_sepdir + EXPORT CXXModules + FILE_SET modules DESTINATION "lib/cxx/miu") +export(EXPORT CXXModules + NAMESPACE CXXModules:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/export_sepdir-targets.cmake") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_sepdir-config.cmake" + "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_sepdir-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_sepdir_build + COMMAND + "${CMAKE_COMMAND}" + "-Dexpected_dir=${CMAKE_CURRENT_SOURCE_DIR}" + "-Dexport_sepdir_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-command-sepdir-build/subdir/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/subdir/CMakeLists.txt new file mode 100644 index 0000000..cd571f6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/subdir/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(export_sepdir STATIC) +target_sources(export_sepdir + PUBLIC + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(export_sepdir PUBLIC cxx_std_20) diff --git a/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/subdir/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/subdir/importable.cxx new file mode 100644 index 0000000..607680a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/subdir/importable.cxx @@ -0,0 +1,6 @@ +export module importable; + +export int from_import() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/test/CMakeLists.txt new file mode 100644 index 0000000..d393271 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-build/test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.24...3.28) +project(cxx_modules_library NONE) + +find_package(export_sepdir REQUIRED) + +if (NOT TARGET CXXModules::export_sepdir) + message(FATAL_ERROR + "Missing imported target") +endif () + +get_property(modules TARGET CXXModules::export_sepdir + PROPERTY "IMPORTED_CXX_MODULES_NOCONFIG") +if (modules STREQUAL "") + message(SEND_ERROR + "Expected non-empty property value for IMPORTED_CXX_MODULES_NOCONFIG") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/CMakeLists.txt new file mode 100644 index 0000000..de21a2e --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.24...3.28) +project(cxx_modules_export_sepdir CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_subdirectory(subdir) + +install(TARGETS export_sepdir + EXPORT CXXModules + FILE_SET modules DESTINATION "lib/cxx/miu") +install(EXPORT CXXModules + NAMESPACE CXXModules:: + DESTINATION "lib/cmake/export_sepdir" + FILE "export_sepdir-targets.cmake") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/export_sepdir-config.cmake" + "include(\"\${CMAKE_CURRENT_LIST_DIR}/export_sepdir-targets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND 1) +") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/export_sepdir-config.cmake" + DESTINATION "lib/cmake/export_sepdir") + +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_sepdir_build + COMMAND + "${CMAKE_COMMAND}" + "-Dexpected_dir=${CMAKE_INSTALL_PREFIX}/lib/cxx/miu" + "-Dexport_sepdir_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/export_sepdir" + ${generator} + -S "${CMAKE_CURRENT_SOURCE_DIR}/test" + -B "${CMAKE_CURRENT_BINARY_DIR}/test") diff --git a/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/subdir/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/subdir/CMakeLists.txt new file mode 100644 index 0000000..cd571f6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/subdir/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(export_sepdir STATIC) +target_sources(export_sepdir + PUBLIC + FILE_SET modules TYPE CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(export_sepdir PUBLIC cxx_std_20) diff --git a/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/subdir/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/subdir/importable.cxx new file mode 100644 index 0000000..607680a --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/subdir/importable.cxx @@ -0,0 +1,6 @@ +export module importable; + +export int from_import() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/test/CMakeLists.txt new file mode 100644 index 0000000..d393271 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/export-command-sepdir-install/test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.24...3.28) +project(cxx_modules_library NONE) + +find_package(export_sepdir REQUIRED) + +if (NOT TARGET CXXModules::export_sepdir) + message(FATAL_ERROR + "Missing imported target") +endif () + +get_property(modules TARGET CXXModules::export_sepdir + PROPERTY "IMPORTED_CXX_MODULES_NOCONFIG") +if (modules STREQUAL "") + message(SEND_ERROR + "Expected non-empty property value for IMPORTED_CXX_MODULES_NOCONFIG") +endif () diff --git a/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt index 494b91a..6796660 100644 --- a/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt @@ -7,6 +7,8 @@ if (NO_PROPERTIES) set(package_name "export_interfaces_no_properties") elseif (WITH_BMIS) set(package_name "export_bmi_and_interfaces") +elseif (EXPORT_COMMAND_SEPDIR) + set(package_name "export_sepdir") elseif (INCLUDE_PROPERTIES) set(package_name "export_include_directories") elseif (FROM_NINJA) |