LinkItem: track cmSourceFile
instances for external objects
The target may be required in order to provide Fortran modules, so track the source file so that the target may be looked up when needed.
This commit is contained in:
parent
d2fa56772f
commit
1175f1c874
@ -515,6 +515,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.ObjectSource = item.ObjectSource;
|
||||
|
||||
// Record explicitly linked object files separately.
|
||||
this->ObjectEntries.emplace_back(index);
|
||||
|
@ -22,6 +22,7 @@
|
||||
class cmGeneratorTarget;
|
||||
class cmGlobalGenerator;
|
||||
class cmMakefile;
|
||||
class cmSourceFile;
|
||||
class cmake;
|
||||
|
||||
/** \class cmComputeLinkDepends
|
||||
@ -63,6 +64,9 @@ public:
|
||||
|
||||
BT<std::string> Item;
|
||||
cmGeneratorTarget const* Target = nullptr;
|
||||
// The source file representing the external object (used when linking
|
||||
// `$<TARGET_OBJECTS>`)
|
||||
cmSourceFile const* ObjectSource = nullptr;
|
||||
EntryKind Kind = Library;
|
||||
// The following member is for the management of items specified
|
||||
// through genex $<LINK_LIBRARY:...>
|
||||
|
@ -1176,7 +1176,7 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
|
||||
: cmStateEnums::RuntimeBinaryArtifact;
|
||||
std::string exe = tgt->GetFullPath(config, artifact, true);
|
||||
this->Items.emplace_back(
|
||||
BT<std::string>(exe, item.Backtrace), ItemIsPath::Yes, tgt,
|
||||
BT<std::string>(exe, item.Backtrace), ItemIsPath::Yes, tgt, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT
|
||||
? "__CMAKE_LINK_EXECUTABLE"
|
||||
: entry.Feature));
|
||||
@ -1197,7 +1197,7 @@ void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
|
||||
} else if (this->GlobalGenerator->IsXcode() &&
|
||||
!tgt->GetImportedXcFrameworkPath(config).empty()) {
|
||||
this->Items.emplace_back(
|
||||
tgt->GetImportedXcFrameworkPath(config), ItemIsPath::Yes, tgt,
|
||||
tgt->GetImportedXcFrameworkPath(config), ItemIsPath::Yes, tgt, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT
|
||||
? "__CMAKE_LINK_XCFRAMEWORK"
|
||||
: entry.Feature));
|
||||
@ -1679,15 +1679,15 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
|
||||
if (isImportedFrameworkFolderOnApple) {
|
||||
if (entry.Feature == DEFAULT) {
|
||||
this->AddLibraryFeature("FRAMEWORK");
|
||||
this->Items.emplace_back(item, ItemIsPath::Yes, target,
|
||||
this->Items.emplace_back(item, ItemIsPath::Yes, target, nullptr,
|
||||
this->FindLibraryFeature("FRAMEWORK"));
|
||||
} else {
|
||||
this->Items.emplace_back(item, ItemIsPath::Yes, target,
|
||||
this->Items.emplace_back(item, ItemIsPath::Yes, target, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature));
|
||||
}
|
||||
} else {
|
||||
this->Items.emplace_back(
|
||||
item, ItemIsPath::Yes, target,
|
||||
item, ItemIsPath::Yes, target, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT
|
||||
? "__CMAKE_LINK_FRAMEWORK"
|
||||
: entry.Feature));
|
||||
@ -1695,17 +1695,17 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
|
||||
} else {
|
||||
if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s)) {
|
||||
this->Items.emplace_back(fwDescriptor->GetLinkName(), ItemIsPath::Yes,
|
||||
target,
|
||||
target, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature));
|
||||
} else if (entry.Feature == DEFAULT &&
|
||||
isImportedFrameworkFolderOnApple) {
|
||||
this->AddLibraryFeature("FRAMEWORK");
|
||||
this->Items.emplace_back(fwDescriptor->GetLinkName(), ItemIsPath::Yes,
|
||||
target,
|
||||
target, nullptr,
|
||||
this->FindLibraryFeature("FRAMEWORK"));
|
||||
} else {
|
||||
this->Items.emplace_back(
|
||||
item, ItemIsPath::Yes, target,
|
||||
item, ItemIsPath::Yes, target, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT
|
||||
? "__CMAKE_LINK_LIBRARY"
|
||||
: entry.Feature));
|
||||
@ -1714,7 +1714,7 @@ void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
|
||||
} else {
|
||||
// Now add the full path to the library.
|
||||
this->Items.emplace_back(
|
||||
item, ItemIsPath::Yes, target,
|
||||
item, ItemIsPath::Yes, target, nullptr,
|
||||
this->FindLibraryFeature(
|
||||
entry.Feature == DEFAULT ? "__CMAKE_LINK_LIBRARY" : entry.Feature));
|
||||
}
|
||||
@ -1774,7 +1774,7 @@ void cmComputeLinkInformation::AddFullItem(LinkEntry const& entry)
|
||||
|
||||
// Now add the full path to the library.
|
||||
this->Items.emplace_back(
|
||||
item, ItemIsPath::Yes, nullptr,
|
||||
item, ItemIsPath::Yes, nullptr, entry.ObjectSource,
|
||||
this->FindLibraryFeature(
|
||||
entry.Feature == DEFAULT
|
||||
? (entry.Kind == cmComputeLinkDepends::LinkEntry::Object
|
||||
@ -2000,13 +2000,13 @@ void cmComputeLinkInformation::AddFrameworkItem(LinkEntry const& entry)
|
||||
if (this->GlobalGenerator->IsXcode()) {
|
||||
// Add framework path - it will be handled by Xcode after it's added to
|
||||
// "Link Binary With Libraries" build phase
|
||||
this->Items.emplace_back(item, ItemIsPath::Yes, nullptr,
|
||||
this->Items.emplace_back(item, ItemIsPath::Yes, nullptr, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT
|
||||
? "FRAMEWORK"
|
||||
: entry.Feature));
|
||||
} else {
|
||||
this->Items.emplace_back(
|
||||
fwDescriptor->GetLinkName(), ItemIsPath::Yes, nullptr,
|
||||
fwDescriptor->GetLinkName(), ItemIsPath::Yes, nullptr, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT ? "FRAMEWORK"
|
||||
: entry.Feature));
|
||||
}
|
||||
@ -2024,7 +2024,7 @@ void cmComputeLinkInformation::AddXcFrameworkItem(LinkEntry const& entry)
|
||||
plist->SelectSuitableLibrary(*this->Makefile, entry.Item.Backtrace)) {
|
||||
if (this->GlobalGenerator->IsXcode()) {
|
||||
this->Items.emplace_back(
|
||||
entry.Item.Value, ItemIsPath::Yes, nullptr,
|
||||
entry.Item.Value, ItemIsPath::Yes, nullptr, nullptr,
|
||||
this->FindLibraryFeature(entry.Feature == DEFAULT
|
||||
? "__CMAKE_LINK_XCFRAMEWORK"
|
||||
: entry.Feature));
|
||||
|
@ -22,6 +22,7 @@ class cmGeneratorTarget;
|
||||
class cmGlobalGenerator;
|
||||
class cmMakefile;
|
||||
class cmOrderDirectories;
|
||||
class cmSourceFile;
|
||||
class cmake;
|
||||
|
||||
/** \class cmComputeLinkInformation
|
||||
@ -51,16 +52,21 @@ public:
|
||||
{
|
||||
Item(BT<std::string> v, ItemIsPath isPath,
|
||||
cmGeneratorTarget const* target = nullptr,
|
||||
cmSourceFile const* objectSource = nullptr,
|
||||
FeatureDescriptor const* feature = nullptr)
|
||||
: Value(std::move(v))
|
||||
, IsPath(isPath)
|
||||
, Target(target)
|
||||
, ObjectSource(objectSource)
|
||||
, Feature(feature)
|
||||
{
|
||||
}
|
||||
BT<std::string> Value;
|
||||
ItemIsPath IsPath = ItemIsPath::No;
|
||||
cmGeneratorTarget const* Target = nullptr;
|
||||
// The source file representing the external object (used when linking
|
||||
// `$<TARGET_OBJECTS>`)
|
||||
cmSourceFile const* ObjectSource = nullptr;
|
||||
|
||||
bool HasFeature() const { return this->Feature != nullptr; }
|
||||
const std::string& GetFeatureName() const
|
||||
|
@ -6898,6 +6898,7 @@ void cmGeneratorTarget::ExpandLinkItems(
|
||||
cmSourceFile const* sf =
|
||||
mf->GetSource(maybeObj, cmSourceFileLocationKind::Known);
|
||||
if (sf && sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
|
||||
item.ObjectSource = sf;
|
||||
iface.Objects.emplace_back(std::move(item));
|
||||
continue;
|
||||
}
|
||||
@ -8489,6 +8490,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
|
||||
cmSourceFile const* sf =
|
||||
mf->GetSource(maybeObj, cmSourceFileLocationKind::Known);
|
||||
if (sf && sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
|
||||
item.ObjectSource = sf;
|
||||
impl.Objects.emplace_back(std::move(item));
|
||||
continue;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "cmTargetLinkLibraryType.h"
|
||||
|
||||
class cmGeneratorTarget;
|
||||
class cmSourceFile;
|
||||
|
||||
// Basic information about each link item.
|
||||
class cmLinkItem
|
||||
@ -29,6 +30,9 @@ public:
|
||||
cmLinkItem(cmGeneratorTarget const* t, bool c, cmListFileBacktrace bt);
|
||||
std::string const& AsStr() const;
|
||||
cmGeneratorTarget const* Target = nullptr;
|
||||
// The source file representing the external object (used when linking
|
||||
// `$<TARGET_OBJECTS>`)
|
||||
cmSourceFile const* ObjectSource = nullptr;
|
||||
bool Cross = false;
|
||||
cmListFileBacktrace Backtrace;
|
||||
friend bool operator<(cmLinkItem const& l, cmLinkItem const& r);
|
||||
|
Loading…
Reference in New Issue
Block a user