浏览代码

ENH: Teach file(INSTALL) relative paths

This teaches the undocumented file(INSTALL) command to deal with
relative paths.  Relative input file paths are evaluated with respect to
the current source directory.  Relative output file paths are evaluated
with respect to the current binary directory.

While this command is currently used only in cmake_install.cmake scripts
(in -P script mode), this cleans up its interface in preparation for a
documented signature.
Brad King 16 年之前
父节点
当前提交
b6cb117346
共有 1 个文件被更改,包括 19 次插入2 次删除
  1. 19 2
      Source/cmFileCommand.cxx

+ 19 - 2
Source/cmFileCommand.cxx

@@ -1216,10 +1216,27 @@ bool cmFileCopier::CheckValue(std::string const& arg)
   switch(this->Doing)
   switch(this->Doing)
     {
     {
     case DoingFiles:
     case DoingFiles:
-      this->Files.push_back(arg);
+      if(arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str()))
+        {
+        this->Files.push_back(arg);
+        }
+      else
+        {
+        std::string file = this->Makefile->GetCurrentDirectory();
+        file += "/" + arg;
+        this->Files.push_back(file);
+        }
       break;
       break;
     case DoingDestination:
     case DoingDestination:
-      this->Destination = arg;
+      if(arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str()))
+        {
+        this->Destination = arg;
+        }
+      else
+        {
+        this->Destination = this->Makefile->GetCurrentOutputDirectory();
+        this->Destination += "/" + arg;
+        }
       this->Doing = DoingNone;
       this->Doing = DoingNone;
       break;
       break;
     case DoingRegex:
     case DoingRegex: