cmGlobalGenerator: Add NVI wrapper to create local generator.

This commit is contained in:
Stephen Kelly 2015-05-16 05:18:25 +02:00
parent 2e4ea0c055
commit b659d161da
14 changed files with 26 additions and 18 deletions

View File

@ -715,7 +715,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.SetProgressCallback(cmCPackGeneratorProgress, this); cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg; cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();
std::string realInstallDirectory = tempInstallDirectory; std::string realInstallDirectory = tempInstallDirectory;
if ( !installSubDirectory.empty() && installSubDirectory != "/" ) if ( !installSubDirectory.empty() && installSubDirectory != "/" )

View File

@ -201,7 +201,7 @@ int main (int argc, char const* const* argv)
cminst.GetState()->RemoveUnscriptableCommands(); cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg; cmGlobalGenerator cmgg;
cmgg.SetCMakeInstance(&cminst); cmgg.SetCMakeInstance(&cminst);
cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.MakeLocalGenerator());
cmMakefile* globalMF = cmlg->GetMakefile(); cmMakefile* globalMF = cmlg->GetMakefile();
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");

View File

@ -752,7 +752,7 @@ void cmCTestLaunch::LoadConfig()
cmake cm; cmake cm;
cmGlobalGenerator gg; cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile* mf = lg->GetMakefile(); cmMakefile* mf = lg->GetMakefile();
std::string fname = this->LogDir; std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake"; fname += "CTestLaunchConfig.cmake";

View File

@ -340,7 +340,7 @@ void cmCTestScriptHandler::CreateCMake()
this->GlobalGenerator = new cmGlobalGenerator; this->GlobalGenerator = new cmGlobalGenerator;
this->GlobalGenerator->SetCMakeInstance(this->CMake); this->GlobalGenerator->SetCMakeInstance(this->CMake);
this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(); this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator();
this->Makefile = this->LocalGenerator->GetMakefile(); this->Makefile = this->LocalGenerator->GetMakefile();
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);

View File

@ -1573,7 +1573,7 @@ void cmCTestTestHandler::GetListOfTests()
cmake cm; cmake cm;
cmGlobalGenerator gg; cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();
mf->AddDefinition("CTEST_CONFIGURATION_TYPE", mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
this->CTest->GetConfigType().c_str()); this->CTest->GetConfigType().c_str());

View File

@ -512,7 +512,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cmake cm; cmake cm;
cmGlobalGenerator gg; cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();
if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) )
{ {

View File

@ -1099,7 +1099,7 @@ void cmGlobalGenerator::Configure()
this->ClearGeneratorMembers(); this->ClearGeneratorMembers();
// start with this directory // start with this directory
cmLocalGenerator *lg = this->CreateLocalGenerator(); cmLocalGenerator *lg = this->MakeLocalGenerator();
this->LocalGenerators.push_back(lg); this->LocalGenerators.push_back(lg);
// set the Start directories // set the Start directories
@ -1881,6 +1881,12 @@ void cmGlobalGenerator::EnableInstallTarget()
this->InstallTargetEnabled = true; this->InstallTargetEnabled = true;
} }
cmLocalGenerator *
cmGlobalGenerator::MakeLocalGenerator(cmLocalGenerator *parent)
{
return this->CreateLocalGenerator(parent);
}
cmLocalGenerator * cmLocalGenerator *
cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator *parent) cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator *parent)
{ {

View File

@ -52,8 +52,7 @@ public:
cmGlobalGenerator(); cmGlobalGenerator();
virtual ~cmGlobalGenerator(); virtual ~cmGlobalGenerator();
///! Create a local generator appropriate to this Global Generator cmLocalGenerator* MakeLocalGenerator(cmLocalGenerator* parent = 0);
virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent = 0);
///! Get the name for this generator ///! Get the name for this generator
virtual std::string GetName() const { return "Generic"; } virtual std::string GetName() const { return "Generic"; }
@ -442,6 +441,9 @@ protected:
virtual bool UseFolderProperty(); virtual bool UseFolderProperty();
private: private:
///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent);
cmMakefile* TryCompileOuterMakefile; cmMakefile* TryCompileOuterMakefile;
float FirstTimeProgress; float FirstTimeProgress;
// If you add a new map here, make sure it is copied // If you add a new map here, make sure it is copied

View File

@ -580,7 +580,7 @@ void cmGlobalUnixMakefileGenerator3
else else
{ {
lg = static_cast<cmLocalUnixMakefileGenerator3 *> lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->CreateLocalGenerator()); (this->MakeLocalGenerator());
// set the Start directories // set the Start directories
lg->GetMakefile()->SetCurrentSourceDirectory lg->GetMakefile()->SetCurrentSourceDirectory
(this->CMakeInstance->GetHomeDirectory()); (this->CMakeInstance->GetHomeDirectory());

View File

@ -67,7 +67,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
cmake cm; cmake cm;
cmGlobalGenerator ggi; cmGlobalGenerator ggi;
ggi.SetCMakeInstance(&cm); ggi.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(ggi.MakeLocalGenerator());
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();
const char* inFileName = settingsFileName; const char* inFileName = settingsFileName;

View File

@ -1706,7 +1706,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
// create a new local generator and set its parent // create a new local generator and set its parent
cmLocalGenerator *lg2 = this->GetGlobalGenerator() cmLocalGenerator *lg2 = this->GetGlobalGenerator()
->CreateLocalGenerator(this->LocalGenerator); ->MakeLocalGenerator(this->LocalGenerator);
this->GetGlobalGenerator()->AddLocalGenerator(lg2); this->GetGlobalGenerator()->AddLocalGenerator(lg2);
// set the subdirs start dirs // set the subdirs start dirs

View File

@ -1212,7 +1212,7 @@ static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
cm->SetHomeOutputDirectory(targetDirectory); cm->SetHomeOutputDirectory(targetDirectory);
cm->SetHomeDirectory(targetDirectory); cm->SetHomeDirectory(targetDirectory);
cmLocalGenerator* lg = gg->CreateLocalGenerator(); cmLocalGenerator* lg = gg->MakeLocalGenerator();
lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
gg->SetCurrentLocalGenerator(lg); gg->SetCurrentLocalGenerator(lg);

View File

@ -376,7 +376,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
std::string homeOutputDir = this->GetHomeOutputDirectory(); std::string homeOutputDir = this->GetHomeOutputDirectory();
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator());
lg->GetMakefile()->SetCurrentBinaryDirectory lg->GetMakefile()->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory()); (cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetCurrentSourceDirectory lg->GetMakefile()->SetCurrentSourceDirectory
@ -418,7 +418,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
this->SetGlobalGenerator(gg); this->SetGlobalGenerator(gg);
// read in the list file to fill the cache // read in the list file to fill the cache
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator());
cmMakefile* mf = lg->GetMakefile(); cmMakefile* mf = lg->GetMakefile();
mf->SetCurrentBinaryDirectory mf->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory()); (cmSystemTools::GetCurrentWorkingDirectory());
@ -1927,7 +1927,7 @@ int cmake::CheckBuildSystem()
cmake cm; cmake cm;
cmGlobalGenerator gg; cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
cmMakefile* mf = lg->GetMakefile(); cmMakefile* mf = lg->GetMakefile();
if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
cmSystemTools::GetErrorOccuredFlag()) cmSystemTools::GetErrorOccuredFlag())
@ -1957,7 +1957,7 @@ int cmake::CheckBuildSystem()
ggd(this->CreateGlobalGenerator(genName)); ggd(this->CreateGlobalGenerator(genName));
if(ggd.get()) if(ggd.get())
{ {
cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator());
lgd->ClearDependencies(mf, verbose); lgd->ClearDependencies(mf, verbose);
} }
} }

View File

@ -646,7 +646,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen))
{ {
cm.SetGlobalGenerator(ggd); cm.SetGlobalGenerator(ggd);
cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator());
lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);