cmLocalGenerator: Convert two recursive methods to loops.
This commit is contained in:
parent
c5cb3a734d
commit
e7f7c2e208
|
@ -2853,41 +2853,71 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote,
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmLocalGenerator::FindRelativePathTopSource()
|
std::string cmLocalGenerator::FindRelativePathTopSource()
|
||||||
{
|
{
|
||||||
// Relative path conversion within a single tree managed by CMake is
|
cmLocalGenerator* gen = this;
|
||||||
// safe. We can use our parent relative path top if and only if
|
std::vector<cmLocalGenerator*> gens;
|
||||||
// this is a subdirectory of that top.
|
gens.push_back(gen);
|
||||||
if(cmLocalGenerator* parent = this->GetParent())
|
while (true)
|
||||||
{
|
{
|
||||||
std::string parentTop = parent->FindRelativePathTopSource();
|
gen = gen->GetParent();
|
||||||
if(cmSystemTools::IsSubDirectory(
|
if (gen)
|
||||||
this->StateSnapshot.GetCurrentSourceDirectory(), parentTop))
|
|
||||||
{
|
{
|
||||||
return parentTop;
|
gens.push_back(gen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise this directory itself is the new top.
|
std::string result = gens.front()->StateSnapshot.GetCurrentSourceDirectory();
|
||||||
return this->StateSnapshot.GetCurrentSourceDirectory();
|
|
||||||
|
for (std::vector<cmLocalGenerator*>::const_iterator it = gens.begin() + 1;
|
||||||
|
it != gens.end(); ++it)
|
||||||
|
{
|
||||||
|
std::string currentSource =
|
||||||
|
(*it)->StateSnapshot.GetCurrentSourceDirectory();
|
||||||
|
if(cmSystemTools::IsSubDirectory(result, currentSource))
|
||||||
|
{
|
||||||
|
result = currentSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmLocalGenerator::FindRelativePathTopBinary()
|
std::string cmLocalGenerator::FindRelativePathTopBinary()
|
||||||
{
|
{
|
||||||
// Relative path conversion within a single tree managed by CMake is
|
cmLocalGenerator* gen = this;
|
||||||
// safe. We can use our parent relative path top if and only if
|
std::vector<cmLocalGenerator*> gens;
|
||||||
// this is a subdirectory of that top.
|
gens.push_back(gen);
|
||||||
if(cmLocalGenerator* parent = this->GetParent())
|
while (true)
|
||||||
{
|
{
|
||||||
std::string parentTop = parent->FindRelativePathTopBinary();
|
gen = gen->GetParent();
|
||||||
if(cmSystemTools::IsSubDirectory(
|
if (gen)
|
||||||
this->StateSnapshot.GetCurrentBinaryDirectory(), parentTop))
|
|
||||||
{
|
{
|
||||||
return parentTop;
|
gens.push_back(gen);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise this directory itself is the new top.
|
std::string result = gens.front()->StateSnapshot.GetCurrentBinaryDirectory();
|
||||||
return this->StateSnapshot.GetCurrentBinaryDirectory();
|
|
||||||
|
for (std::vector<cmLocalGenerator*>::const_iterator it = gens.begin() + 1;
|
||||||
|
it != gens.end(); ++it)
|
||||||
|
{
|
||||||
|
std::string currentBinary =
|
||||||
|
(*it)->StateSnapshot.GetCurrentBinaryDirectory();
|
||||||
|
if(cmSystemTools::IsSubDirectory(result, currentBinary))
|
||||||
|
{
|
||||||
|
result = currentBinary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue