Przeglądaj źródła

ENH: Inform user when RPATH or RUNPATH is removed

Brad King 17 lat temu
rodzic
commit
8063dd293e
3 zmienionych plików z 27 dodań i 5 usunięć
  1. 14 3
      Source/cmFileCommand.cxx
  2. 11 1
      Source/cmSystemTools.cxx
  3. 2 1
      Source/cmSystemTools.h

+ 14 - 3
Source/cmFileCommand.cxx

@@ -1486,7 +1486,8 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
   cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew();
   bool have_ft = cmSystemTools::FileTimeGet(file, ft);
   std::string emsg;
-  if(!cmSystemTools::RemoveRPath(file, &emsg))
+  bool removed;
+  if(!cmSystemTools::RemoveRPath(file, &emsg, &removed))
     {
     cmOStringStream e;
     e << "RPATH_REMOVE could not remove RPATH from file:\n"
@@ -1495,9 +1496,19 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
     this->SetError(e.str().c_str());
     success = false;
     }
-  if(success && have_ft)
+  if(success)
     {
-    cmSystemTools::FileTimeSet(file, ft);
+    if(removed)
+      {
+      std::string message = "Removed runtime path from \"";
+      message += file;
+      message += "\"";
+      this->Makefile->DisplayStatus(message.c_str(), -1);
+      }
+    if(have_ft)
+      {
+      cmSystemTools::FileTimeSet(file, ft);
+      }
     }
   cmSystemTools::FileTimeDelete(ft);
   return success;

+ 11 - 1
Source/cmSystemTools.cxx

@@ -2525,9 +2525,14 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
 }
 
 //----------------------------------------------------------------------------
-bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg)
+bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
+                                bool* removed)
 {
 #if defined(CMAKE_USE_ELF_PARSER)
+  if(removed)
+    {
+    *removed = false;
+    }
   int zeroCount = 0;
   unsigned long zeroPosition[2] = {0,0};
   unsigned long zeroSize[2] = {0,0};
@@ -2676,10 +2681,15 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg)
     }
 
   // Everything was updated successfully.
+  if(removed)
+    {
+    *removed = true;
+    }
   return true;
 #else
   (void)file;
   (void)emsg;
+  (void)removed;
   return false;
 #endif
 }

+ 2 - 1
Source/cmSystemTools.h

@@ -396,7 +396,8 @@ public:
                           bool* changed = 0);
 
   /** Try to remove the RPATH from an ELF binary.  */
-  static bool RemoveRPath(std::string const& file, std::string* emsg = 0);
+  static bool RemoveRPath(std::string const& file, std::string* emsg = 0,
+                          bool* removed = 0);
 
   /** Check whether the RPATH in an ELF binary contains the path
       given.  */