Avoid duplicate RPATH entries
Teach cmComputeLinkInformation::GetRPath to avoid adding the same directory to the output runtime path more than once.
This commit is contained in:
parent
1d3b35fd8a
commit
171b0993d9
|
@ -1751,6 +1751,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,
|
void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
||||||
bool for_install)
|
bool for_install)
|
||||||
|
@ -1776,10 +1792,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
||||||
this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
|
this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
|
||||||
|
|
||||||
// Construct the RPATH.
|
// Construct the RPATH.
|
||||||
|
std::set<cmStdString> emitted;
|
||||||
if(use_install_rpath)
|
if(use_install_rpath)
|
||||||
{
|
{
|
||||||
const char* install_rpath = this->Target->GetProperty("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)
|
if(use_build_rpath || use_link_rpath)
|
||||||
{
|
{
|
||||||
|
@ -1790,9 +1807,12 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
||||||
// Put this directory in the rpath if using build-tree rpath
|
// Put this directory in the rpath if using build-tree rpath
|
||||||
// support or if using the link path as an rpath.
|
// support or if using the link path as an rpath.
|
||||||
if(use_build_rpath)
|
if(use_build_rpath)
|
||||||
|
{
|
||||||
|
if(emitted.insert(*ri).second)
|
||||||
{
|
{
|
||||||
runtimeDirs.push_back(*ri);
|
runtimeDirs.push_back(*ri);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(use_link_rpath)
|
else if(use_link_rpath)
|
||||||
{
|
{
|
||||||
// Do not add any path inside the source or build tree.
|
// Do not add any path inside the source or build tree.
|
||||||
|
@ -1803,15 +1823,18 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
|
||||||
!cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) &&
|
!cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) &&
|
||||||
!cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir))
|
!cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir))
|
||||||
{
|
{
|
||||||
|
if(emitted.insert(*ri).second)
|
||||||
|
{
|
||||||
runtimeDirs.push_back(*ri);
|
runtimeDirs.push_back(*ri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add runtime paths required by the platform to always be
|
// Add runtime paths required by the platform to always be
|
||||||
// present. This is done even when skipping rpath support.
|
// present. This is done even when skipping rpath support.
|
||||||
cmSystemTools::ExpandListArgument(this->RuntimeAlways.c_str(), runtimeDirs);
|
cmCLI_ExpandListUnique(this->RuntimeAlways.c_str(), runtimeDirs, emitted);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue