From 7b3be313ee9997879bc1496bb3801021039d4d5b Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 30 Mar 2006 09:17:02 -0500 Subject: ENH: modified the relative path code to not do relative paths between bin and source --- Source/cmGlobalGenerator.cxx | 49 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 289bf90..55929fe 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1033,20 +1033,49 @@ cmGlobalGenerator::ConvertToRelativePath(const std::vector& 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 remote; -- cgit v0.12