Commit 3fe5f8d9 authored by Brad King's avatar Brad King
Browse files

Optionally force conversion to relative path

In cmLocalGenerator::ConvertToRelativePath we normally convert to
relative path only if the local and remote paths both lie inside the
source tree or both lie inside the build tree.  This commit adds an
optional 'force' argument to allow conversion even when this rule is
violated.
parent 25cf2f43
......@@ -2303,7 +2303,7 @@ static bool cmLocalGeneratorNotAbove(const char* a, const char* b)
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
const char* in_remote)
const char* in_remote, bool force)
{
// The path should never be quoted.
assert(in_remote[0] != '\"');
......@@ -2324,19 +2324,22 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
this->RelativePathsConfigured = true;
}
// 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);
if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
this->RelativePathTopBinary.c_str()) &&
cmLocalGeneratorNotAbove(in_remote,
this->RelativePathTopBinary.c_str())) ||
(cmLocalGeneratorNotAbove(local_path.c_str(),
this->RelativePathTopSource.c_str()) &&
cmLocalGeneratorNotAbove(in_remote,
this->RelativePathTopSource.c_str()))))
if(!force)
{
return in_remote;
// 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);
if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
this->RelativePathTopBinary.c_str()) &&
cmLocalGeneratorNotAbove(in_remote,
this->RelativePathTopBinary.c_str())) ||
(cmLocalGeneratorNotAbove(local_path.c_str(),
this->RelativePathTopSource.c_str()) &&
cmLocalGeneratorNotAbove(in_remote,
this->RelativePathTopSource.c_str()))))
{
return in_remote;
}
}
// Identify the longest shared path component between the remote
......
......@@ -260,7 +260,7 @@ public:
* or quoted.
*/
std::string ConvertToRelativePath(const std::vector<std::string>& local,
const char* remote);
const char* remote, bool force=false);
/**
* Get the relative path from the generator output directory to a
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment