summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-03-07 21:35:53 (GMT)
committerBrad King <brad.king@kitware.com>2007-03-07 21:35:53 (GMT)
commitad4055f3e201189112fd10bb02ef2ca237815cd9 (patch)
treef54e489ce5971dc6a51ea85fc511986b17db273d
parent073076e0f7785428f9a211dec76e4eaa304ad3b5 (diff)
downloadCMake-ad4055f3e201189112fd10bb02ef2ca237815cd9.zip
CMake-ad4055f3e201189112fd10bb02ef2ca237815cd9.tar.gz
CMake-ad4055f3e201189112fd10bb02ef2ca237815cd9.tar.bz2
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.
-rw-r--r--Source/cmLocalGenerator.cxx49
1 files changed, 44 insertions, 5 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 46266ac..3b6e93c 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2086,19 +2086,58 @@ std::string cmLocalGenerator::Convert(const char* source,
//----------------------------------------------------------------------------
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 = "";
}
}