BUG: Changing to a new test for whether to do relative path conversion. Now only paths inside the source or binary trees are converted.
This commit is contained in:
parent
26f82b064c
commit
7ed018ec09
@ -889,36 +889,20 @@ cmTarget* cmGlobalGenerator::FindTarget(const char* project,
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalGenerator::ConfigureRelativePaths()
|
void cmGlobalGenerator::ConfigureRelativePaths()
|
||||||
{
|
{
|
||||||
// Identify the longest shared path component between the source
|
// The current working directory on Windows cannot be a network
|
||||||
// directory and the build directory.
|
// path. Therefore relative paths cannot work when the build tree
|
||||||
std::vector<std::string> source;
|
// is a network path.
|
||||||
std::vector<std::string> binary;
|
std::string source = m_CMakeInstance->GetHomeDirectory();
|
||||||
cmSystemTools::SplitPath(m_CMakeInstance->GetHomeDirectory(), source);
|
std::string binary = m_CMakeInstance->GetHomeOutputDirectory();
|
||||||
cmSystemTools::SplitPath(m_CMakeInstance->GetHomeOutputDirectory(), binary);
|
if(binary.size() < 2 || binary.substr(0, 2) != "//")
|
||||||
unsigned int common=0;
|
|
||||||
while(common < source.size() && common < binary.size() &&
|
|
||||||
cmSystemTools::ComparePath(source[common].c_str(),
|
|
||||||
binary[common].c_str()))
|
|
||||||
{
|
{
|
||||||
++common;
|
m_RelativePathTopSource = source;
|
||||||
}
|
m_RelativePathTopBinary = binary;
|
||||||
|
|
||||||
// Require more than just the root portion of the path to be in
|
|
||||||
// common before allowing relative paths. Also disallow relative
|
|
||||||
// paths if the build tree is a network path. The current working
|
|
||||||
// directory on Windows cannot be a network path. Therefore
|
|
||||||
// relative paths cannot work with network paths.
|
|
||||||
if(common > 1 && source[0] != "//")
|
|
||||||
{
|
|
||||||
// Build the minimum prefix required of a path to be converted to
|
|
||||||
// a relative path.
|
|
||||||
source.erase(source.begin()+common, source.end());
|
|
||||||
m_RelativePathTop = cmSystemTools::JoinPath(source);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Disable relative paths.
|
m_RelativePathTopSource = "";
|
||||||
m_RelativePathTop = "";
|
m_RelativePathTopBinary = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -939,13 +923,16 @@ cmGlobalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
|
|||||||
return in_remote;
|
return in_remote;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the path does not contain all of the relative top path then return
|
// Skip conversion if the path is not in the source or binary tree.
|
||||||
// because it is going too far out of the tree
|
|
||||||
std::string original = in_remote;
|
std::string original = in_remote;
|
||||||
if(original.size() < m_RelativePathTop.size() ||
|
if((original.size() < m_RelativePathTopSource.size() ||
|
||||||
!cmSystemTools::ComparePath(
|
!cmSystemTools::ComparePath(
|
||||||
original.substr(0, m_RelativePathTop.size()).c_str(),
|
original.substr(0, m_RelativePathTopSource.size()).c_str(),
|
||||||
m_RelativePathTop.c_str()))
|
m_RelativePathTopSource.c_str())) &&
|
||||||
|
(original.size() < m_RelativePathTopBinary.size() ||
|
||||||
|
!cmSystemTools::ComparePath(
|
||||||
|
original.substr(0, m_RelativePathTopBinary.size()).c_str(),
|
||||||
|
m_RelativePathTopBinary.c_str())))
|
||||||
{
|
{
|
||||||
return in_remote;
|
return in_remote;
|
||||||
}
|
}
|
||||||
@ -963,8 +950,8 @@ cmGlobalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
|
|||||||
++common;
|
++common;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if nothiong is in common the return
|
// If no part of the path is in common then return the full path.
|
||||||
if (common == 0)
|
if(common == 0)
|
||||||
{
|
{
|
||||||
return in_remote;
|
return in_remote;
|
||||||
}
|
}
|
||||||
|
@ -171,10 +171,13 @@ private:
|
|||||||
std::map<cmStdString, cmStdString> m_ExtensionToLanguage;
|
std::map<cmStdString, cmStdString> m_ExtensionToLanguage;
|
||||||
std::map<cmStdString, cmStdString> m_LanguageToLinkerPreference;
|
std::map<cmStdString, cmStdString> m_LanguageToLinkerPreference;
|
||||||
|
|
||||||
// The prefix required of a path to be converted to a relative path.
|
// The paths to the tops of the source and binary trees used for
|
||||||
// No sequence of ../.. will ever go past this path. This is the
|
// relative path computation. A path must be either in the source
|
||||||
// longest common path between the top level source and build trees.
|
// tree or the build tree to be converted to a relative path. The
|
||||||
std::string m_RelativePathTop;
|
// ConfigureRelativePaths method may set these to be empty when
|
||||||
|
// using relative paths is unsafe.
|
||||||
|
std::string m_RelativePathTopSource;
|
||||||
|
std::string m_RelativePathTopBinary;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user