From 012e4c4f68dc75002468cc043065c358bc12a7b5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 27 Aug 2008 10:21:50 -0400 Subject: 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. --- Source/cmComputeLinkDepends.cxx | 13 ++++++++++--- Source/cmComputeLinkDepends.h | 6 ++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index e3ef604..d687d64 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -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 _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; @@ -555,7 +558,10 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, // The depender must come before the dependee. if(depender_index >= 0) { - this->EntryConstraintGraph[dependee_index].push_back(depender_index); + if(!this->EntryList[dependee_index].IsFlag) + { + this->EntryConstraintGraph[dependee_index].push_back(depender_index); + } } else { @@ -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); diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 5777110..b41da9e 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -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 EntryVector; -- cgit v0.12