From ff8ac8ee6ab3ee686621445456a765fa33c1a873 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 11:41:51 +0200 Subject: [PATCH] cmLocalGenerator: Create from already-constructed cmMakefile. Don't manage the lifetime of the cmMakefile with cmLocalGenerator. --- Source/CPack/cmCPackGenerator.cxx | 5 +++-- Source/CPack/cpack.cxx | 9 +++++---- Source/CTest/cmCTestLaunch.cxx | 4 ++-- Source/CTest/cmCTestScriptHandler.cxx | 10 ++++++---- Source/CTest/cmCTestTestHandler.cxx | 4 ++-- Source/cmCTest.cxx | 8 ++++---- Source/cmGlobalBorlandMakefileGenerator.cxx | 4 ++-- Source/cmGlobalBorlandMakefileGenerator.h | 2 +- Source/cmGlobalGenerator.cxx | 13 +++++++------ Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalGhsMultiGenerator.cxx | 4 ++-- Source/cmGlobalGhsMultiGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.cxx | 4 ++-- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 10 +++++++--- Source/cmGlobalUnixMakefileGenerator3.h | 3 +-- Source/cmGlobalVisualStudio10Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio10Generator.h | 2 +- Source/cmGlobalVisualStudio6Generator.cxx | 5 ++--- Source/cmGlobalVisualStudio6Generator.h | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 4 ++-- Source/cmGlobalVisualStudio7Generator.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- Source/cmGlobalXCodeGenerator.h | 2 +- Source/cmGraphVizWriter.cxx | 6 +++--- Source/cmLocalCommonGenerator.cxx | 4 ++-- Source/cmLocalCommonGenerator.h | 3 +-- Source/cmLocalGenerator.cxx | 9 ++++----- Source/cmLocalGenerator.h | 2 +- Source/cmLocalGhsMultiGenerator.cxx | 4 ++-- Source/cmLocalGhsMultiGenerator.h | 3 +-- Source/cmLocalNinjaGenerator.cxx | 4 ++-- Source/cmLocalNinjaGenerator.h | 3 +-- Source/cmLocalUnixMakefileGenerator3.cxx | 5 ++--- Source/cmLocalUnixMakefileGenerator3.h | 3 +-- Source/cmLocalVisualStudio10Generator.cxx | 5 ++--- Source/cmLocalVisualStudio10Generator.h | 3 +-- Source/cmLocalVisualStudio6Generator.cxx | 5 ++--- Source/cmLocalVisualStudio6Generator.h | 3 +-- Source/cmLocalVisualStudio7Generator.cxx | 5 ++--- Source/cmLocalVisualStudio7Generator.h | 3 +-- Source/cmLocalVisualStudioGenerator.cxx | 5 ++--- Source/cmLocalVisualStudioGenerator.h | 3 +-- Source/cmLocalXCodeGenerator.cxx | 4 ++-- Source/cmLocalXCodeGenerator.h | 2 +- Source/cmMakefile.cxx | 9 ++++----- Source/cmQtAutoGenerators.cxx | 3 ++- Source/cmake.cxx | 18 ++++++++++-------- Source/cmcmd.cxx | 3 ++- 49 files changed, 112 insertions(+), 116 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 8cbcd4eff..92a4b2bcd 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -716,9 +716,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cm.AddCMakePaths(); cm.SetProgressCallback(cmCPackGeneratorProgress, this); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf( + new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) { diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 96351f784..cb9cbc49e 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -202,9 +202,10 @@ int main (int argc, char const* const* argv) cminst.SetHomeOutputDirectory(""); cminst.GetState()->RemoveUnscriptableCommands(); cmGlobalGenerator cmgg(&cminst); + cmsys::auto_ptr globalMF( + new cmMakefile(&cmgg, cminst.GetCurrentSnapshot())); cmsys::auto_ptr cmlg( - cmgg.CreateLocalGenerator(cminst.GetCurrentSnapshot())); - cmMakefile* globalMF = cmlg->GetMakefile(); + cmgg.CreateLocalGenerator(globalMF.get())); #if defined(__CYGWIN__) globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif @@ -358,8 +359,8 @@ int main (int argc, char const* const* argv) ++it ) { const char* gen = it->c_str(); - cmMakefile::ScopePushPop raii(globalMF); - cmMakefile* mf = globalMF; + cmMakefile::ScopePushPop raii(globalMF.get()); + cmMakefile* mf = globalMF.get(); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Specified generator: " << gen << std::endl); if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 7340d5cba..fb0cce634 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -738,9 +738,9 @@ void cmCTestLaunch::LoadConfig() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile* mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); std::string fname = this->LogDir; fname += "CTestLaunchConfig.cmake"; if(cmSystemTools::FileExists(fname.c_str()) && diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 4be5eb69a..c1ba2794a 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -125,6 +125,7 @@ void cmCTestScriptHandler::Initialize() // what time in seconds did this script start running this->ScriptStartTime = 0; + delete this->Makefile; this->Makefile = 0; delete this->LocalGenerator; @@ -139,8 +140,7 @@ void cmCTestScriptHandler::Initialize() //---------------------------------------------------------------------- cmCTestScriptHandler::~cmCTestScriptHandler() { - // local generator owns the makefile - this->Makefile = 0; + delete this->Makefile; delete this->LocalGenerator; delete this->GlobalGenerator; delete this->CMake; @@ -317,6 +317,7 @@ void cmCTestScriptHandler::CreateCMake() delete this->CMake; delete this->GlobalGenerator; delete this->LocalGenerator; + delete this->Makefile; } this->CMake = new cmake; this->CMake->SetHomeDirectory(""); @@ -325,8 +326,9 @@ void cmCTestScriptHandler::CreateCMake() this->GlobalGenerator = new cmGlobalGenerator(this->CMake); cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); - this->LocalGenerator = this->GlobalGenerator->CreateLocalGenerator(snapshot); - this->Makefile = this->LocalGenerator->GetMakefile(); + this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot); + this->LocalGenerator = + this->GlobalGenerator->CreateLocalGenerator(this->Makefile); this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 9e001936b..a523f570f 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1592,9 +1592,9 @@ void cmCTestTestHandler::GetListOfTests() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + gg.CreateLocalGenerator(mf.get())); mf->AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType().c_str()); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 1786c2ce6..adefd1c39 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -520,10 +520,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); - if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); + if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), + mf.get()) ) { cmCTestOptionalLog(this, DEBUG, "Cannot find custom configuration file tree" << std::endl, quiet); diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index c31f952b2..40e8d2901 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile *mf) { cmLocalUnixMakefileGenerator3* lg = - new cmLocalUnixMakefileGenerator3(this, snapshot); + new cmLocalUnixMakefileGenerator3(this, mf); lg->SetMakefileVariableSize(32); lg->SetMakeCommandEscapeTargetTwice(true); lg->SetBorlandMakeCurlyHack(true); diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 62e458f74..b59c86d56 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -36,7 +36,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index fba14e510..d82c7f38f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1127,10 +1127,10 @@ void cmGlobalGenerator::Configure() this->FirstTimeProgress = 0.0f; this->ClearGeneratorMembers(); - // start with this directory - cmLocalGenerator *lg = this->CreateLocalGenerator( - this->GetCMakeInstance()->GetCurrentSnapshot()); - this->Makefiles.push_back(lg->GetMakefile()); + cmMakefile* dirMf = + new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot()); + this->Makefiles.push_back(dirMf); + cmLocalGenerator *lg = this->CreateLocalGenerator(dirMf); this->LocalGenerators.push_back(lg); // set the Start directories @@ -1601,6 +1601,7 @@ void cmGlobalGenerator::ClearGeneratorMembers() cmDeleteAll(this->BuildExportSets); this->BuildExportSets.clear(); + cmDeleteAll(this->Makefiles); this->Makefiles.clear(); cmDeleteAll(this->LocalGenerators); @@ -1987,9 +1988,9 @@ void cmGlobalGenerator::EnableInstallTarget() } cmLocalGenerator* -cmGlobalGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalGenerator(this, snapshot); + return new cmLocalGenerator(this, mf); } void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 91c1aac5d..b11348859 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -57,7 +57,7 @@ public: virtual ~cmGlobalGenerator(); virtual cmLocalGenerator* - CreateLocalGenerator(cmState::Snapshot snapshot = cmState::Snapshot()); + CreateLocalGenerator(cmMakefile* mf); ///! Get the name for this generator virtual std::string GetName() const { return "Generic"; } diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 29abb373c..6dde1e387 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -33,9 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() } cmLocalGenerator * -cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalGhsMultiGenerator(this, snapshot); + return new cmLocalGhsMultiGenerator(this, mf); } void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry) diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 873c20f37..8f88d4f21 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -31,7 +31,7 @@ public: { return new cmGlobalGeneratorSimpleFactory(); } ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /// @return the name of this generator. static std::string GetActualName() { return "Green Hills MULTI"; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 72ef4d6be..120bb036a 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -528,9 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) // Virtual public methods. cmLocalGenerator* -cmGlobalNinjaGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalNinjaGenerator(this, snapshot); + return new cmLocalNinjaGenerator(this, mf); } void cmGlobalNinjaGenerator diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ecc89288a..d204a50ca 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -167,7 +167,7 @@ public: virtual ~cmGlobalNinjaGenerator() { } - virtual cmLocalGenerator* CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); virtual std::string GetName() const { return cmGlobalNinjaGenerator::GetActualName(); } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0d4ee151a..cf4fd69e1 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -60,9 +60,9 @@ void cmGlobalUnixMakefileGenerator3 ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { - return new cmLocalUnixMakefileGenerator3(this, snapshot); + return new cmLocalUnixMakefileGenerator3(this, mf); } //---------------------------------------------------------------------------- @@ -577,17 +577,20 @@ void cmGlobalUnixMakefileGenerator3 makeOptions.begin(), makeOptions.end()); if (!targetName.empty()) { + cmMakefile* mf; cmLocalUnixMakefileGenerator3 *lg; if (!this->LocalGenerators.empty()) { lg = static_cast (this->LocalGenerators[0]); + mf = lg->GetMakefile(); } else { cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); + mf = new cmMakefile(this, snapshot); lg = static_cast - (this->CreateLocalGenerator(snapshot)); + (this->CreateLocalGenerator(mf)); // set the Start directories lg->GetMakefile()->SetCurrentSourceDirectory (this->CMakeInstance->GetHomeDirectory()); @@ -606,6 +609,7 @@ void cmGlobalUnixMakefileGenerator3 if (this->LocalGenerators.empty()) { delete lg; + delete mf; } } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 3ea6bb282..5f39c7979 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -67,8 +67,7 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator3 - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a36fed154..44d632d46 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -307,9 +307,9 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) ///! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { - return new cmLocalVisualStudio10Generator(this, snapshot); + return new cmLocalVisualStudio10Generator(this, mf); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index bbc22b9b2..8de7b0995 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -48,7 +48,7 @@ public: virtual bool Compute(); ///! create the correct local generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 48c3d3284..df49948d0 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -173,10 +173,9 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalVisualStudio6Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) +cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalVisualStudio6Generator(this, snapshot); + return new cmLocalVisualStudio6Generator(this, mf); } diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 0169be0e4..e9b24eaa6 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -39,7 +39,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index b8f63576a..01750628f 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -280,10 +280,10 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand( ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator( - cmState::Snapshot snapshot) + cmMakefile* mf) { cmLocalVisualStudio7Generator *lg = - new cmLocalVisualStudio7Generator(this, snapshot); + new cmLocalVisualStudio7Generator(this, mf); return lg; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 5ada2c574..35575d108 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -43,7 +43,7 @@ public: std::string const& GetPlatformName() const; ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf); virtual bool SetSystemName(std::string const& s, cmMakefile* mf); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index af3629dfa..33babecd9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -371,9 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( //---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator * -cmGlobalXCodeGenerator::CreateLocalGenerator(cmState::Snapshot snapshot) +cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf) { - return new cmLocalXCodeGenerator(this, snapshot); + return new cmLocalXCodeGenerator(this, mf); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index f93f62f8d..102c0366a 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -41,7 +41,7 @@ public: static void GetDocumentation(cmDocumentationEntry& entry); ///! Create a local generator appropriate to this Global Generator - virtual cmLocalGenerator *CreateLocalGenerator(cmState::Snapshot snapshot); + virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf); /** * Try to determine system information such as shared library diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 7da3085bc..2023697fe 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -68,9 +68,9 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator ggi(&cm); - cmsys::auto_ptr lg( - ggi.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile *mf = lg->GetMakefile(); + cmsys::auto_ptr mf( + new cmMakefile(&ggi, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(ggi.CreateLocalGenerator(mf.get())); const char* inFileName = settingsFileName; diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 58c707c84..5a18e2f5f 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -14,8 +14,8 @@ #include "cmMakefile.h" cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalGenerator(gg, snapshot) + cmMakefile* mf): + cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index b7caf0b16..6b4b1cdbb 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -22,8 +22,7 @@ class cmCommonTargetGenerator; class cmLocalCommonGenerator: public cmLocalGenerator { public: - cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf); ~cmLocalCommonGenerator(); std::string const& GetConfigName() { return this->ConfigName; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 357a50873..455b69879 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -43,13 +43,13 @@ #endif cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmOutputConverter(snapshot), StateSnapshot(snapshot) + cmMakefile* makefile) + : cmOutputConverter(makefile->GetStateSnapshot()), + StateSnapshot(makefile->GetStateSnapshot()) { - assert(snapshot.IsValid()); this->GlobalGenerator = gg; - this->Makefile = new cmMakefile(gg, snapshot); + this->Makefile = makefile; this->EmitUniversalBinaryFlags = true; this->BackwardsCompatibility = 0; @@ -58,7 +58,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator::~cmLocalGenerator() { - delete this->Makefile; } void cmLocalGenerator::IssueMessage(cmake::MessageType t, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 4c0b1fe5c..28b5ed1c1 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -36,7 +36,7 @@ class cmCustomCommandGenerator; class cmLocalGenerator : public cmOutputConverter { public: - cmLocalGenerator(cmGlobalGenerator* gg, cmState::Snapshot snapshot); + cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile); virtual ~cmLocalGenerator(); /** diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 91dfeb462..bac989f85 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -17,8 +17,8 @@ #include "cmGeneratedFileStream.h" cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h index 3309bfd7d..b6a9a33f7 100644 --- a/Source/cmLocalGhsMultiGenerator.h +++ b/Source/cmLocalGhsMultiGenerator.h @@ -25,8 +25,7 @@ class cmGeneratedFileStream; class cmLocalGhsMultiGenerator : public cmLocalGenerator { public: - cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalGhsMultiGenerator(); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 62bf8b218..7525bf2ed 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -23,8 +23,8 @@ #include cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalCommonGenerator(gg, mf) , HomeRelativeOutputPath("") { this->TargetImplib = "$TARGET_IMPLIB"; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 4c158bce7..8d3d49cee 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -31,8 +31,7 @@ class cmake; class cmLocalNinjaGenerator : public cmLocalCommonGenerator { public: - cmLocalNinjaGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalNinjaGenerator(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index d2b60d35a..b131a634d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -80,9 +80,8 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3:: -cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalCommonGenerator(gg, snapshot) +cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf) + : cmLocalCommonGenerator(gg, mf) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 2b9af38af..98f15e66f 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -34,8 +34,7 @@ class cmSourceFile; class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator { public: - cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalUnixMakefileGenerator3(); virtual void ComputeHomeRelativeOutputPath(); diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 25b3f193c..b043b0068 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -62,9 +62,8 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator -::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudio7Generator(gg, snapshot) +::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudio7Generator(gg, mf) { } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 0f179fd7f..e18759096 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,8 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 46e1987a8..cc94cd474 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -24,9 +24,8 @@ #include cmLocalVisualStudio6Generator -::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, snapshot) +::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudioGenerator(gg, mf) { } diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 86b49065c..828d2525b 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -29,8 +29,7 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio6Generator(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index eebed7e6f..cf67251e8 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -53,9 +53,8 @@ static void cmConvertToWindowsSlash(std::string& s) //---------------------------------------------------------------------------- cmLocalVisualStudio7Generator -::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot): - cmLocalVisualStudioGenerator(gg, snapshot) +::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf): + cmLocalVisualStudioGenerator(gg, mf) { this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); } diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 42ae09788..bc05a06a7 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -35,8 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio7Generator(); diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 70f729f12..c0072de42 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -19,9 +19,8 @@ //---------------------------------------------------------------------------- cmLocalVisualStudioGenerator -::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) +::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf) + : cmLocalGenerator(gg, mf) { } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 32244c74b..071bfb31b 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -31,8 +31,7 @@ class cmCustomCommandGenerator; class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: - cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index d6576f617..b19112d67 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -16,8 +16,8 @@ //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot) - : cmLocalGenerator(gg, snapshot) + cmMakefile* mf) + : cmLocalGenerator(gg, mf) { // the global generator does this, so do not // put these flags into the language flags diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index d96e78c7d..6d0926fcc 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -25,7 +25,7 @@ class cmLocalXCodeGenerator : public cmLocalGenerator public: ///! Set cache only and recurse to false by default. cmLocalXCodeGenerator(cmGlobalGenerator* gg, - cmState::Snapshot snapshot); + cmMakefile* mf); virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1df62134c..7893032fc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -16,7 +16,6 @@ #include "cmSourceFileLocation.h" #include "cmSystemTools.h" #include "cmGlobalGenerator.h" -#include "cmLocalGenerator.h" #include "cmCommands.h" #include "cmState.h" #include "cmOutputConverter.h" @@ -1754,14 +1753,14 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, this->ContextStack.back()->Name, this->ContextStack.back()->Line); + cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); + this->GetGlobalGenerator()->AddMakefile(subMf); + // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() - ->CreateLocalGenerator(newSnapshot); - this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile()); + ->CreateLocalGenerator(subMf); this->GetGlobalGenerator()->AddLocalGenerator(lg2); - cmMakefile* subMf = lg2->GetMakefile(); - // set the subdirs start dirs subMf->SetCurrentSourceDirectory(srcPath); subMf->SetCurrentBinaryDirectory(binPath); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 9803c0173..becfeba46 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,7 +1218,8 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmGlobalGenerator gg(&cm); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); - cmsys::auto_ptr lg(gg.CreateLocalGenerator(snapshot)); + cmsys::auto_ptr mf(new cmMakefile(&gg, snapshot)); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg.SetCurrentMakefile(lg->GetMakefile()); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ebc38d8c3..f0694813a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -430,7 +430,8 @@ void cmake::ReadListFile(const std::vector& args, this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmState::Snapshot snapshot = this->GetCurrentSnapshot(); - cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); + cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); lg->GetMakefile()->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); lg->GetMakefile()->SetCurrentSourceDirectory @@ -472,8 +473,8 @@ bool cmake::FindPackage(const std::vector& args) cmState::Snapshot snapshot = this->GetCurrentSnapshot(); // read in the list file to fill the cache - cmsys::auto_ptr lg(gg->CreateLocalGenerator(snapshot)); - cmMakefile* mf = lg->GetMakefile(); + cmsys::auto_ptr mf(new cmMakefile(gg, snapshot)); + cmsys::auto_ptr lg(gg->CreateLocalGenerator(mf.get())); mf->SetCurrentBinaryDirectory (cmSystemTools::GetCurrentWorkingDirectory()); mf->SetCurrentSourceDirectory @@ -2061,9 +2062,8 @@ int cmake::CheckBuildSystem() cm.SetHomeDirectory(""); cm.SetHomeOutputDirectory(""); cmGlobalGenerator gg(&cm); - cmsys::auto_ptr lg( - gg.CreateLocalGenerator(cm.GetCurrentSnapshot())); - cmMakefile* mf = lg->GetMakefile(); + cmsys::auto_ptr mf(new cmMakefile(&gg, cm.GetCurrentSnapshot())); + cmsys::auto_ptr lg(gg.CreateLocalGenerator(mf.get())); if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) || cmSystemTools::GetErrorOccuredFlag()) { @@ -2092,9 +2092,11 @@ int cmake::CheckBuildSystem() ggd(this->CreateGlobalGenerator(genName)); if(ggd.get()) { + cmsys::auto_ptr mfd(new cmMakefile(ggd.get(), + cm.GetCurrentSnapshot())); cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(cm.GetCurrentSnapshot())); - lgd->ClearDependencies(mf, verbose); + ggd->CreateLocalGenerator(mfd.get())); + lgd->ClearDependencies(mfd.get(), verbose); } } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index c7884744f..aa70aa069 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -769,8 +769,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) { cm.SetGlobalGenerator(ggd); cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmsys::auto_ptr mf(new cmMakefile(ggd, snapshot)); cmsys::auto_ptr lgd( - ggd->CreateLocalGenerator(snapshot)); + ggd->CreateLocalGenerator(mf.get())); lgd->GetMakefile()->SetCurrentSourceDirectory(startDir); lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);