summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-01-18 16:45:06 -0500
committerBrad King <brad.king@kitware.com>2022-01-29 06:48:12 -0500
commitf3d2eab36a0b3bf259dfe847b42bfe0b46447107 (patch)
tree0aaf022c72fbd6380bbdeeb3ff4399c85895c949 /Source/cmGeneratorTarget.cxx
parentd75ab9d066129d54c53e42f7d617bc90a39bbaeb (diff)
downloadcmake-f3d2eab36a0b3bf259dfe847b42bfe0b46447107.tar.gz
cmGeneratorTarget: Fix link interface caching of partial results
`GetLinkInterface` and `GetLinkInterfaceLibraries` cache their results to avoid repeating work. In the case that the result does not depend on the "head" target, they re-use results computed from the first call with any "head" target. However, if `GetLinkInterfaceLibraries` is called first, then not all of the link interface is populated. If `GetLinkInterface` is later called, it needs to finish populating the link interface even if a partially completed interface was cached.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx30
1 files changed, 14 insertions, 16 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index f78b12b4de..5ec683217b 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -6746,17 +6746,16 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
// Lookup any existing link interface for this configuration.
cmHeadToLinkInterfaceMap& hm = this->GetHeadToLinkInterfaceMap(config);
- if (secondPass) {
- hm.erase(head);
- }
-
// If the link interface does not depend on the head target
- // then return the one we computed first.
+ // then re-use the one from the head we computed first.
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
- return &hm.begin()->second;
+ head = hm.begin()->first;
}
cmOptionalLinkInterface& iface = hm[head];
+ if (secondPass) {
+ iface = cmOptionalLinkInterface();
+ }
if (!iface.LibrariesDone) {
iface.LibrariesDone = true;
this->ComputeLinkInterfaceLibraries(config, iface, head,
@@ -6875,9 +6874,9 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
: this->GetHeadToLinkInterfaceMap(config));
// If the link interface does not depend on the head target
- // then return the one we computed first.
+ // then re-use the one from the head we computed first.
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
- return &hm.begin()->second;
+ head = hm.begin()->first;
}
cmOptionalLinkInterface& iface = hm[head];
@@ -7381,17 +7380,16 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
? this->GetHeadToLinkInterfaceUsageRequirementsMap(config)
: this->GetHeadToLinkInterfaceMap(config));
- if (secondPass) {
- hm.erase(headTarget);
- }
-
// If the link interface does not depend on the head target
- // then return the one we computed first.
+ // then re-use the one from the head we computed first.
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
- return &hm.begin()->second;
+ headTarget = hm.begin()->first;
}
cmOptionalLinkInterface& iface = hm[headTarget];
+ if (secondPass) {
+ iface = cmOptionalLinkInterface();
+ }
if (!iface.AllDone) {
iface.AllDone = true;
iface.LibrariesDone = true;
@@ -7905,9 +7903,9 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
this->LinkImplMap[cmSystemTools::UpperCase(config)];
// If the link implementation does not depend on the head target
- // then return the one we computed first.
+ // then re-use the one from the head we computed first.
if (!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition) {
- return &hm.begin()->second;
+ head = hm.begin()->first;
}
cmOptionalLinkImplementation& impl = hm[head];