From 757875df9151eb02e252caa4e4f5ee6522f5a99f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 27 May 2008 10:22:03 -0400 Subject: ENH: Inform user when RPATH is set during installation. - Original patch from Alex. - Modified to print only when RPATH is actually set. --- Source/cmFileCommand.cxx | 19 ++++++++++++++++--- Source/cmSystemTools.cxx | 12 +++++++++++- Source/cmSystemTools.h | 3 ++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index be2bf652f7..6ac6bccaed 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1411,7 +1411,8 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew(); bool have_ft = cmSystemTools::FileTimeGet(file, ft); std::string emsg; - if(!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg)) + bool changed; + if(!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) { cmOStringStream e; e << "RPATH_CHANGE could not write new RPATH:\n" @@ -1422,9 +1423,21 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) this->SetError(e.str().c_str()); success = false; } - if(success && have_ft) + if(success) { - cmSystemTools::FileTimeSet(file, ft); + if(changed) + { + std::string message = "Set runtime path of \""; + message += file; + message += "\" to \""; + message += newRPath; + message += "\""; + this->Makefile->DisplayStatus(message.c_str(), -1); + } + if(have_ft) + { + cmSystemTools::FileTimeSet(file, ft); + } } cmSystemTools::FileTimeDelete(ft); return success; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 4d25944d4a..6da20fb1d8 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2332,9 +2332,14 @@ std::string::size_type cmSystemToolsFindRPath(std::string const& have, bool cmSystemTools::ChangeRPath(std::string const& file, std::string const& oldRPath, std::string const& newRPath, - std::string* emsg) + std::string* emsg, + bool* changed) { #if defined(CMAKE_USE_ELF_PARSER) + if(changed) + { + *changed = false; + } unsigned long rpathPosition = 0; unsigned long rpathSize = 0; std::string rpathPrefix; @@ -2445,6 +2450,10 @@ bool cmSystemTools::ChangeRPath(std::string const& file, // Make sure everything was okay. if(f) { + if(changed) + { + *changed = true; + } return true; } else @@ -2460,6 +2469,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file, (void)oldRPath; (void)newRPath; (void)emsg; + (void)changed; return false; #endif } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 89cf407a2d..77b79839f7 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -391,7 +391,8 @@ public: static bool ChangeRPath(std::string const& file, std::string const& oldRPath, std::string const& newRPath, - std::string* emsg = 0); + std::string* emsg = 0, + bool* changed = 0); /** Try to remove the RPATH from an ELF binary. */ static bool RemoveRPath(std::string const& file, std::string* emsg = 0); -- cgit v1.2.1