cmMakefile: Move Configure responsibility from cmLocalGenerator.

The generator should only have a function at generate time.
This commit is contained in:
Stephen Kelly 2015-05-30 19:50:58 +02:00 committed by Brad King
parent a653611db0
commit f059ed165b
5 changed files with 62 additions and 83 deletions

View File

@ -1106,7 +1106,7 @@ void cmGlobalGenerator::Configure()
this->CMakeInstance->GetHomeOutputDirectory()); this->CMakeInstance->GetHomeOutputDirectory());
// now do it // now do it
lg->Configure(); lg->GetMakefile()->Configure();
// update the cache entry for the number of local generators, this is used // update the cache entry for the number of local generators, this is used
// for progress // for progress

View File

@ -74,68 +74,6 @@ bool cmLocalGenerator::IsRootMakefile() const
return !this->StateSnapshot.GetParent().IsValid(); return !this->StateSnapshot.GetParent().IsValid();
} }
//----------------------------------------------------------------------------
class cmLocalGeneratorCurrent
{
cmGlobalGenerator* GG;
cmMakefile* MF;
cmState::Snapshot Snapshot;
public:
cmLocalGeneratorCurrent(cmMakefile* mf)
{
this->GG = mf->GetGlobalGenerator();
this->MF = this->GG->GetCurrentMakefile();
this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
this->GG->GetCMakeInstance()->SetCurrentSnapshot(
this->GG->GetCMakeInstance()->GetCurrentSnapshot());
this->GG->SetCurrentMakefile(mf);
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PushFileScope();
#endif
}
~cmLocalGeneratorCurrent()
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PopFileScope();
#endif
this->GG->SetCurrentMakefile(this->MF);
this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
}
};
//----------------------------------------------------------------------------
void cmLocalGenerator::Configure()
{
// Manage the global generator's current local generator.
cmLocalGeneratorCurrent clg(this->GetMakefile());
static_cast<void>(clg);
// make sure the CMakeFiles dir is there
std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory();
filesDir += cmake::GetCMakeFilesDirectory();
cmSystemTools::MakeDirectory(filesDir.c_str());
std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory();
currentStart += "/CMakeLists.txt";
assert(cmSystemTools::FileExists(currentStart.c_str(), true));
this->Makefile->ProcessBuildsystemFile(currentStart.c_str());
// at the end handle any old style subdirs
std::vector<cmLocalGenerator *> subdirs =
this->GetMakefile()->GetUnConfiguredDirectories();
// for each subdir recurse
std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
for (; sdi != subdirs.end(); ++sdi)
{
this->Makefile->ConfigureSubDirectory(*sdi);
}
this->Makefile->AddCMakeDependFilesFromUser();
this->Makefile->SetConfigured();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalGenerator::ComputeObjectMaxPath() void cmLocalGenerator::ComputeObjectMaxPath()
{ {

View File

@ -46,12 +46,6 @@ public:
*/ */
virtual void Generate() {} virtual void Generate() {}
/**
* Process the CMakeLists files for this directory to fill in the
* Makefile ivar
*/
void Configure();
/** /**
* Calls TraceVSDependencies() on all targets of this generator. * Calls TraceVSDependencies() on all targets of this generator.
*/ */

View File

@ -1553,6 +1553,64 @@ void cmMakefile::InitializeFromParent()
this->ImportedTargets = parent->ImportedTargets; this->ImportedTargets = parent->ImportedTargets;
} }
//----------------------------------------------------------------------------
class cmMakefileCurrent
{
cmGlobalGenerator* GG;
cmMakefile* MF;
cmState::Snapshot Snapshot;
public:
cmMakefileCurrent(cmMakefile* mf)
{
this->GG = mf->GetGlobalGenerator();
this->MF = this->GG->GetCurrentMakefile();
this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
this->GG->GetCMakeInstance()->SetCurrentSnapshot(
this->GG->GetCMakeInstance()->GetCurrentSnapshot());
this->GG->SetCurrentMakefile(mf);
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PushFileScope();
#endif
}
~cmMakefileCurrent()
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->GG->GetFileLockPool().PopFileScope();
#endif
this->GG->SetCurrentMakefile(this->MF);
this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
}
};
//----------------------------------------------------------------------------
void cmMakefile::Configure()
{
cmMakefileCurrent cmf(this);
// make sure the CMakeFiles dir is there
std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory();
filesDir += cmake::GetCMakeFilesDirectory();
cmSystemTools::MakeDirectory(filesDir.c_str());
std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory();
currentStart += "/CMakeLists.txt";
assert(cmSystemTools::FileExists(currentStart.c_str(), true));
this->ProcessBuildsystemFile(currentStart.c_str());
// at the end handle any old style subdirs
std::vector<cmLocalGenerator*> subdirs = this->UnConfiguredDirectories;
// for each subdir recurse
std::vector<cmLocalGenerator*>::iterator sdi = subdirs.begin();
for (; sdi != subdirs.end(); ++sdi)
{
this->ConfigureSubDirectory(*sdi);
}
this->AddCMakeDependFilesFromUser();
this->SetConfigured();
}
void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
{ {
lg2->GetMakefile()->InitializeFromParent(); lg2->GetMakefile()->InitializeFromParent();
@ -1598,15 +1656,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
return; return;
} }
// finally configure the subdir // finally configure the subdir
lg2->Configure(); lg2->GetMakefile()->Configure();
// at the end handle any old style subdirs
for (std::vector<cmLocalGenerator *>::iterator sdi =
this->UnConfiguredDirectories.begin();
sdi != this->UnConfiguredDirectories.end(); ++sdi)
{
this->ConfigureSubDirectory(*sdi);
}
if (this->GetCMakeInstance()->GetDebugOutput()) if (this->GetCMakeInstance()->GetDebugOutput())
{ {

View File

@ -262,11 +262,6 @@ public:
this->LinkDirectories = vec; this->LinkDirectories = vec;
} }
std::vector<cmLocalGenerator*> GetUnConfiguredDirectories() const
{
return this->UnConfiguredDirectories;
}
/** /**
* Add a subdirectory to the build. * Add a subdirectory to the build.
*/ */
@ -275,6 +270,8 @@ public:
bool excludeFromAll, bool excludeFromAll,
bool immediate); bool immediate);
void Configure();
/** /**
* Configure a subdirectory * Configure a subdirectory
*/ */