diff options
author | Brad King <brad.king@kitware.com> | 2014-11-11 17:45:54 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-11-11 17:45:54 (GMT) |
commit | 70c2432887da232d65bdc56e34ff046656e19703 (patch) | |
tree | 5f32496180943fd948259784e6b8ba9dbe4d26ad /Source | |
parent | dd563e1eb3002578fcc28f9cc4ef9d2326043a23 (diff) | |
parent | 4db31095e5f4ce410c013e0b92bc5d1baee03934 (diff) | |
download | CMake-70c2432887da232d65bdc56e34ff046656e19703.zip CMake-70c2432887da232d65bdc56e34ff046656e19703.tar.gz CMake-70c2432887da232d65bdc56e34ff046656e19703.tar.bz2 |
Merge topic 'fix_link-line-dedup_regression'
4db31095 Fix link line order when shared libraries are de-duplicated
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index b13a125..1fb8f30 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -263,21 +263,26 @@ cmComputeLinkDepends::Compute() this->OrderLinkEntires(); // Compute the final set of link entries. + // Iterate in reverse order so we can keep only the last occurrence + // of a shared library. std::set<int> emmitted; - for(std::vector<int>::const_iterator li = this->FinalLinkOrder.begin(); - li != this->FinalLinkOrder.end(); ++li) + for(std::vector<int>::const_reverse_iterator + li = this->FinalLinkOrder.rbegin(), + le = this->FinalLinkOrder.rend(); + li != le; ++li) { int i = *li; LinkEntry const& e = this->EntryList[i]; cmTarget const* t = e.Target; - // Entries that we know the linker will re-use for symbols - // needed by later entries do not need to be repeated. + // Entries that we know the linker will re-use do not need to be repeated. bool uniquify = t && t->GetType() == cmTarget::SHARED_LIBRARY; if(!uniquify || emmitted.insert(i).second) { this->FinalLinkEntries.push_back(e); } } + // Reverse the resulting order since we iterated in reverse. + std::reverse(this->FinalLinkEntries.begin(), this->FinalLinkEntries.end()); // Display the final set. if(this->DebugMode) |