summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-02 19:35:23 (GMT)
committerBrad King <brad.king@kitware.com>2008-03-02 19:35:23 (GMT)
commitd732de4a8a189699135e67f8bad66757bdcf188f (patch)
treea18672b2681d61fd62d3be37cb9166ab3fe50290 /Source/cmSystemTools.cxx
parent16a415dd0c81a4a11cf6fa78755ce636e5ac3ab9 (diff)
downloadCMake-d732de4a8a189699135e67f8bad66757bdcf188f.zip
CMake-d732de4a8a189699135e67f8bad66757bdcf188f.tar.gz
CMake-d732de4a8a189699135e67f8bad66757bdcf188f.tar.bz2
ENH: Cleanup builtin chrpath support
- Move computation of extended build-tree rpath to cmComputeLinkInformation - Only enable the extended build-tree rpath if the target will be installed - Generalize the interface of file(CHRPATH) - When changing the rpath on installation only replace the part generated by CMake because the native tools (ex SunCC on Linux) might have added their own part to the rpath
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx37
1 files changed, 33 insertions, 4 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index fb41834..dbcf775 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2198,18 +2198,41 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
//----------------------------------------------------------------------------
bool cmSystemTools::ChangeRPath(std::string const& file,
+ std::string const& oldRPath,
std::string const& newRPath,
std::string* emsg)
{
#if defined(CMAKE_USE_ELF_PARSER)
unsigned long rpathPosition = 0;
unsigned long rpathSize = 0;
+ std::string rpathSuffix;
{
cmELF elf(file.c_str());
if(cmELF::StringEntry const* se = elf.GetRPath())
{
+ // Make sure the current rpath begins with the old rpath.
+ if(se->Value.length() < oldRPath.length() ||
+ se->Value.substr(0, oldRPath.length()) != oldRPath)
+ {
+ // If it begins with the new rpath instead then it is okay.
+ if(se->Value.length() >= newRPath.length() &&
+ se->Value.substr(0, newRPath.length()) == newRPath)
+ {
+ return true;
+ }
+ if(emsg)
+ {
+ *emsg = "The current RPATH does not begin with that specified.";
+ }
+ return false;
+ }
+
+ // Store information about the entry.
rpathPosition = se->Position;
rpathSize = se->Size;
+
+ // Store the part of the path we must preserve.
+ rpathSuffix = se->Value.substr(oldRPath.length(), oldRPath.npos);
}
else if(newRPath.empty())
{
@@ -2221,14 +2244,19 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
{
if(emsg)
{
- *emsg = "No valid ELF RPATH entry exists in the file.";
+ *emsg = "No valid ELF RPATH entry exists in the file; ";
+ *emsg += elf.GetErrorMessage();
}
return false;
}
}
+ // Compute the full new rpath.
+ std::string rpath = newRPath;
+ rpath += rpathSuffix;
+
// Make sure there is enough room to store the new rpath and at
// least one null terminator.
- if(rpathSize < newRPath.length()+1)
+ if(rpathSize < rpath.length()+1)
{
if(emsg)
{
@@ -2259,8 +2287,8 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// Write the new rpath. Follow it with enough null terminators to
// fill the string table entry.
- f << newRPath;
- for(unsigned long i=newRPath.length(); i < rpathSize; ++i)
+ f << rpath;
+ for(unsigned long i=rpath.length(); i < rpathSize; ++i)
{
f << '\0';
}
@@ -2280,6 +2308,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
}
#else
(void)file;
+ (void)oldRPath;
(void)newRPath;
(void)emsg;
return false;