1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

export: Allow multiple exports when only one export is installed

Since commit c8997fc046 (export: Allow depending on targets exported
multiple times, 2024-12-26, v4.0.0-rc1~241^2), it is possible to depend
on a target exported multiple times so long as the target is exported in
only one set and with a consistent namespace.  However, as a
side-effect, a target could not be in multiple export sets even if only
one of those sets was installed.

Update the check so that uninstalled export sets do not count towards a
target being exported multiple times.
This commit is contained in:
Martin Duffy
2025-03-17 17:07:17 -04:00
committed by Brad King
parent df2ec408c9
commit d723409e8e
3 changed files with 11 additions and 4 deletions

View File

@@ -280,12 +280,14 @@ cmExportFileGenerator::ExportInfo cmExportInstallFileGenerator::FindExportInfo(
[&name](std::unique_ptr<cmTargetExport> const& te) {
return te->TargetName == name;
})) {
exportSets.insert(exp.first);
std::vector<cmInstallExportGenerator const*> const* installs =
exportSet.GetInstallations();
for (cmInstallExportGenerator const* install : *installs) {
exportFiles.push_back(install->GetDestinationFile());
namespaces.insert(install->GetNamespace());
if (!installs->empty()) {
exportSets.insert(exp.first);
for (cmInstallExportGenerator const* install : *installs) {
exportFiles.push_back(install->GetDestinationFile());
namespaces.insert(install->GetNamespace());
}
}
}
}

View File

@@ -0,0 +1,4 @@
project(DependsMultipleNotInstalled CXX)
set(NAMESPACE foo::)
include(DependsMultipleCommon.cmake)
install(TARGETS foo EXPORT foo-alt) # set foo-alt never installed

View File

@@ -34,3 +34,4 @@ run_cmake(LowerCaseFile)
run_cmake(Requirements)
run_cmake(TargetTypes)
run_cmake(DependsMultiple)
run_cmake(DependsMultipleNotInstalled)