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

This commit is contained in:
Ken Martin 2006-03-30 09:17:02 -05:00
parent d92205b26d
commit 7b3be313ee
1 changed files with 39 additions and 10 deletions

View File

@ -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;