Merge topic 'clean-up-cmQtAutoGenerators'

a5b59fae QtAutogen: Create global generator on the stack.
fe401ede QtAutogen: Use a more-obvious delete-target.
c95a55ad QtAutogen: Remove the need for a local makefile variable.
460e8fb9 QtAutogen: Inline static factory method.
58f41c78 QtAutogen: Remove repeated setters.
This commit is contained in:
Brad King 2015-05-21 09:03:46 -04:00 committed by CMake Topic Stage
commit e604bb1be9

View File

@ -1203,23 +1203,6 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target)
return std::string(); return std::string();
} }
static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
const std::string& targetDirectory)
{
cmGlobalGenerator* gg = new cmGlobalGenerator();
gg->SetCMakeInstance(cm);
cm->SetHomeOutputDirectory(targetDirectory);
cm->SetHomeDirectory(targetDirectory);
cmLocalGenerator* lg = gg->MakeLocalGenerator();
lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
gg->SetCurrentLocalGenerator(lg);
return gg;
}
bool cmQtAutoGenerators::Run(const std::string& targetDirectory, bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
const std::string& config) const std::string& config)
{ {
@ -1227,25 +1210,27 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
cmake cm; cmake cm;
cm.SetHomeOutputDirectory(targetDirectory); cm.SetHomeOutputDirectory(targetDirectory);
cm.SetHomeDirectory(targetDirectory); cm.SetHomeDirectory(targetDirectory);
cmGlobalGenerator* gg = CreateGlobalGenerator(&cm, targetDirectory); cmGlobalGenerator gg;
cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); gg.SetCMakeInstance(&cm);
this->ReadAutogenInfoFile(makefile, targetDirectory, config); cmLocalGenerator* lg = gg.MakeLocalGenerator();
this->ReadOldMocDefinitionsFile(makefile, targetDirectory); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
gg.SetCurrentLocalGenerator(lg);
this->ReadAutogenInfoFile(lg->GetMakefile(), targetDirectory, config);
this->ReadOldMocDefinitionsFile(lg->GetMakefile(), targetDirectory);
this->Init(); this->Init();
if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
{ {
success = this->RunAutogen(makefile); success = this->RunAutogen(lg->GetMakefile());
} }
this->WriteOldMocDefinitionsFile(targetDirectory); this->WriteOldMocDefinitionsFile(targetDirectory);
delete gg->GetCurrentLocalGenerator(); delete lg;
delete gg;
gg = NULL;
makefile = NULL;
return success; return success;
} }