1
0
Эх сурвалжийг харах

Merge topic 'generate-time-generators'

2b9a25d7 cmGlobalGenerator: Create global targets directly after Configure.
3e08b4df cmMakefile: Skip Global targets for CMP0019 evaluation.
357bf469 cmGlobalGenerator: Fill the project map at compute time.
ebf8d0a9 cmGlobalGenerator: Rename method.
bd096d30 cmGlobalGenerator: Avoid cmLocalGenerator until after Configure.
ff8ac8ee cmLocalGenerator: Create from already-constructed cmMakefile.
0bd7279f Ninja: Remove some incorrect comments adding no value.
2f2d4da9 cmCTestScriptHandler: Simplify deletes.
7fdc9a8b QtAutogen: Use a smart pointer.
92041eec cmGlobalGenerator: Remove MakeLocalGenerator method.
acb00622 cmGlobalGenerator: Require a snapshot to create a local generator.
83b8a927 cmMakefile: Remove cmLocalGenerator member.
9b6a743b cmLocalGenerator: Remove Parent pointer.
Brad King 10 жил өмнө
parent
commit
352e8e95b6
50 өөрчлөгдсөн 176 нэмэгдсэн , 247 устгасан
  1. 4 2
      Source/CPack/cmCPackGenerator.cxx
  2. 6 4
      Source/CPack/cpack.cxx
  3. 3 2
      Source/CTest/cmCTestLaunch.cxx
  4. 16 30
      Source/CTest/cmCTestScriptHandler.cxx
  5. 3 2
      Source/CTest/cmCTestTestHandler.cxx
  6. 4 3
      Source/cmCTest.cxx
  7. 2 2
      Source/cmGlobalBorlandMakefileGenerator.cxx
  8. 1 2
      Source/cmGlobalBorlandMakefileGenerator.h
  9. 33 47
      Source/cmGlobalGenerator.cxx
  10. 3 8
      Source/cmGlobalGenerator.h
  11. 2 3
      Source/cmGlobalGhsMultiGenerator.cxx
  12. 1 2
      Source/cmGlobalGhsMultiGenerator.h
  13. 2 3
      Source/cmGlobalNinjaGenerator.cxx
  14. 1 13
      Source/cmGlobalNinjaGenerator.h
  15. 9 5
      Source/cmGlobalUnixMakefileGenerator3.cxx
  16. 1 3
      Source/cmGlobalUnixMakefileGenerator3.h
  17. 3 4
      Source/cmGlobalVisualStudio10Generator.cxx
  18. 1 2
      Source/cmGlobalVisualStudio10Generator.h
  19. 2 3
      Source/cmGlobalVisualStudio6Generator.cxx
  20. 1 2
      Source/cmGlobalVisualStudio6Generator.h
  21. 3 4
      Source/cmGlobalVisualStudio7Generator.cxx
  22. 1 2
      Source/cmGlobalVisualStudio7Generator.h
  23. 2 3
      Source/cmGlobalXCodeGenerator.cxx
  24. 1 2
      Source/cmGlobalXCodeGenerator.h
  25. 3 2
      Source/cmGraphVizWriter.cxx
  26. 2 3
      Source/cmLocalCommonGenerator.cxx
  27. 1 3
      Source/cmLocalCommonGenerator.h
  28. 4 7
      Source/cmLocalGenerator.cxx
  29. 1 6
      Source/cmLocalGenerator.h
  30. 2 3
      Source/cmLocalGhsMultiGenerator.cxx
  31. 1 2
      Source/cmLocalGhsMultiGenerator.h
  32. 2 3
      Source/cmLocalNinjaGenerator.cxx
  33. 1 2
      Source/cmLocalNinjaGenerator.h
  34. 2 3
      Source/cmLocalUnixMakefileGenerator3.cxx
  35. 1 3
      Source/cmLocalUnixMakefileGenerator3.h
  36. 2 4
      Source/cmLocalVisualStudio10Generator.cxx
  37. 1 3
      Source/cmLocalVisualStudio10Generator.h
  38. 2 4
      Source/cmLocalVisualStudio6Generator.cxx
  39. 1 3
      Source/cmLocalVisualStudio6Generator.h
  40. 2 4
      Source/cmLocalVisualStudio7Generator.cxx
  41. 1 3
      Source/cmLocalVisualStudio7Generator.h
  42. 2 4
      Source/cmLocalVisualStudioGenerator.cxx
  43. 1 3
      Source/cmLocalVisualStudioGenerator.h
  44. 2 3
      Source/cmLocalXCodeGenerator.cxx
  45. 2 2
      Source/cmLocalXCodeGenerator.h
  46. 12 11
      Source/cmMakefile.cxx
  47. 3 3
      Source/cmMakefile.h
  48. 3 2
      Source/cmQtAutoGenerators.cxx
  49. 13 7
      Source/cmake.cxx
  50. 4 1
      Source/cmcmd.cxx

+ 4 - 2
Source/CPack/cmCPackGenerator.cxx

@@ -716,8 +716,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
         cm.AddCMakePaths();
         cm.SetProgressCallback(cmCPackGeneratorProgress, this);
         cmGlobalGenerator gg(&cm);
-        cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
-        cmMakefile *mf = lg->GetMakefile();
+        cmsys::auto_ptr<cmMakefile> mf(
+              new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+        cmsys::auto_ptr<cmLocalGenerator> lg(
+              gg.CreateLocalGenerator(mf.get()));
         std::string realInstallDirectory = tempInstallDirectory;
         if ( !installSubDirectory.empty() && installSubDirectory != "/" )
           {

+ 6 - 4
Source/CPack/cpack.cxx

@@ -202,8 +202,10 @@ int main (int argc, char const* const* argv)
   cminst.SetHomeOutputDirectory("");
   cminst.GetState()->RemoveUnscriptableCommands();
   cmGlobalGenerator cmgg(&cminst);
-  cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.MakeLocalGenerator());
-  cmMakefile* globalMF = cmlg->GetMakefile();
+  cmsys::auto_ptr<cmMakefile> globalMF(
+        new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
+  cmsys::auto_ptr<cmLocalGenerator> cmlg(
+        cmgg.CreateLocalGenerator(globalMF.get()));
 #if defined(__CYGWIN__)
   globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
 #endif
@@ -357,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") )

+ 3 - 2
Source/CTest/cmCTestLaunch.cxx

@@ -738,8 +738,9 @@ void cmCTestLaunch::LoadConfig()
   cm.SetHomeDirectory("");
   cm.SetHomeOutputDirectory("");
   cmGlobalGenerator gg(&cm);
-  cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
-  cmMakefile* mf = lg->GetMakefile();
+  cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+  cmsys::auto_ptr<cmLocalGenerator> lg(
+        gg.CreateLocalGenerator(mf.get()));
   std::string fname = this->LogDir;
   fname += "CTestLaunchConfig.cmake";
   if(cmSystemTools::FileExists(fname.c_str()) &&

+ 16 - 30
Source/CTest/cmCTestScriptHandler.cxx

@@ -125,42 +125,25 @@ void cmCTestScriptHandler::Initialize()
   // what time in seconds did this script start running
   this->ScriptStartTime = 0;
 
+  delete this->Makefile;
   this->Makefile = 0;
-  if (this->LocalGenerator)
-    {
-    delete this->LocalGenerator;
-    }
+
+  delete this->LocalGenerator;
   this->LocalGenerator = 0;
-  if (this->GlobalGenerator)
-    {
-    delete this->GlobalGenerator;
-    }
+
+  delete this->GlobalGenerator;
   this->GlobalGenerator = 0;
-  if (this->CMake)
-    {
-    delete this->CMake;
-    }
+
+  delete this->CMake;
 }
 
 //----------------------------------------------------------------------
 cmCTestScriptHandler::~cmCTestScriptHandler()
 {
-  // local generator owns the makefile
-  this->Makefile = 0;
-  if (this->LocalGenerator)
-    {
-    delete this->LocalGenerator;
-    }
-  this->LocalGenerator = 0;
-  if (this->GlobalGenerator)
-    {
-    delete this->GlobalGenerator;
-    }
-  this->GlobalGenerator = 0;
-  if (this->CMake)
-    {
-    delete this->CMake;
-    }
+  delete this->Makefile;
+  delete this->LocalGenerator;
+  delete this->GlobalGenerator;
+  delete this->CMake;
 }
 
 
@@ -334,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("");
@@ -341,8 +325,10 @@ void cmCTestScriptHandler::CreateCMake()
   this->CMake->AddCMakePaths();
   this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
 
-  this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator();
-  this->Makefile = this->LocalGenerator->GetMakefile();
+  cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
+  this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
+  this->LocalGenerator =
+      this->GlobalGenerator->CreateLocalGenerator(this->Makefile);
 
   this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
 

+ 3 - 2
Source/CTest/cmCTestTestHandler.cxx

@@ -1592,8 +1592,9 @@ void cmCTestTestHandler::GetListOfTests()
   cm.SetHomeDirectory("");
   cm.SetHomeOutputDirectory("");
   cmGlobalGenerator gg(&cm);
-  cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
-  cmMakefile *mf = lg->GetMakefile();
+  cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+  cmsys::auto_ptr<cmLocalGenerator> lg(
+        gg.CreateLocalGenerator(mf.get()));
   mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
     this->CTest->GetConfigType().c_str());
 

+ 4 - 3
Source/cmCTest.cxx

@@ -520,9 +520,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
   cm.SetHomeDirectory("");
   cm.SetHomeOutputDirectory("");
   cmGlobalGenerator gg(&cm);
-  cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
-  cmMakefile *mf = lg->GetMakefile();
-  if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) )
+  cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+  cmsys::auto_ptr<cmLocalGenerator> 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);

+ 2 - 2
Source/cmGlobalBorlandMakefileGenerator.cxx

@@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator
 
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
-    cmLocalGenerator* parent, cmState::Snapshot snapshot)
+    cmMakefile *mf)
 {
   cmLocalUnixMakefileGenerator3* lg =
-      new cmLocalUnixMakefileGenerator3(this, parent, snapshot);
+      new cmLocalUnixMakefileGenerator3(this, mf);
   lg->SetMakefileVariableSize(32);
   lg->SetMakeCommandEscapeTargetTwice(true);
   lg->SetBorlandMakeCurlyHack(true);

+ 1 - 2
Source/cmGlobalBorlandMakefileGenerator.h

@@ -36,8 +36,7 @@ public:
   static void GetDocumentation(cmDocumentationEntry& entry);
 
   ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library

+ 33 - 47
Source/cmGlobalGenerator.cxx

@@ -1127,23 +1127,40 @@ void cmGlobalGenerator::Configure()
   this->FirstTimeProgress = 0.0f;
   this->ClearGeneratorMembers();
 
-  // start with this directory
-  cmLocalGenerator *lg = this->MakeLocalGenerator();
-  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
-  lg->GetMakefile()->SetCurrentSourceDirectory
+  dirMf->SetCurrentSourceDirectory
     (this->CMakeInstance->GetHomeDirectory());
-  lg->GetMakefile()->SetCurrentBinaryDirectory
+  dirMf->SetCurrentBinaryDirectory
     (this->CMakeInstance->GetHomeOutputDirectory());
 
   this->BinaryDirectories.insert(
       this->CMakeInstance->GetHomeOutputDirectory());
 
   // now do it
-  lg->GetMakefile()->Configure();
-  lg->GetMakefile()->EnforceDirectoryLevelRules();
+  dirMf->Configure();
+  dirMf->EnforceDirectoryLevelRules();
+
+  // Put a copy of each global target in every directory.
+  cmTargets globalTargets;
+  this->CreateDefaultGlobalTargets(&globalTargets);
+
+  for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
+    {
+    cmMakefile* mf = this->Makefiles[i];
+    cmTargets* targets = &(mf->GetTargets());
+    cmTargets::iterator tit;
+    for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit )
+      {
+      (*targets)[tit->first] = tit->second;
+      (*targets)[tit->first].SetMakefile(mf);
+      }
+    }
 
   // update the cache entry for the number of local generators, this is used
   // for progress
@@ -1155,11 +1172,7 @@ void cmGlobalGenerator::Configure()
 
   // check for link libraries and include directories containing "NOTFOUND"
   // and for infinite loops
-  this->CheckLocalGenerators();
-
-  // at this point this->LocalGenerators has been filled,
-  // so create the map from project name to vector of local generators
-  this->FillProjectMap();
+  this->CheckTargetProperties();
 
   if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE)
     {
@@ -1186,25 +1199,6 @@ void cmGlobalGenerator::Configure()
       }
     this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1);
     }
-
-  unsigned int i;
-
-  // Put a copy of each global target in every directory.
-  cmTargets globalTargets;
-  this->CreateDefaultGlobalTargets(&globalTargets);
-
-  for (i = 0; i < this->Makefiles.size(); ++i)
-    {
-    cmMakefile* mf = this->Makefiles[i];
-    cmTargets* targets = &(mf->GetTargets());
-    cmTargets::iterator tit;
-    for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit )
-      {
-      (*targets)[tit->first] = tit->second;
-      (*targets)[tit->first].SetMakefile(mf);
-      }
-    }
-
 }
 
 void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
@@ -1267,6 +1261,10 @@ bool cmGlobalGenerator::Compute()
 
   this->CreateGenerationObjects();
 
+  // at this point this->LocalGenerators has been filled,
+  // so create the map from project name to vector of local generators
+  this->FillProjectMap();
+
 #ifdef CMAKE_BUILD_WITH_CMAKE
   // Iterate through all targets and set up automoc for those which have
   // the AUTOMOC, AUTOUIC or AUTORCC property set
@@ -1600,6 +1598,7 @@ void cmGlobalGenerator::ClearGeneratorMembers()
   cmDeleteAll(this->BuildExportSets);
   this->BuildExportSets.clear();
 
+  cmDeleteAll(this->Makefiles);
   this->Makefiles.clear();
 
   cmDeleteAll(this->LocalGenerators);
@@ -1634,7 +1633,7 @@ void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
 {
 }
 
-void cmGlobalGenerator::CheckLocalGenerators()
+void cmGlobalGenerator::CheckTargetProperties()
 {
   std::map<std::string, std::string> notFoundMap;
 //  std::set<std::string> notFoundMap;
@@ -1985,23 +1984,10 @@ void cmGlobalGenerator::EnableInstallTarget()
   this->InstallTargetEnabled = true;
 }
 
-cmLocalGenerator *
-cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot,
-                                      cmLocalGenerator *parent)
-{
-  if (!snapshot.IsValid())
-    {
-    snapshot = this->CMakeInstance->GetCurrentSnapshot();
-    }
-
-  return this->CreateLocalGenerator(parent, snapshot);
-}
-
 cmLocalGenerator*
-cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
-                                        cmState::Snapshot snapshot)
+cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf)
 {
-  return new cmLocalGenerator(this, parent, snapshot);
+  return new cmLocalGenerator(this, mf);
 }
 
 void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,

+ 3 - 8
Source/cmGlobalGenerator.h

@@ -56,9 +56,8 @@ public:
   cmGlobalGenerator(cmake* cm);
   virtual ~cmGlobalGenerator();
 
-  cmLocalGenerator* MakeLocalGenerator(
-      cmState::Snapshot snapshot = cmState::Snapshot(),
-      cmLocalGenerator* parent = 0);
+  virtual cmLocalGenerator*
+  CreateLocalGenerator(cmMakefile* mf);
 
   ///! Get the name for this generator
   virtual std::string GetName() const { return "Generic"; }
@@ -395,7 +394,7 @@ protected:
   // Fill the ProjectMap, this must be called after LocalGenerators
   // has been populated.
   void FillProjectMap();
-  void CheckLocalGenerators();
+  void CheckTargetProperties();
   bool IsExcluded(cmState::Snapshot const& root,
                   cmState::Snapshot const& snp) const;
   bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const;
@@ -441,10 +440,6 @@ protected:
   virtual bool UseFolderProperty();
 
 private:
-  ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
-
   cmMakefile* TryCompileOuterMakefile;
   // If you add a new map here, make sure it is copied
   // in EnableLanguagesFromGenerator

+ 2 - 3
Source/cmGlobalGhsMultiGenerator.cxx

@@ -33,10 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
 }
 
 cmLocalGenerator *
-cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
-                                                cmState::Snapshot snapshot)
+cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf)
 {
-  return new cmLocalGhsMultiGenerator(this, parent, snapshot);
+  return new cmLocalGhsMultiGenerator(this, mf);
 }
 
 void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry)

+ 1 - 2
Source/cmGlobalGhsMultiGenerator.h

@@ -31,8 +31,7 @@ public:
   { return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>(); }
 
   ///! create the correct local generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
 
   /// @return the name of this generator.
   static std::string GetActualName() { return "Green Hills MULTI"; }

+ 2 - 3
Source/cmGlobalNinjaGenerator.cxx

@@ -528,10 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
 // Virtual public methods.
 
 cmLocalGenerator*
-cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
-                                             cmState::Snapshot snapshot)
+cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf)
 {
-  return new cmLocalNinjaGenerator(this, parent, snapshot);
+  return new cmLocalNinjaGenerator(this, mf);
 }
 
 void cmGlobalNinjaGenerator

+ 1 - 13
Source/cmGlobalNinjaGenerator.h

@@ -162,33 +162,24 @@ public:
 public:
   cmGlobalNinjaGenerator(cmake* cm);
 
-  /// Convenience method for creating an instance of this class.
   static cmGlobalGeneratorFactory* NewFactory() {
     return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>(); }
 
-  /// Destructor.
   virtual ~cmGlobalNinjaGenerator() { }
 
-  /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator()
-  virtual cmLocalGenerator* CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
 
-  /// Overloaded methods. @see cmGlobalGenerator::GetName().
   virtual std::string GetName() const {
     return cmGlobalNinjaGenerator::GetActualName(); }
 
-  /// @return the name of this generator.
   static std::string GetActualName() { return "Ninja"; }
 
-  /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
   static void GetDocumentation(cmDocumentationEntry& entry);
 
-  /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage()
   virtual void EnableLanguage(std::vector<std::string>const& languages,
                               cmMakefile* mf,
                               bool optional);
 
-  /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand()
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
     const std::string& makeProgram,
@@ -307,11 +298,8 @@ public:
 
 protected:
 
-  /// Overloaded methods. @see cmGlobalGenerator::Generate()
   virtual void Generate();
 
-  /// Overloaded methods.
-  /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS()
   virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; }
 
 

+ 9 - 5
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -59,11 +59,10 @@ void cmGlobalUnixMakefileGenerator3
 }
 
 ///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent,
-                                                   cmState::Snapshot snapshot)
+cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(
+    cmMakefile* mf)
 {
-  return new cmLocalUnixMakefileGenerator3(this, parent, snapshot);
+  return new cmLocalUnixMakefileGenerator3(this, mf);
 }
 
 //----------------------------------------------------------------------------
@@ -578,16 +577,20 @@ void cmGlobalUnixMakefileGenerator3
                      makeOptions.begin(), makeOptions.end());
   if (!targetName.empty())
     {
+    cmMakefile* mf;
     cmLocalUnixMakefileGenerator3 *lg;
     if (!this->LocalGenerators.empty())
       {
       lg = static_cast<cmLocalUnixMakefileGenerator3 *>
         (this->LocalGenerators[0]);
+      mf = lg->GetMakefile();
       }
     else
       {
+      cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
+      mf = new cmMakefile(this, snapshot);
       lg = static_cast<cmLocalUnixMakefileGenerator3 *>
-        (this->MakeLocalGenerator());
+        (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;
       }
     }
 }

+ 1 - 3
Source/cmGlobalUnixMakefileGenerator3.h

@@ -67,9 +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(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library

+ 3 - 4
Source/cmGlobalVisualStudio10Generator.cxx

@@ -306,11 +306,10 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
 }
 
 ///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent,
-                                                    cmState::Snapshot snapshot)
+cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator(
+    cmMakefile* mf)
 {
-  return new cmLocalVisualStudio10Generator(this, parent, snapshot);
+  return new cmLocalVisualStudio10Generator(this, mf);
 }
 
 //----------------------------------------------------------------------------

+ 1 - 2
Source/cmGlobalVisualStudio10Generator.h

@@ -48,8 +48,7 @@ public:
   virtual bool Compute();
 
   ///! create the correct local generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library

+ 2 - 3
Source/cmGlobalVisualStudio6Generator.cxx

@@ -173,10 +173,9 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
 
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *
-cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent,
-                                                   cmState::Snapshot snapshot)
+cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf)
 {
-  return new cmLocalVisualStudio6Generator(this, parent, snapshot);
+  return new cmLocalVisualStudio6Generator(this, mf);
 }
 
 

+ 1 - 2
Source/cmGlobalVisualStudio6Generator.h

@@ -39,8 +39,7 @@ public:
   static void GetDocumentation(cmDocumentationEntry& entry);
 
   ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
 
   /**
    * Try to determine system information such as shared library

+ 3 - 4
Source/cmGlobalVisualStudio7Generator.cxx

@@ -279,12 +279,11 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
 }
 
 ///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent,
-                                                   cmState::Snapshot snapshot)
+cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator(
+    cmMakefile* mf)
 {
   cmLocalVisualStudio7Generator *lg =
-    new cmLocalVisualStudio7Generator(this, parent, snapshot);
+    new cmLocalVisualStudio7Generator(this, mf);
   return lg;
 }
 

+ 1 - 2
Source/cmGlobalVisualStudio7Generator.h

@@ -43,8 +43,7 @@ public:
   std::string const& GetPlatformName() const;
 
   ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
 
   virtual bool SetSystemName(std::string const& s, cmMakefile* mf);
 

+ 2 - 3
Source/cmGlobalXCodeGenerator.cxx

@@ -371,10 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
 //----------------------------------------------------------------------------
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *
-cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
-                                             cmState::Snapshot snapshot)
+cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
 {
-  return new cmLocalXCodeGenerator(this, parent, snapshot);
+  return new cmLocalXCodeGenerator(this, mf);
 }
 
 //----------------------------------------------------------------------------

+ 1 - 2
Source/cmGlobalXCodeGenerator.h

@@ -41,8 +41,7 @@ public:
   static void GetDocumentation(cmDocumentationEntry& entry);
 
   ///! Create a local generator appropriate to this Global Generator
-  virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
-                                                 cmState::Snapshot snapshot);
+  virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf);
 
   /**
    * Try to determine system information such as shared library

+ 3 - 2
Source/cmGraphVizWriter.cxx

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

+ 2 - 3
Source/cmLocalCommonGenerator.cxx

@@ -14,9 +14,8 @@
 #include "cmMakefile.h"
 
 cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
-                                               cmLocalGenerator* parent,
-                                               cmState::Snapshot snapshot):
-  cmLocalGenerator(gg, parent, snapshot)
+                                               cmMakefile* mf):
+  cmLocalGenerator(gg, mf)
 {
 }
 

+ 1 - 3
Source/cmLocalCommonGenerator.h

@@ -22,9 +22,7 @@ class cmCommonTargetGenerator;
 class cmLocalCommonGenerator: public cmLocalGenerator
 {
 public:
-  cmLocalCommonGenerator(cmGlobalGenerator* gg,
-                         cmLocalGenerator* parent,
-                         cmState::Snapshot snapshot);
+  cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
   ~cmLocalCommonGenerator();
 
   std::string const& GetConfigName() { return this->ConfigName; }

+ 4 - 7
Source/cmLocalGenerator.cxx

@@ -43,15 +43,13 @@
 #endif
 
 cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
-                                   cmLocalGenerator* parent,
-                                   cmState::Snapshot snapshot)
-  : cmOutputConverter(snapshot), StateSnapshot(snapshot)
+                                   cmMakefile* makefile)
+  : cmOutputConverter(makefile->GetStateSnapshot()),
+    StateSnapshot(makefile->GetStateSnapshot())
 {
-  assert(snapshot.IsValid());
   this->GlobalGenerator = gg;
-  this->Parent = parent;
 
-  this->Makefile = new cmMakefile(this);
+  this->Makefile = makefile;
 
   this->EmitUniversalBinaryFlags = true;
   this->BackwardsCompatibility = 0;
@@ -60,7 +58,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
 
 cmLocalGenerator::~cmLocalGenerator()
 {
-  delete this->Makefile;
 }
 
 void cmLocalGenerator::IssueMessage(cmake::MessageType t,

+ 1 - 6
Source/cmLocalGenerator.h

@@ -36,8 +36,7 @@ class cmCustomCommandGenerator;
 class cmLocalGenerator : public cmOutputConverter
 {
 public:
-  cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
-                   cmState::Snapshot snapshot);
+  cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile);
   virtual ~cmLocalGenerator();
 
   /**
@@ -86,9 +85,6 @@ public:
   cmState* GetState() const;
   cmState::Snapshot GetStateSnapshot() const;
 
-  ///! set/get the parent generator
-  cmLocalGenerator* GetParent() const {return this->Parent;}
-
   void AddArchitectureFlags(std::string& flags,
                             cmGeneratorTarget const* target,
                             const std::string&lang, const std::string& config);
@@ -343,7 +339,6 @@ protected:
   cmMakefile *Makefile;
   cmState::Snapshot StateSnapshot;
   cmGlobalGenerator *GlobalGenerator;
-  cmLocalGenerator* Parent;
   std::map<std::string, std::string> UniqueObjectNamesMap;
   std::string::size_type ObjectPathMax;
   std::set<std::string> ObjectMaxPathViolations;

+ 2 - 3
Source/cmLocalGhsMultiGenerator.cxx

@@ -17,9 +17,8 @@
 #include "cmGeneratedFileStream.h"
 
 cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
-                                                   cmLocalGenerator* parent,
-                                                   cmState::Snapshot snapshot)
-  : cmLocalGenerator(gg, parent, snapshot)
+                                                   cmMakefile* mf)
+  : cmLocalGenerator(gg, mf)
 {
 }
 

+ 1 - 2
Source/cmLocalGhsMultiGenerator.h

@@ -25,8 +25,7 @@ class cmGeneratedFileStream;
 class cmLocalGhsMultiGenerator : public cmLocalGenerator
 {
 public:
-  cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
-                           cmState::Snapshot snapshot);
+  cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
 
   virtual ~cmLocalGhsMultiGenerator();
 

+ 2 - 3
Source/cmLocalNinjaGenerator.cxx

@@ -23,9 +23,8 @@
 #include <assert.h>
 
 cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
-                                             cmLocalGenerator* parent,
-                                             cmState::Snapshot snapshot)
-  : cmLocalCommonGenerator(gg, parent, snapshot)
+                                             cmMakefile* mf)
+  : cmLocalCommonGenerator(gg, mf)
   , HomeRelativeOutputPath("")
 {
   this->TargetImplib = "$TARGET_IMPLIB";

+ 1 - 2
Source/cmLocalNinjaGenerator.h

@@ -31,8 +31,7 @@ class cmake;
 class cmLocalNinjaGenerator : public cmLocalCommonGenerator
 {
 public:
-  cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
-                        cmState::Snapshot snapshot);
+  cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
 
   virtual ~cmLocalNinjaGenerator();
 

+ 2 - 3
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -80,9 +80,8 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
 
 //----------------------------------------------------------------------------
 cmLocalUnixMakefileGenerator3::
-cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent,
-                              cmState::Snapshot snapshot)
-  : cmLocalCommonGenerator(gg, parent, snapshot)
+cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf)
+  : cmLocalCommonGenerator(gg, mf)
 {
   this->MakefileVariableSize = 0;
   this->ColorMakefile = false;

+ 1 - 3
Source/cmLocalUnixMakefileGenerator3.h

@@ -34,9 +34,7 @@ class cmSourceFile;
 class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator
 {
 public:
-  cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg,
-                                cmLocalGenerator* parent,
-                                cmState::Snapshot snapshot);
+  cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf);
   virtual ~cmLocalUnixMakefileGenerator3();
 
   virtual void ComputeHomeRelativeOutputPath();

+ 2 - 4
Source/cmLocalVisualStudio10Generator.cxx

@@ -62,10 +62,8 @@ class cmVS10XMLParser : public cmXMLParser
 
 //----------------------------------------------------------------------------
 cmLocalVisualStudio10Generator
-::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
-                                 cmLocalGenerator* parent,
-                                 cmState::Snapshot snapshot):
-  cmLocalVisualStudio7Generator(gg, parent, snapshot)
+::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf):
+  cmLocalVisualStudio7Generator(gg, mf)
 {
 }
 

+ 1 - 3
Source/cmLocalVisualStudio10Generator.h

@@ -25,9 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
 {
 public:
   ///! Set cache only and recurse to false by default.
-  cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
-                                 cmLocalGenerator* parent,
-                                 cmState::Snapshot snapshot);
+  cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf);
 
   virtual ~cmLocalVisualStudio10Generator();
 

+ 2 - 4
Source/cmLocalVisualStudio6Generator.cxx

@@ -24,10 +24,8 @@
 #include <cmsys/FStream.hxx>
 
 cmLocalVisualStudio6Generator
-::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
-                                cmLocalGenerator* parent,
-                                cmState::Snapshot snapshot):
-  cmLocalVisualStudioGenerator(gg, parent, snapshot)
+::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf):
+  cmLocalVisualStudioGenerator(gg, mf)
 {
 }
 

+ 1 - 3
Source/cmLocalVisualStudio6Generator.h

@@ -29,9 +29,7 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator
 {
 public:
   ///! Set cache only and recurse to false by default.
-  cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
-                                cmLocalGenerator* parent,
-                                cmState::Snapshot snapshot);
+  cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf);
 
   virtual ~cmLocalVisualStudio6Generator();
 

+ 2 - 4
Source/cmLocalVisualStudio7Generator.cxx

@@ -53,10 +53,8 @@ static void cmConvertToWindowsSlash(std::string& s)
 
 //----------------------------------------------------------------------------
 cmLocalVisualStudio7Generator
-::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
-                                cmLocalGenerator* parent,
-                                cmState::Snapshot snapshot):
-  cmLocalVisualStudioGenerator(gg, parent, snapshot)
+::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf):
+  cmLocalVisualStudioGenerator(gg, mf)
 {
   this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
 }

+ 1 - 3
Source/cmLocalVisualStudio7Generator.h

@@ -35,9 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
 {
 public:
   ///! Set cache only and recurse to false by default.
-  cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
-                                cmLocalGenerator* parent,
-                                cmState::Snapshot snapshot);
+  cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
 
   virtual ~cmLocalVisualStudio7Generator();
 

+ 2 - 4
Source/cmLocalVisualStudioGenerator.cxx

@@ -19,10 +19,8 @@
 
 //----------------------------------------------------------------------------
 cmLocalVisualStudioGenerator
-::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
-                               cmLocalGenerator* parent,
-                               cmState::Snapshot snapshot)
-  : cmLocalGenerator(gg, parent, snapshot)
+::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf)
+  : cmLocalGenerator(gg, mf)
 {
 }
 

+ 1 - 3
Source/cmLocalVisualStudioGenerator.h

@@ -31,9 +31,7 @@ class cmCustomCommandGenerator;
 class cmLocalVisualStudioGenerator : public cmLocalGenerator
 {
 public:
-  cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
-                               cmLocalGenerator* parent,
-                               cmState::Snapshot snapshot);
+  cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
   virtual ~cmLocalVisualStudioGenerator();
 
   /** Construct a script from the given list of command lines.  */

+ 2 - 3
Source/cmLocalXCodeGenerator.cxx

@@ -16,9 +16,8 @@
 
 //----------------------------------------------------------------------------
 cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
-                                             cmLocalGenerator* parent,
-                                             cmState::Snapshot snapshot)
-  : cmLocalGenerator(gg, parent, snapshot)
+                                             cmMakefile* mf)
+  : cmLocalGenerator(gg, mf)
 {
   // the global generator does this, so do not
   // put these flags into the language flags

+ 2 - 2
Source/cmLocalXCodeGenerator.h

@@ -24,8 +24,8 @@ class cmLocalXCodeGenerator : public cmLocalGenerator
 {
 public:
   ///! Set cache only and recurse to false by default.
-  cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
-                        cmState::Snapshot snapshot);
+  cmLocalXCodeGenerator(cmGlobalGenerator* gg,
+                        cmMakefile* mf);
 
   virtual ~cmLocalXCodeGenerator();
   virtual std::string GetTargetDirectory(cmTarget const& target) const;

+ 12 - 11
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"
@@ -44,9 +43,10 @@
 #include <assert.h>
 
 // default is not to be building executables
-cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
-  : LocalGenerator(localGenerator),
-    StateSnapshot(localGenerator->GetStateSnapshot())
+cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
+                       cmState::Snapshot const& snapshot)
+  : GlobalGenerator(globalGenerator),
+    StateSnapshot(snapshot)
 {
   this->IsSourceFileTryCompile = false;
 
@@ -1753,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()
-        ->MakeLocalGenerator(newSnapshot, this->LocalGenerator);
-  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);
@@ -2334,7 +2334,8 @@ void cmMakefile::ExpandVariablesCMP0019()
        l != this->Targets.end(); ++l)
     {
     cmTarget &t = l->second;
-    if (t.GetType() == cmTarget::INTERFACE_LIBRARY)
+    if (t.GetType() == cmTarget::INTERFACE_LIBRARY
+        || t.GetType() == cmTarget::GLOBAL_TARGET)
       {
       continue;
       }
@@ -3744,12 +3745,12 @@ bool cmMakefile::GetIsSourceFileTryCompile() const
 
 cmake *cmMakefile::GetCMakeInstance() const
 {
-  return this->GetGlobalGenerator()->GetCMakeInstance();
+  return this->GlobalGenerator->GetCMakeInstance();
 }
 
 cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
 {
-  return this->LocalGenerator->GetGlobalGenerator();
+  return this->GlobalGenerator;
 }
 
 #ifdef CMAKE_BUILD_WITH_CMAKE

+ 3 - 3
Source/cmMakefile.h

@@ -42,7 +42,6 @@
 class cmFunctionBlocker;
 class cmCommand;
 class cmInstallGenerator;
-class cmLocalGenerator;
 class cmMakeDepend;
 class cmSourceFile;
 class cmTest;
@@ -71,7 +70,8 @@ public:
   /**
    * Construct an empty makefile.
    */
-  cmMakefile(cmLocalGenerator* localGenerator);
+  cmMakefile(cmGlobalGenerator* globalGenerator,
+             const cmState::Snapshot& snapshot);
 
   /**
    * Destructor.
@@ -856,7 +856,7 @@ protected:
 #endif
 
   std::vector<cmCommand*> FinalPassCommands;
-  cmLocalGenerator* LocalGenerator;
+  cmGlobalGenerator* GlobalGenerator;
   bool IsFunctionBlocked(const cmListFileFunction& lff,
                          cmExecutionStatus &status);
 

+ 3 - 2
Source/cmQtAutoGenerators.cxx

@@ -1217,7 +1217,9 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
   cm.SetHomeDirectory(targetDirectory);
   cmGlobalGenerator gg(&cm);
 
-  cmLocalGenerator* lg = gg.MakeLocalGenerator();
+  cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
+  cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot));
+  cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get()));
   lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
   lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
   gg.SetCurrentMakefile(lg->GetMakefile());
@@ -1234,7 +1236,6 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
 
   this->WriteOldMocDefinitionsFile(targetDirectory);
 
-  delete lg;
   return success;
 }
 

+ 13 - 7
Source/cmake.cxx

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

+ 4 - 1
Source/cmcmd.cxx

@@ -768,7 +768,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen))
         {
         cm.SetGlobalGenerator(ggd);
-        cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator());
+        cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
+        cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
+        cmsys::auto_ptr<cmLocalGenerator> lgd(
+              ggd->CreateLocalGenerator(mf.get()));
         lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
         lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);