瀏覽代碼

ENH: modified the relative path code to not do relative paths between bin and source

Ken Martin 20 年之前
父節點
當前提交
7b3be313ee
共有 1 個文件被更改,包括 39 次插入10 次删除
  1. 39 10
      Source/cmGlobalGenerator.cxx

+ 39 - 10
Source/cmGlobalGenerator.cxx

@@ -1033,20 +1033,49 @@ cmGlobalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
     return in_remote;
     }
 
-  // Skip conversion if the path is not in the source or binary tree.
   std::string original = in_remote;
-  if((original.size() < this->RelativePathTopSource.size() ||
-      !cmSystemTools::ComparePath(
-        original.substr(0, this->RelativePathTopSource.size()).c_str(),
-        this->RelativePathTopSource.c_str())) &&
-     (original.size() < this->RelativePathTopBinary.size() ||
-      !cmSystemTools::ComparePath(
-        original.substr(0, this->RelativePathTopBinary.size()).c_str(),
-        this->RelativePathTopBinary.c_str())))
+
+  // Skip conversion if the path and local are not both in the source or both
+  // in the binary tree
+  std::string local_path = cmSystemTools::JoinPath(local);
+  bool should_convert = false;
+  
+  // is the root in the binary tree?
+  if (local_path.size() >= this->RelativePathTopBinary.size() &&
+      cmSystemTools::ComparePath
+      (local_path.substr(0, this->RelativePathTopBinary.size()).c_str(),
+       this->RelativePathTopBinary.c_str()))
+    {
+    // is the source also in the binary tree?
+    if (original.size() >= this->RelativePathTopBinary.size() &&
+        cmSystemTools::ComparePath
+        (original.substr(0, this->RelativePathTopBinary.size()).c_str(),
+         this->RelativePathTopBinary.c_str()))
+      {
+      should_convert = true;
+      }
+    }
+  
+  if (local_path.size() >= this->RelativePathTopSource.size() &&
+      cmSystemTools::ComparePath
+      (local_path.substr(0, this->RelativePathTopSource.size()).c_str(),
+       this->RelativePathTopSource.c_str()))
+    {
+    // is the source also in the binary tree?
+    if (original.size() >= this->RelativePathTopSource.size() &&
+        cmSystemTools::ComparePath
+        (original.substr(0, this->RelativePathTopSource.size()).c_str(),
+         this->RelativePathTopSource.c_str()))
+      {
+      should_convert = true;
+      }
+    }
+  
+  if (!should_convert)
     {
     return in_remote;
     }
-
+  
   // Identify the longest shared path component between the remote
   // path and the local path.
   std::vector<std::string> remote;