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

View File

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

View File

@ -256,6 +256,7 @@ public:
that is a framework. */ that is a framework. */
bool NameResolvesToFramework(const std::string& libname) const; bool NameResolvesToFramework(const std::string& libname) const;
cmMakefile* FindMakefile(const std::string& start_dir) const;
///! Find a local generator by its startdirectory ///! Find a local generator by its startdirectory
cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const; 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. // The local generators are associated with collapsed paths.
dir = cmSystemTools::CollapseFullPath(dir); dir = cmSystemTools::CollapseFullPath(dir);
// Lookup the generator. mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
if(cmLocalGenerator* lg = if (!mf)
this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir))
{
// Use the makefile for the directory found.
mf = lg->GetMakefile();
}
else
{ {
// Could not find the directory. // Could not find the directory.
this->SetError this->SetError