cmGlobalGenerator: Port Find API to cmMakefile.

This commit is contained in:
Stephen Kelly 2015-08-02 12:39:51 +02:00
parent c5b8841fd9
commit 5f66900e71
5 changed files with 21 additions and 20 deletions

View File

@ -51,10 +51,8 @@ bool cmGetDirectoryPropertyCommand
sd = cmSystemTools::CollapseFullPath(sd);
// lookup the makefile from the directory name
cmLocalGenerator *lg =
this->Makefile->GetGlobalGenerator()->
FindLocalGenerator(sd);
if (!lg)
dir = this->Makefile->GetGlobalGenerator()->FindMakefile(sd);
if (!dir)
{
this->SetError
("DIRECTORY argument provided but requested directory not found. "
@ -62,7 +60,6 @@ bool cmGetDirectoryPropertyCommand
"it is valid but has not been processed yet.");
return false;
}
dir = lg->GetMakefile();
++i;
}

View File

@ -262,13 +262,8 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
dir = cmSystemTools::CollapseFullPath(dir);
// Lookup the generator.
if(cmLocalGenerator* lg =
(this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir)))
{
// Use the makefile for the directory found.
mf = lg->GetMakefile();
}
else
mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
if (!mf)
{
// Could not find the directory.
this->SetError

View File

@ -2160,6 +2160,20 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
}
}
cmMakefile*
cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
{
for(std::vector<cmMakefile*>::const_iterator it =
this->Makefiles.begin(); it != this->Makefiles.end(); ++it)
{
std::string sd = (*it)->GetCurrentSourceDirectory();
if (sd == start_dir)
{
return *it;
}
}
return 0;
}
///! Find a local generator by its startdirectory
cmLocalGenerator*

View File

@ -256,6 +256,7 @@ public:
that is a framework. */
bool NameResolvesToFramework(const std::string& libname) const;
cmMakefile* FindMakefile(const std::string& start_dir) const;
///! Find a local generator by its startdirectory
cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;

View File

@ -205,14 +205,8 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
// The local generators are associated with collapsed paths.
dir = cmSystemTools::CollapseFullPath(dir);
// Lookup the generator.
if(cmLocalGenerator* lg =
this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir))
{
// Use the makefile for the directory found.
mf = lg->GetMakefile();
}
else
mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
if (!mf)
{
// Could not find the directory.
this->SetError