summaryrefslogtreecommitdiffstats
path: root/Source/cmComputeLinkDepends.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-10-31 13:12:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-10-31 13:12:28 (GMT)
commit3a515b31b39d9eb9c07a39e6da7705cfd1d01f25 (patch)
treea3193b5adf1c74464afcb6d062c78b804e9e371e /Source/cmComputeLinkDepends.cxx
parentd33ea3dff5e36e4e2dea39282f20512a8ec5c87f (diff)
parent22da18b9953f1ec9dff039572b5e8903009e4afb (diff)
downloadCMake-3a515b31b39d9eb9c07a39e6da7705cfd1d01f25.zip
CMake-3a515b31b39d9eb9c07a39e6da7705cfd1d01f25.tar.gz
CMake-3a515b31b39d9eb9c07a39e6da7705cfd1d01f25.tar.bz2
Merge topic 'modules-depends-via-target-objects' into release-3.28
22da18b995 Fortran: Restore support for TARGET_OBJECTS providing modules 64d9240564 cmComputeLinkInformation: skip over linking to items for object purposes 035302b7e3 cmComputeLinkDepends: also copy the target from object link items 861876b936 Tests/ObjectLibrary: fix comment Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Acked-by: scivision <michael@scivision.dev> Merge-request: !8923
Diffstat (limited to 'Source/cmComputeLinkDepends.cxx')
-rw-r--r--Source/cmComputeLinkDepends.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 7394d86..596572b 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -27,6 +27,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
+#include "cmSourceFile.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmTarget.h"
@@ -320,6 +321,9 @@ cmComputeLinkDepends::Compute()
// Follow the link dependencies of the target to be linked.
this->AddDirectLinkEntries();
+ // Add dependencies on targets named by $<TARGET_OBJECTS:...> sources.
+ this->AddTargetObjectEntries();
+
// Complete the breadth-first search of dependencies.
while (!this->BFSQueue.empty()) {
// Get the next entry.
@@ -513,6 +517,7 @@ void cmComputeLinkDepends::AddLinkObject(cmLinkItem const& item)
LinkEntry& entry = this->EntryList[index];
entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
entry.Kind = LinkEntry::Object;
+ entry.Target = item.Target;
// Record explicitly linked object files separately.
this->ObjectEntries.emplace_back(index);
@@ -701,6 +706,21 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
}
}
+void cmComputeLinkDepends::AddTargetObjectEntries()
+{
+ std::vector<cmSourceFile const*> externalObjects;
+ this->Target->GetExternalObjects(externalObjects, this->Config);
+ for (auto const* externalObject : externalObjects) {
+ std::string const& objLib = externalObject->GetObjectLibrary();
+ if (objLib.empty()) {
+ continue;
+ }
+ cmLinkItem const& objItem =
+ this->Target->ResolveLinkItem(BT<std::string>(objLib));
+ this->AddLinkObject(objItem);
+ }
+}
+
template <typename T>
void cmComputeLinkDepends::AddLinkEntries(size_t depender_index,
std::vector<T> const& libs)