[cmake-commits] king committed cmLocalGenerator.cxx 1.192 1.193

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Mar 7 16:35:55 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv31948/Source

Modified Files:
	cmLocalGenerator.cxx 
Log Message:
ENH: Set RelativePathTopSource and RelativePathTopBinary independently for each local generator.  Relative path conversion is safe within a tree as long as it does not go above the highest parent directory still managed by CMake.


Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.192
retrieving revision 1.193
diff -u -d -r1.192 -r1.193
--- cmLocalGenerator.cxx	7 Mar 2007 20:30:30 -0000	1.192
+++ cmLocalGenerator.cxx	7 Mar 2007 21:35:53 -0000	1.193
@@ -2086,19 +2086,58 @@
 //----------------------------------------------------------------------------
 void cmLocalGenerator::ConfigureRelativePaths()
 {
+  // Find the highest parent source directory containing the local
+  // source directory.  This is the top of safe relative path
+  // conversion.
+  cmLocalGenerator* srcTop = this;
+  while(cmLocalGenerator* next = srcTop->GetParent())
+    {
+    if(cmSystemTools::IsSubDirectory(
+         this->Makefile->GetStartDirectory(),
+         next->Makefile->GetStartDirectory()))
+      {
+      srcTop = next;
+      }
+    else
+      {
+      break;
+      }
+    }
+
+  // Relative path conversion inside the source tree is not used to
+  // construct relative paths passed to build tools so it is safe to
+  // even when the source is a network path.
+  std::string source = srcTop->Makefile->GetStartDirectory();
+  this->RelativePathTopSource = source;
+
+  // Find the highest parent binary directory containing the local
+  // binary directory.  This is the top of safe relative path
+  // conversion.
+  cmLocalGenerator* binTop = this;
+  while(cmLocalGenerator* next = binTop->GetParent())
+    {
+    if(cmSystemTools::IsSubDirectory(
+         this->Makefile->GetStartOutputDirectory(),
+         next->Makefile->GetStartOutputDirectory()))
+      {
+      binTop = next;
+      }
+    else
+      {
+      break;
+      }
+    }
+
   // The current working directory on Windows cannot be a network
-  // path.  Therefore relative paths cannot work when the build tree
+  // path.  Therefore relative paths cannot work when the binary tree
   // is a network path.
-  std::string source = this->Makefile->GetHomeDirectory();
-  std::string binary = this->Makefile->GetHomeOutputDirectory();
+  std::string binary = binTop->Makefile->GetStartOutputDirectory();
   if(binary.size() < 2 || binary.substr(0, 2) != "//")
     {
-    this->RelativePathTopSource = source;
     this->RelativePathTopBinary = binary;
     }
   else
     {
-    this->RelativePathTopSource = "";
     this->RelativePathTopBinary = "";
     }
 }



More information about the Cmake-commits mailing list