diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx index 24e43d12c0..14f5e4cf76 100644 --- a/Source/cmDyndepCollation.cxx +++ b/Source/cmDyndepCollation.cxx @@ -32,6 +32,7 @@ #include "cmInstallFileSetGenerator.h" #include "cmInstallGenerator.h" #include "cmListFileCache.h" +#include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmOutputConverter.h" @@ -109,12 +110,14 @@ TdiSourceInfo CollationInformationSources(cmGeneratorTarget const* gt, auto files_per_dirs = file_set->GetFiles(context, gt); Json::Value fs_dest = Json::nullValue; - for (auto const& ig : gt->Makefile->GetInstallGenerators()) { - if (auto const* fsg = - dynamic_cast(ig.get())) { - if (fsg->GetTarget() == gt && fsg->GetFileSet() == file_set) { - fs_dest = fsg->GetDestination(config); - continue; + // The install rule may be in a different directory than the target. + for (auto const& lg : gt->GetGlobalGenerator()->GetLocalGenerators()) { + for (auto const& ig : lg->GetMakefile()->GetInstallGenerators()) { + if (auto const* fsg = + dynamic_cast(ig.get())) { + if (fsg->GetTarget() == gt && fsg->GetFileSet() == file_set) { + fs_dest = fsg->GetDestination(config); + } } } } @@ -229,12 +232,14 @@ Json::Value CollationInformationBmiInstallation(cmGeneratorTarget const* gt, std::string const& config) { cmInstallCxxModuleBmiGenerator const* bmi_gen = nullptr; - for (auto const& ig : gt->Makefile->GetInstallGenerators()) { - if (auto const* bmig = - dynamic_cast(ig.get())) { - if (bmig->GetTarget() == gt) { - bmi_gen = bmig; - continue; + // The install rule may be in a different directory than the target. + for (auto const& lg : gt->GetGlobalGenerator()->GetLocalGenerators()) { + for (auto const& ig : lg->GetMakefile()->GetInstallGenerators()) { + if (auto const* bmig = + dynamic_cast(ig.get())) { + if (bmig->GetTarget() == gt) { + bmi_gen = bmig; + } } } } diff --git a/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/CMakeLists.txt index 928be0b6fe..a2ca2efd28 100644 --- a/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/CMakeLists.txt @@ -11,7 +11,8 @@ install(TARGETS export_sepdir install(EXPORT CXXModules NAMESPACE CXXModules:: DESTINATION "lib/cmake/export_sepdir" - FILE "export_sepdir-targets.cmake") + FILE "export_sepdir-targets.cmake" + CXX_MODULES_DIRECTORY "export_sepdir-cxx-modules") install(PACKAGE_INFO "export_sepdir_cps" EXPORT CXXModules DESTINATION "lib/cmake/export_sepdir_cps" diff --git a/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/test/CMakeLists.txt b/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/test/CMakeLists.txt index d0698735da..51e296b25e 100644 --- a/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/test/CMakeLists.txt +++ b/Tests/RunCMake/CXXModulesCompile/exp-command-sepdir-install/test/CMakeLists.txt @@ -12,10 +12,14 @@ function(test_target target) endif () get_property(modules TARGET ${target} - PROPERTY "IMPORTED_CXX_MODULES_NOCONFIG") - if (modules STREQUAL "") - message(SEND_ERROR - "Expected non-empty property value for IMPORTED_CXX_MODULES_NOCONFIG") + PROPERTY IMPORTED_CXX_MODULES_DEBUG) + set(expected_modules "importable=${expected_dir}/importable.cxx") + if (NOT modules STREQUAL "${expected_modules}") + message(FATAL_ERROR + "Incorrect exported modules in ${target}:\n" + " ${modules}\n" + "does not match:\n" + " ${expected_modules}") endif () endfunction()