diff options
author | Brad King <brad.king@kitware.com> | 2024-07-16 14:32:04 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-07-16 14:32:14 (GMT) |
commit | 5a3eabcd1f48691a27098abebe4db8cf8d73daba (patch) | |
tree | 14f3bd2019e8a2e9c3da37f334f30122107aa554 | |
parent | 0c567293bf79e1b2009bb025a4b2c431cf18c819 (diff) | |
parent | 7a77a6c642eac544e3761272222696a76fcc78a8 (diff) | |
download | CMake-5a3eabcd1f48691a27098abebe4db8cf8d73daba.zip CMake-5a3eabcd1f48691a27098abebe4db8cf8d73daba.tar.gz CMake-5a3eabcd1f48691a27098abebe4db8cf8d73daba.tar.bz2 |
Merge topic 'custom-transitive-properties' into release-3.30
7a77a6c642 Restore support for exporting INTERFACE with missing dependencies
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Robert Maynard <robertjmaynard@gmail.com>
Merge-request: !9656
-rw-r--r-- | Source/cmExportFileGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 8 | ||||
-rw-r--r-- | Source/cmGeneratorTarget_Link.cxx | 39 | ||||
-rw-r--r-- | Source/cmGeneratorTarget_TransitiveProperty.cxx | 3 | ||||
-rw-r--r-- | Source/cmLinkItem.h | 3 |
5 files changed, 45 insertions, 9 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5348f2..28c91da 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -613,6 +613,7 @@ void cmExportFileGenerator::PopulateCustomTransitiveInterfaceProperties( properties); this->PopulateInterfaceProperty("TRANSITIVE_LINK_PROPERTIES", target, properties); + cmGeneratorTarget::CheckLinkLibrariesSuppressionRAII cllSuppressRAII; std::set<std::string> ifaceProperties; for (std::string const& config : this->Configurations) { for (auto const& i : target->GetCustomTransitiveProperties( diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index dd5f047..1e6ff78 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -99,6 +99,13 @@ public: // Call this after generation is complete. void CheckLinkLibraries() const; + class CheckLinkLibrariesSuppressionRAII + { + public: + CheckLinkLibrariesSuppressionRAII(); + ~CheckLinkLibrariesSuppressionRAII(); + }; + cmStateEnums::TargetType GetType() const; const std::string& GetName() const; std::string GetExportName() const; @@ -264,7 +271,6 @@ public: { Compile, // Usage requirements for compiling. Excludes $<LINK_ONLY>. Link, // Usage requirements for linking. Includes $<LINK_ONLY>. - LinkInterfaceEval, }; cmLinkInterfaceLibraries const* GetLinkInterfaceLibraries( diff --git a/Source/cmGeneratorTarget_Link.cxx b/Source/cmGeneratorTarget_Link.cxx index 3ed77a8..50bcefa 100644 --- a/Source/cmGeneratorTarget_Link.cxx +++ b/Source/cmGeneratorTarget_Link.cxx @@ -54,6 +54,20 @@ const std::string kINTERFACE_LINK_LIBRARIES_DIRECT = "INTERFACE_LINK_LIBRARIES_DIRECT"; const std::string kINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE = "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"; + +unsigned int CheckLinkLibrariesSuppressionRAIICount; +void MaybeEnableCheckLinkLibraries(cmOptionalLinkImplementation& impl) +{ + if (CheckLinkLibrariesSuppressionRAIICount == 0) { + impl.CheckLinkLibraries = true; + } +} +void MaybeEnableCheckLinkLibraries(cmOptionalLinkInterface& iface) +{ + if (CheckLinkLibrariesSuppressionRAIICount == 0) { + iface.CheckLinkLibraries = true; + } +} } class cmTargetCollectLinkLanguages @@ -372,7 +386,8 @@ void cmGeneratorTarget::CheckLinkLibraries() const // There could be several entries used when computing the pre-CMP0022 // default link interface. Check only the entry for our own link impl. auto const hmi = hm.find(this); - if (hmi == hm.end() || !hmi->second.LibrariesDone) { + if (hmi == hm.end() || !hmi->second.LibrariesDone || + !hmi->second.CheckLinkLibraries) { continue; } for (cmLinkImplItem const& item : hmi->second.Libraries) { @@ -392,7 +407,7 @@ void cmGeneratorTarget::CheckLinkLibraries() const // should be a subset of LinkInterfaceMap (with LINK_ONLY left out). for (auto const& hmp : this->LinkInterfaceMap) { for (auto const& hmi : hmp.second) { - if (!hmi.second.LibrariesDone || hmi.second.LinkOnlyEval) { + if (!hmi.second.LibrariesDone || !hmi.second.CheckLinkLibraries) { continue; } for (cmLinkItem const& item : hmi.second.Libraries) { @@ -408,6 +423,18 @@ void cmGeneratorTarget::CheckLinkLibraries() const } } +cmGeneratorTarget::CheckLinkLibrariesSuppressionRAII:: + CheckLinkLibrariesSuppressionRAII() +{ + ++CheckLinkLibrariesSuppressionRAIICount; +} + +cmGeneratorTarget::CheckLinkLibrariesSuppressionRAII:: + ~CheckLinkLibrariesSuppressionRAII() +{ + --CheckLinkLibrariesSuppressionRAIICount; +} + namespace { cm::string_view missingTargetPossibleReasons = "Possible reasons include:\n" @@ -642,7 +669,7 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface( if (secondPass) { iface = cmOptionalLinkInterface(); } - iface.LinkOnlyEval = false; + MaybeEnableCheckLinkLibraries(iface); if (!iface.LibrariesDone) { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries(config, iface, head, UseTo::Link); @@ -766,7 +793,7 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( } cmOptionalLinkInterface& iface = hm[head]; - iface.LinkOnlyEval = (usage == UseTo::LinkInterfaceEval); + MaybeEnableCheckLinkLibraries(iface); if (!iface.LibrariesDone) { iface.LibrariesDone = true; this->ComputeLinkInterfaceLibraries(config, iface, head, usage); @@ -1036,7 +1063,7 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface( if (secondPass) { iface = cmOptionalLinkInterface(); } - iface.LinkOnlyEval = (usage == UseTo::LinkInterfaceEval); + MaybeEnableCheckLinkLibraries(iface); if (!iface.AllDone) { iface.AllDone = true; iface.LibrariesDone = true; @@ -1109,6 +1136,7 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( if (secondPass) { impl = cmOptionalLinkImplementation(); } + MaybeEnableCheckLinkLibraries(impl); if (!impl.LibrariesDone) { impl.LibrariesDone = true; this->ComputeLinkImplementationLibraries(config, impl, this, usage); @@ -1165,6 +1193,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal( } cmOptionalLinkImplementation& impl = hm[head]; + MaybeEnableCheckLinkLibraries(impl); if (!impl.LibrariesDone) { impl.LibrariesDone = true; this->ComputeLinkImplementationLibraries(config, impl, head, usage); diff --git a/Source/cmGeneratorTarget_TransitiveProperty.cxx b/Source/cmGeneratorTarget_TransitiveProperty.cxx index 107f6d9..ac929eb 100644 --- a/Source/cmGeneratorTarget_TransitiveProperty.cxx +++ b/Source/cmGeneratorTarget_TransitiveProperty.cxx @@ -286,8 +286,7 @@ cmGeneratorTarget::GetCustomTransitiveProperties(std::string const& config, } } }; - addTransitiveProperties("TRANSITIVE_LINK_PROPERTIES", - UseTo::LinkInterfaceEval); + addTransitiveProperties("TRANSITIVE_LINK_PROPERTIES", UseTo::Link); addTransitiveProperties("TRANSITIVE_COMPILE_PROPERTIES", UseTo::Compile); i = ctpm.emplace(config, std::move(ctp)).first; } diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index bd1531b..4e356b7 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -120,11 +120,11 @@ struct cmLinkInterface : public cmLinkInterfaceLibraries struct cmOptionalLinkInterface : public cmLinkInterface { - bool LinkOnlyEval = false; bool LibrariesDone = false; bool AllDone = false; bool Exists = false; bool Explicit = false; + bool CheckLinkLibraries = false; }; struct cmHeadToLinkInterfaceMap @@ -149,6 +149,7 @@ struct cmOptionalLinkImplementation : public cmLinkImplementation bool LibrariesDone = false; bool LanguagesDone = false; bool HadHeadSensitiveCondition = false; + bool CheckLinkLibraries = false; }; /** Compute the link type to use for the given configuration. */ |