summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.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/cmFileCommand.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/cmFileCommand.cxx')
-rw-r--r--Source/cmFileCommand.cxx68
1 files changed, 62 insertions, 6 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 0128135..8868812 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -1333,25 +1333,81 @@ bool cmFileCommand::HandleInstallDestination(cmFileInstaller& installer,
//----------------------------------------------------------------------------
bool cmFileCommand::HandleChrpathCommand(std::vector<std::string> const& args)
{
- if(args.size() != 3)
+ // Evaluate arguments.
+ const char* file = 0;
+ const char* oldRPath = 0;
+ const char* newRPath = 0;
+ enum Doing { DoingNone, DoingFile, DoingOld, DoingNew };
+ Doing doing = DoingNone;
+ for(unsigned int i=1; i < args.size(); ++i)
+ {
+ if(args[i] == "OLD_RPATH")
+ {
+ doing = DoingOld;
+ }
+ else if(args[i] == "NEW_RPATH")
+ {
+ doing = DoingNew;
+ }
+ else if(args[i] == "FILE")
+ {
+ doing = DoingFile;
+ }
+ else if(doing == DoingFile)
+ {
+ file = args[i].c_str();
+ doing = DoingNone;
+ }
+ else if(doing == DoingOld)
+ {
+ oldRPath = args[i].c_str();
+ doing = DoingNone;
+ }
+ else if(doing == DoingNew)
+ {
+ newRPath = args[i].c_str();
+ doing = DoingNone;
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "CHRPATH given unknown argument " << args[i];
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+ if(!file)
+ {
+ this->SetError("CHRPATH not given FILE option.");
+ return false;
+ }
+ if(!oldRPath)
{
- this->SetError("CHRPATH must be given a file and a new rpath.");
+ this->SetError("CHRPATH not given OLD_RPATH option.");
return false;
}
- if(!cmSystemTools::FileExists(args[1].c_str(), true))
+ if(!newRPath)
{
- this->SetError("CHRPATH given file that does not exist.");
+ this->SetError("CHRPATH not given NEW_RPATH option.");
+ return false;
+ }
+ if(!cmSystemTools::FileExists(file, true))
+ {
+ cmOStringStream e;
+ e << "CHRPATH given FILE \"" << file << "\" that does not exist.";
+ this->SetError(e.str().c_str());
return false;
}
std::string emsg;
- if(cmSystemTools::ChangeRPath(args[1], args[2], &emsg))
+ if(cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg))
{
return true;
}
else
{
cmOStringStream e;
- e << "CHRPATH could not write new RPATH to the file: "
+ e << "CHRPATH could not write new RPATH \""
+ << newRPath << "\" to the file \"" << file << "\": "
<< emsg;
this->SetError(e.str().c_str());
return false;