diff options
author | Brad King <brad.king@kitware.com> | 2022-01-18 21:45:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-01-29 11:48:12 (GMT) |
commit | f3d2eab36a0b3bf259dfe847b42bfe0b46447107 (patch) | |
tree | 0aaf022c72fbd6380bbdeeb3ff4399c85895c949 | |
parent | d75ab9d066129d54c53e42f7d617bc90a39bbaeb (diff) | |
download | CMake-f3d2eab36a0b3bf259dfe847b42bfe0b46447107.zip CMake-f3d2eab36a0b3bf259dfe847b42bfe0b46447107.tar.gz CMake-f3d2eab36a0b3bf259dfe847b42bfe0b46447107.tar.bz2 |
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.
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f78b12b..5ec6832 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]; |