[cmake-commits] king committed cmLocalGenerator.cxx 1.193 1.194
cmLocalGenerator.h 1.74 1.75
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Mar 7 17:32:37 EST 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv20598
Modified Files:
cmLocalGenerator.cxx cmLocalGenerator.h
Log Message:
ENH: Improved computation of RelativePathTopSource and RelativePathTopBinary to use higher relative path tops when the source directories jump around in a tree below the original source top.
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -d -r1.193 -r1.194
--- cmLocalGenerator.cxx 7 Mar 2007 21:35:53 -0000 1.193
+++ cmLocalGenerator.cxx 7 Mar 2007 22:32:35 -0000 1.194
@@ -2084,54 +2084,58 @@
}
//----------------------------------------------------------------------------
-void cmLocalGenerator::ConfigureRelativePaths()
+std::string cmLocalGenerator::FindRelativePathTopSource()
{
- // 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())
+ // Relative path conversion within a single tree managed by CMake is
+ // safe. We can use our parent relative path top if and only if
+ // this is a subdirectory of that top.
+ if(cmLocalGenerator* parent = this->GetParent())
{
+ std::string parentTop = parent->FindRelativePathTopSource();
if(cmSystemTools::IsSubDirectory(
- this->Makefile->GetStartDirectory(),
- next->Makefile->GetStartDirectory()))
- {
- srcTop = next;
- }
- else
+ this->Makefile->GetStartDirectory(), parentTop.c_str()))
{
- break;
+ return parentTop;
}
}
- // 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;
+ // Otherwise this directory itself is the new top.
+ return this->Makefile->GetStartDirectory();
+}
- // 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())
+//----------------------------------------------------------------------------
+std::string cmLocalGenerator::FindRelativePathTopBinary()
+{
+ // Relative path conversion within a single tree managed by CMake is
+ // safe. We can use our parent relative path top if and only if
+ // this is a subdirectory of that top.
+ if(cmLocalGenerator* parent = this->GetParent())
{
+ std::string parentTop = parent->FindRelativePathTopBinary();
if(cmSystemTools::IsSubDirectory(
- this->Makefile->GetStartOutputDirectory(),
- next->Makefile->GetStartOutputDirectory()))
- {
- binTop = next;
- }
- else
+ this->Makefile->GetStartOutputDirectory(), parentTop.c_str()))
{
- break;
+ return parentTop;
}
}
+ // Otherwise this directory itself is the new top.
+ return this->Makefile->GetStartOutputDirectory();
+}
+
+//----------------------------------------------------------------------------
+void cmLocalGenerator::ConfigureRelativePaths()
+{
+ // 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 = this->FindRelativePathTopSource();
+ this->RelativePathTopSource = source;
+
// The current working directory on Windows cannot be a network
// path. Therefore relative paths cannot work when the binary tree
// is a network path.
- std::string binary = binTop->Makefile->GetStartOutputDirectory();
+ std::string binary = this->FindRelativePathTopBinary();
if(binary.size() < 2 || binary.substr(0, 2) != "//")
{
this->RelativePathTopBinary = binary;
Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- cmLocalGenerator.h 7 Mar 2007 21:32:29 -0000 1.74
+++ cmLocalGenerator.h 7 Mar 2007 22:32:35 -0000 1.75
@@ -277,6 +277,8 @@
std::string& CreateSafeUniqueObjectFileName(const char* sin);
void ConfigureRelativePaths();
+ std::string FindRelativePathTopSource();
+ std::string FindRelativePathTopBinary();
cmMakefile *Makefile;
cmGlobalGenerator *GlobalGenerator;
More information about the Cmake-commits
mailing list