BUG: Do not infer dependencies of link flags

In cmComputeLinkDepends link items that look like flags (starting in
'-') should not be included in dependency inferral.  They are not
libraries and therefore have no dependencies.  They should just be
passed through to the final link line unchanged.  See issue #7546.
This commit is contained in:
Brad King 2008-08-27 10:21:50 -04:00
parent 32fe1d5b0d
commit 012e4c4f68
2 changed files with 14 additions and 5 deletions

View File

@ -50,7 +50,9 @@ those without known dependencies. We will call the two types "known
items" and "unknown items", respecitvely. Known items are those whose
names correspond to targets (built or imported) and those for which an
old-style <item>_LIB_DEPENDS variable is defined. All other items are
unknown and we must infer dependencies for them.
unknown and we must infer dependencies for them. For items that look
like flags (beginning with '-') we trivially infer no dependencies,
and do not include them in the dependencies of other items.
Known items have dependency lists ordered based on how the user
specified them. We can use this order to infer potential dependencies
@ -293,6 +295,7 @@ int cmComputeLinkDepends::AddLinkEntry(std::string const& item)
LinkEntry& entry = this->EntryList[index];
entry.Item = item;
entry.Target = this->FindTargetToLink(entry.Item.c_str());
entry.IsFlag = !entry.Target && item[0] == '-';
// If the item has dependencies queue it to follow them.
if(entry.Target)
@ -312,7 +315,7 @@ int cmComputeLinkDepends::AddLinkEntry(std::string const& item)
BFSEntry qe = {index, val};
this->BFSQueue.push(qe);
}
else
else if(!entry.IsFlag)
{
// The item dependencies are not known. We need to infer them.
this->InferredDependSets[index] = new DependSetList;
@ -554,9 +557,12 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
// The depender must come before the dependee.
if(depender_index >= 0)
{
if(!this->EntryList[dependee_index].IsFlag)
{
this->EntryConstraintGraph[dependee_index].push_back(depender_index);
}
}
else
{
// This is a direct dependency of the target being linked.
@ -572,6 +578,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
// items are outside libraries that should not be depending on
// targets.
if(!this->EntryList[dependee_index].Target &&
!this->EntryList[dependee_index].IsFlag &&
dependee_index != dsi->first)
{
dsi->second.insert(dependee_index);

View File

@ -46,9 +46,11 @@ public:
std::string Item;
cmTarget* Target;
bool IsSharedDep;
LinkEntry(): Item(), Target(0), IsSharedDep(false) {}
bool IsFlag;
LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {}
LinkEntry(LinkEntry const& r):
Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep) {}
Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep),
IsFlag(r.IsFlag) {}
};
typedef std::vector<LinkEntry> EntryVector;