diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-10-27 16:46:04 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-10-30 14:06:12 (GMT) |
commit | 22da18b9953f1ec9dff039572b5e8903009e4afb (patch) | |
tree | f63d2a5cc7272d8fc6cba5db15c2069f31b6faf2 /Source/cmComputeLinkDepends.cxx | |
parent | 64d9240564c778674e6d4b2a34de88f2cff14a96 (diff) | |
download | CMake-22da18b9953f1ec9dff039572b5e8903009e4afb.zip CMake-22da18b9953f1ec9dff039572b5e8903009e4afb.tar.gz CMake-22da18b9953f1ec9dff039572b5e8903009e4afb.tar.bz2 |
Fortran: Restore support for TARGET_OBJECTS providing modules
Continue b665966933 (cmComputeLinkInformation: track OBJECT library
dependencies, 2023-07-22) which added explicitly listed `OBJECT`
libraries to the list of targets which the collator needs to consider.
Now also consider targets which provide objects directly to the target
via a `$<TARGET_OBJECT>` source lists.
Also add tests which use target objects directly and through an
`INTERFACE` library with target objects in its own sources.
Fixes: #25365
Diffstat (limited to 'Source/cmComputeLinkDepends.cxx')
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index ce0df6b..4100135 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -26,6 +26,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" +#include "cmSourceFile.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmTarget.h" @@ -319,6 +320,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. @@ -701,6 +705,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) |