cmGlobalGenerator: Require a snapshot to create a local generator.

This commit is contained in:
Stephen Kelly 2015-05-31 01:43:31 +02:00
parent 83b8a927e5
commit acb006229d
12 changed files with 31 additions and 20 deletions

View File

@ -716,7 +716,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.AddCMakePaths(); cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this); cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(
gg.MakeLocalGenerator(cm.GetCurrentSnapshot()));
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

@ -202,7 +202,8 @@ int main (int argc, char const* const* argv)
cminst.SetHomeOutputDirectory(""); cminst.SetHomeOutputDirectory("");
cminst.GetState()->RemoveUnscriptableCommands(); cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg(&cminst); cmGlobalGenerator cmgg(&cminst);
cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> cmlg(
cmgg.MakeLocalGenerator(cminst.GetCurrentSnapshot()));
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

@ -738,7 +738,8 @@ void cmCTestLaunch::LoadConfig()
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(
gg.MakeLocalGenerator(cm.GetCurrentSnapshot()));
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

@ -341,7 +341,8 @@ void cmCTestScriptHandler::CreateCMake()
this->CMake->AddCMakePaths(); this->CMake->AddCMakePaths();
this->GlobalGenerator = new cmGlobalGenerator(this->CMake); this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator(snapshot);
this->Makefile = this->LocalGenerator->GetMakefile(); this->Makefile = this->LocalGenerator->GetMakefile();
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);

View File

@ -1592,7 +1592,8 @@ void cmCTestTestHandler::GetListOfTests()
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(
gg.MakeLocalGenerator(cm.GetCurrentSnapshot()));
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

@ -520,7 +520,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(
gg.MakeLocalGenerator(cm.GetCurrentSnapshot()));
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

@ -1128,7 +1128,8 @@ void cmGlobalGenerator::Configure()
this->ClearGeneratorMembers(); this->ClearGeneratorMembers();
// start with this directory // start with this directory
cmLocalGenerator *lg = this->MakeLocalGenerator(); cmLocalGenerator *lg = this->MakeLocalGenerator(
this->GetCMakeInstance()->GetCurrentSnapshot());
this->Makefiles.push_back(lg->GetMakefile()); this->Makefiles.push_back(lg->GetMakefile());
this->LocalGenerators.push_back(lg); this->LocalGenerators.push_back(lg);
@ -1988,11 +1989,6 @@ void cmGlobalGenerator::EnableInstallTarget()
cmLocalGenerator * cmLocalGenerator *
cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot) cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot)
{ {
if (!snapshot.IsValid())
{
snapshot = this->CMakeInstance->GetCurrentSnapshot();
}
return this->CreateLocalGenerator(snapshot); return this->CreateLocalGenerator(snapshot);
} }

View File

@ -585,8 +585,9 @@ void cmGlobalUnixMakefileGenerator3
} }
else else
{ {
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
lg = static_cast<cmLocalUnixMakefileGenerator3 *> lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->MakeLocalGenerator()); (this->MakeLocalGenerator(snapshot));
// set the Start directories // set the Start directories
lg->GetMakefile()->SetCurrentSourceDirectory lg->GetMakefile()->SetCurrentSourceDirectory
(this->CMakeInstance->GetHomeDirectory()); (this->CMakeInstance->GetHomeDirectory());

View File

@ -68,7 +68,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator ggi(&cm); cmGlobalGenerator ggi(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(ggi.MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(
ggi.MakeLocalGenerator(cm.GetCurrentSnapshot()));
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();
const char* inFileName = settingsFileName; const char* inFileName = settingsFileName;

View File

@ -1217,7 +1217,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
cm.SetHomeDirectory(targetDirectory); cm.SetHomeDirectory(targetDirectory);
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmLocalGenerator* lg = gg.MakeLocalGenerator(); cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
cmLocalGenerator* lg = gg.MakeLocalGenerator(snapshot);
lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
gg.SetCurrentMakefile(lg->GetMakefile()); gg.SetCurrentMakefile(lg->GetMakefile());

View File

@ -429,7 +429,8 @@ 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->MakeLocalGenerator()); cmState::Snapshot snapshot = this->GetCurrentSnapshot();
cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator(snapshot));
lg->GetMakefile()->SetCurrentBinaryDirectory lg->GetMakefile()->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory()); (cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetCurrentSourceDirectory lg->GetMakefile()->SetCurrentSourceDirectory
@ -469,8 +470,9 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
cmGlobalGenerator *gg = new cmGlobalGenerator(this); cmGlobalGenerator *gg = new cmGlobalGenerator(this);
this->SetGlobalGenerator(gg); this->SetGlobalGenerator(gg);
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
// read in the list file to fill the cache // read in the list file to fill the cache
cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator(snapshot));
cmMakefile* mf = lg->GetMakefile(); cmMakefile* mf = lg->GetMakefile();
mf->SetCurrentBinaryDirectory mf->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory()); (cmSystemTools::GetCurrentWorkingDirectory());
@ -2059,7 +2061,8 @@ int cmake::CheckBuildSystem()
cm.SetHomeDirectory(""); cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory(""); cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm); cmGlobalGenerator gg(&cm);
cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lg(
gg.MakeLocalGenerator(cm.GetCurrentSnapshot()));
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())
@ -2089,7 +2092,8 @@ int cmake::CheckBuildSystem()
ggd(this->CreateGlobalGenerator(genName)); ggd(this->CreateGlobalGenerator(genName));
if(ggd.get()) if(ggd.get())
{ {
cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator()); cmsys::auto_ptr<cmLocalGenerator> lgd(
ggd->MakeLocalGenerator(cm.GetCurrentSnapshot()));
lgd->ClearDependencies(mf, verbose); lgd->ClearDependencies(mf, verbose);
} }
} }

View File

@ -768,7 +768,9 @@ 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->MakeLocalGenerator()); cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
cmsys::auto_ptr<cmLocalGenerator> lgd(
ggd->MakeLocalGenerator(snapshot));
lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);