diff options
author | Brad King <brad.king@kitware.com> | 2013-02-14 14:51:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-02-14 15:14:56 (GMT) |
commit | 171b0993d9596bd3d8e7363515346c6313e7d3a2 (patch) | |
tree | bc648cfa9dc8a6363ad2d86d16345c2be4cf8fc2 /Source/cmComputeLinkInformation.cxx | |
parent | 1d3b35fd8a59c6f987b4caab17330955dbaf32bc (diff) | |
download | CMake-171b0993d9596bd3d8e7363515346c6313e7d3a2.zip CMake-171b0993d9596bd3d8e7363515346c6313e7d3a2.tar.gz CMake-171b0993d9596bd3d8e7363515346c6313e7d3a2.tar.bz2 |
Avoid duplicate RPATH entries
Teach cmComputeLinkInformation::GetRPath to avoid adding the same
directory to the output runtime path more than once.
Diffstat (limited to 'Source/cmComputeLinkInformation.cxx')
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index cd3ef59..a40df51 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1752,6 +1752,22 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath) } //---------------------------------------------------------------------------- +static void cmCLI_ExpandListUnique(const char* str, + std::vector<std::string>& out, + std::set<cmStdString>& emitted) +{ + std::vector<std::string> tmp; + cmSystemTools::ExpandListArgument(str, tmp); + for(std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end(); ++i) + { + if(emitted.insert(*i).second) + { + out.push_back(*i); + } + } +} + +//---------------------------------------------------------------------------- void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, bool for_install) { @@ -1776,10 +1792,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. + std::set<cmStdString> emitted; if(use_install_rpath) { const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); - cmSystemTools::ExpandListArgument(install_rpath, runtimeDirs); + cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) { @@ -1791,7 +1808,10 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // support or if using the link path as an rpath. if(use_build_rpath) { - runtimeDirs.push_back(*ri); + if(emitted.insert(*ri).second) + { + runtimeDirs.push_back(*ri); + } } else if(use_link_rpath) { @@ -1803,7 +1823,10 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - runtimeDirs.push_back(*ri); + if(emitted.insert(*ri).second) + { + runtimeDirs.push_back(*ri); + } } } } @@ -1811,7 +1834,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // Add runtime paths required by the platform to always be // present. This is done even when skipping rpath support. - cmSystemTools::ExpandListArgument(this->RuntimeAlways.c_str(), runtimeDirs); + cmCLI_ExpandListUnique(this->RuntimeAlways.c_str(), runtimeDirs, emitted); } //---------------------------------------------------------------------------- |