Browse Source

Introduce the abstract class cmGlobalGeneratorFactory

This new abstract class allows us move some logic from the
cmGlobalGenerator into its own layer in a next step.
Patrick Gansterer 13 years ago
parent
commit
e8f841473b

+ 1 - 0
Source/CMakeLists.txt

@@ -201,6 +201,7 @@ set(SRCS
   cmGeneratorTarget.h
   cmGlobalGenerator.cxx
   cmGlobalGenerator.h
+  cmGlobalGeneratorFactory.h
   cmGlobalUnixMakefileGenerator3.cxx
   cmGlobalUnixMakefileGenerator3.h
   cmGraphAdjacencyList.h

+ 3 - 2
Source/cmGlobalBorlandMakefileGenerator.h

@@ -23,8 +23,9 @@ class cmGlobalBorlandMakefileGenerator : public cmGlobalNMakeMakefileGenerator
 {
 public:
   cmGlobalBorlandMakefileGenerator();
-  static cmGlobalGenerator* New()
-    { return new cmGlobalBorlandMakefileGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalBorlandMakefileGenerator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 51 - 0
Source/cmGlobalGeneratorFactory.h

@@ -0,0 +1,51 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmGlobalGeneratorFactory_h
+#define cmGlobalGeneratorFactory_h
+
+#include "cmStandardIncludes.h"
+
+class cmGlobalGenerator;
+struct cmDocumentationEntry;
+
+/** \class cmGlobalGeneratorFactory
+ * \brief Responable for creating cmGlobalGenerator instances
+ *
+ * Subclasses of this class generate instances of cmGlobalGenerator.
+ */
+class cmGlobalGeneratorFactory
+{
+public:
+  virtual ~cmGlobalGeneratorFactory() {}
+
+  /** Create a GlobalGenerator */
+  virtual cmGlobalGenerator* CreateGlobalGenerator() const = 0;
+
+  /** Get the documentation entry for this factory */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
+};
+
+template<class T>
+class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
+{
+public:
+  /** Create a GlobalGenerator */
+  virtual cmGlobalGenerator* CreateGlobalGenerator() const {
+    return new T; }
+
+  /** Get the documentation entry for this factory */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const {
+    T().GetDocumentation(entry); }
+};
+
+#endif

+ 3 - 2
Source/cmGlobalJOMMakefileGenerator.h

@@ -23,8 +23,9 @@ class cmGlobalJOMMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalJOMMakefileGenerator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalJOMMakefileGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalJOMMakefileGenerator>(); }
   ///! Get the name for the generator.
   virtual const char* GetName() const {
     return cmGlobalJOMMakefileGenerator::GetActualName();}

+ 3 - 2
Source/cmGlobalMSYSMakefileGenerator.h

@@ -23,8 +23,9 @@ class cmGlobalMSYSMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalMSYSMakefileGenerator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalMSYSMakefileGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalMSYSMakefileGenerator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalMinGWMakefileGenerator.h

@@ -23,8 +23,9 @@ class cmGlobalMinGWMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalMinGWMakefileGenerator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalMinGWMakefileGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalMinGWMakefileGenerator>(); }
   ///! Get the name for the generator.
   virtual const char* GetName() const {
     return cmGlobalMinGWMakefileGenerator::GetActualName();}

+ 3 - 2
Source/cmGlobalNMakeMakefileGenerator.h

@@ -23,8 +23,9 @@ class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalNMakeMakefileGenerator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalNMakeMakefileGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalNMakeMakefileGenerator>(); }
   ///! Get the name for the generator.
   virtual const char* GetName() const {
     return cmGlobalNMakeMakefileGenerator::GetActualName();}

+ 3 - 2
Source/cmGlobalNinjaGenerator.h

@@ -14,6 +14,7 @@
 #  define cmGlobalNinjaGenerator_h
 
 #  include "cmGlobalGenerator.h"
+#  include "cmGlobalGeneratorFactory.h"
 #  include "cmNinjaTypes.h"
 
 //#define NINJA_GEN_VERBOSE_FILES
@@ -160,8 +161,8 @@ public:
   cmGlobalNinjaGenerator();
 
   /// Convenience method for creating an instance of this class.
-  static cmGlobalGenerator* New() {
-    return new cmGlobalNinjaGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>(); }
 
   /// Destructor.
   virtual ~cmGlobalNinjaGenerator() { }

+ 4 - 2
Source/cmGlobalUnixMakefileGenerator3.h

@@ -13,6 +13,7 @@
 #define cmGlobalUnixMakefileGenerator3_h
 
 #include "cmGlobalGenerator.h"
+#include "cmGlobalGeneratorFactory.h"
 
 class cmGeneratedFileStream;
 class cmMakefileTargetGenerator;
@@ -54,8 +55,9 @@ class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator
 {
 public:
   cmGlobalUnixMakefileGenerator3();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalUnixMakefileGenerator3; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalUnixMakefileGenerator3>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio10Generator.h

@@ -25,8 +25,9 @@ class cmGlobalVisualStudio10Generator :
 {
 public:
   cmGlobalVisualStudio10Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio10Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio10Generator>(); }
 
   virtual std::string
   GenerateBuildCommand(const char* makeProgram,

+ 3 - 2
Source/cmGlobalVisualStudio10IA64Generator.h

@@ -19,8 +19,9 @@ class cmGlobalVisualStudio10IA64Generator :
 {
 public:
   cmGlobalVisualStudio10IA64Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio10IA64Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio10IA64Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio10Win64Generator.h

@@ -19,8 +19,9 @@ class cmGlobalVisualStudio10Win64Generator :
 {
 public:
   cmGlobalVisualStudio10Win64Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio10Win64Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio10Win64Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio11ARMGenerator.h

@@ -19,8 +19,9 @@ class cmGlobalVisualStudio11ARMGenerator :
 {
 public:
   cmGlobalVisualStudio11ARMGenerator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio11ARMGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio11ARMGenerator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio11Generator.h

@@ -21,8 +21,9 @@ class cmGlobalVisualStudio11Generator:
 {
 public:
   cmGlobalVisualStudio11Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio11Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio11Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio11Win64Generator.h

@@ -19,8 +19,9 @@ class cmGlobalVisualStudio11Win64Generator :
 {
 public:
   cmGlobalVisualStudio11Win64Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio11Win64Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio11Win64Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 4 - 2
Source/cmGlobalVisualStudio6Generator.h

@@ -13,6 +13,7 @@
 #define cmGlobalVisualStudio6Generator_h
 
 #include "cmGlobalVisualStudioGenerator.h"
+#include "cmGlobalGeneratorFactory.h"
 
 class cmTarget;
 
@@ -25,8 +26,9 @@ class cmGlobalVisualStudio6Generator : public cmGlobalVisualStudioGenerator
 {
 public:
   cmGlobalVisualStudio6Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio6Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio6Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio71Generator.h

@@ -24,8 +24,9 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
 {
 public:
   cmGlobalVisualStudio71Generator();
-  static cmGlobalGenerator* New()
-    { return new cmGlobalVisualStudio71Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio71Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 4 - 2
Source/cmGlobalVisualStudio7Generator.h

@@ -13,6 +13,7 @@
 #define cmGlobalVisualStudio7Generator_h
 
 #include "cmGlobalVisualStudioGenerator.h"
+#include "cmGlobalGeneratorFactory.h"
 
 class cmTarget;
 struct cmIDEFlagTable;
@@ -26,8 +27,9 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
 {
 public:
   cmGlobalVisualStudio7Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio7Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio7Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio8Generator.h

@@ -24,8 +24,9 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
 {
 public:
   cmGlobalVisualStudio8Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio8Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio8Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio8Win64Generator.h

@@ -25,8 +25,9 @@ class cmGlobalVisualStudio8Win64Generator :
 {
 public:
   cmGlobalVisualStudio8Win64Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio8Win64Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio8Win64Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio9Generator.h

@@ -25,8 +25,9 @@ class cmGlobalVisualStudio9Generator :
 {
 public:
   cmGlobalVisualStudio9Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio9Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio9Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio9IA64Generator.h

@@ -25,8 +25,9 @@ class cmGlobalVisualStudio9IA64Generator :
 {
 public:
   cmGlobalVisualStudio9IA64Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio9IA64Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio9IA64Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 2
Source/cmGlobalVisualStudio9Win64Generator.h

@@ -25,8 +25,9 @@ class cmGlobalVisualStudio9Win64Generator :
 {
 public:
   cmGlobalVisualStudio9Win64Generator();
-  static cmGlobalGenerator* New() {
-    return new cmGlobalVisualStudio9Win64Generator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalVisualStudio9Win64Generator>(); }
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {

+ 3 - 1
Source/cmGlobalWatcomWMakeGenerator.h

@@ -23,7 +23,9 @@ class cmGlobalWatcomWMakeGenerator : public cmGlobalUnixMakefileGenerator3
 {
 public:
   cmGlobalWatcomWMakeGenerator();
-  static cmGlobalGenerator* New() { return new cmGlobalWatcomWMakeGenerator; }
+  static cmGlobalGeneratorFactory* NewFactory() {
+    return new cmGlobalGeneratorSimpleFactory
+      <cmGlobalWatcomWMakeGenerator>(); }
   ///! Get the name for the generator.
   virtual const char* GetName() const {
     return cmGlobalWatcomWMakeGenerator::GetActualName();}

+ 18 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -20,6 +20,7 @@
 #include "cmSourceFile.h"
 #include "cmCustomCommandGenerator.h"
 #include "cmGeneratorTarget.h"
+#include "cmGlobalGeneratorFactory.h"
 
 #include <cmsys/auto_ptr.hxx>
 
@@ -112,6 +113,15 @@ public:
     }
 };
 
+class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
+{
+public:
+  virtual cmGlobalGenerator* CreateGlobalGenerator() const;
+
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const {
+    cmGlobalXCodeGenerator().GetDocumentation(entry); }
+};
+
 //----------------------------------------------------------------------------
 cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version)
 {
@@ -132,7 +142,14 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version)
 }
 
 //----------------------------------------------------------------------------
-cmGlobalGenerator* cmGlobalXCodeGenerator::New()
+cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory()
+{
+  return new Factory;
+}
+
+//----------------------------------------------------------------------------
+cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
+::CreateGlobalGenerator() const
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   cmXcodeVersionParser parser;

+ 3 - 1
Source/cmGlobalXCodeGenerator.h

@@ -15,6 +15,7 @@
 #include "cmGlobalGenerator.h"
 #include "cmXCodeObject.h"
 #include "cmCustomCommand.h"
+class cmGlobalGeneratorFactory;
 class cmTarget;
 class cmSourceFile;
 class cmSourceGroup;
@@ -29,7 +30,7 @@ class cmGlobalXCodeGenerator : public cmGlobalGenerator
 {
 public:
   cmGlobalXCodeGenerator(std::string const& version);
-  static cmGlobalGenerator* New();
+  static cmGlobalGeneratorFactory* NewFactory();
 
   ///! Get the name for the generator.
   virtual const char* GetName() const {
@@ -186,6 +187,7 @@ private:
                           const char* varNameSuffix,
                           const char* default_flags);
 
+  class Factory;
   class BuildObjectListOrString;
   friend class BuildObjectListOrString;
 

+ 30 - 27
Source/cmake.cxx

@@ -222,6 +222,11 @@ cmake::~cmake()
     {
     delete (*j).second;
     }
+  for(RegisteredGeneratorsMap::iterator j = this->Generators.begin();
+      j != this->Generators.end(); ++j)
+    {
+    delete (*j).second;
+    }
 #ifdef CMAKE_BUILD_WITH_CMAKE
   delete this->VariableWatch;
 #endif
@@ -1904,7 +1909,7 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
       }
   }
 
-  generator = (genIt->second)();
+  generator = genIt->second->CreateGlobalGenerator();
   generator->SetCMakeInstance(this);
   generator->SetExternalMakefileProjectGenerator(extraGenerator);
   return generator;
@@ -2571,54 +2576,54 @@ void cmake::AddDefaultGenerators()
 #if defined(_WIN32) && !defined(__CYGWIN__)
 # if !defined(CMAKE_BOOT_MINGW)
   this->Generators[cmGlobalVisualStudio6Generator::GetActualName()] =
-    &cmGlobalVisualStudio6Generator::New;
+    cmGlobalVisualStudio6Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
-    &cmGlobalVisualStudio7Generator::New;
+    cmGlobalVisualStudio7Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] =
-    &cmGlobalVisualStudio10Generator::New;
+    cmGlobalVisualStudio10Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio10IA64Generator::GetActualName()] =
-    &cmGlobalVisualStudio10IA64Generator::New;
+    cmGlobalVisualStudio10IA64Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] =
-    &cmGlobalVisualStudio10Win64Generator::New;
+    cmGlobalVisualStudio10Win64Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] =
-    &cmGlobalVisualStudio11Generator::New;
+    cmGlobalVisualStudio11Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] =
-    &cmGlobalVisualStudio11Win64Generator::New;
+    cmGlobalVisualStudio11Win64Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio11ARMGenerator::GetActualName()] =
-    &cmGlobalVisualStudio11ARMGenerator::New;
+    cmGlobalVisualStudio11ARMGenerator::NewFactory();
   this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
-    &cmGlobalVisualStudio71Generator::New;
+    cmGlobalVisualStudio71Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] =
-    &cmGlobalVisualStudio8Generator::New;
+    cmGlobalVisualStudio8Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio9Generator::GetActualName()] =
-    &cmGlobalVisualStudio9Generator::New;
+    cmGlobalVisualStudio9Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio9IA64Generator::GetActualName()] =
-    &cmGlobalVisualStudio9IA64Generator::New;
+    cmGlobalVisualStudio9IA64Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio9Win64Generator::GetActualName()] =
-    &cmGlobalVisualStudio9Win64Generator::New;
+    cmGlobalVisualStudio9Win64Generator::NewFactory();
   this->Generators[cmGlobalVisualStudio8Win64Generator::GetActualName()] =
-    &cmGlobalVisualStudio8Win64Generator::New;
+    cmGlobalVisualStudio8Win64Generator::NewFactory();
   this->Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] =
-    &cmGlobalBorlandMakefileGenerator::New;
+    cmGlobalBorlandMakefileGenerator::NewFactory();
   this->Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
-    &cmGlobalNMakeMakefileGenerator::New;
+    cmGlobalNMakeMakefileGenerator::NewFactory();
   this->Generators[cmGlobalJOMMakefileGenerator::GetActualName()] =
-    &cmGlobalJOMMakefileGenerator::New;
+    cmGlobalJOMMakefileGenerator::NewFactory();
   this->Generators[cmGlobalWatcomWMakeGenerator::GetActualName()] =
-    &cmGlobalWatcomWMakeGenerator::New;
+    cmGlobalWatcomWMakeGenerator::NewFactory();
 # endif
   this->Generators[cmGlobalMSYSMakefileGenerator::GetActualName()] =
-    &cmGlobalMSYSMakefileGenerator::New;
+    cmGlobalMSYSMakefileGenerator::NewFactory();
   this->Generators[cmGlobalMinGWMakefileGenerator::GetActualName()] =
-    &cmGlobalMinGWMakefileGenerator::New;
+    cmGlobalMinGWMakefileGenerator::NewFactory();
 #endif
   this->Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] =
-    &cmGlobalUnixMakefileGenerator3::New;
+    cmGlobalUnixMakefileGenerator3::NewFactory();
   this->Generators[cmGlobalNinjaGenerator::GetActualName()] =
-    &cmGlobalNinjaGenerator::New;
+    cmGlobalNinjaGenerator::NewFactory();
 #ifdef CMAKE_USE_XCODE
   this->Generators[cmGlobalXCodeGenerator::GetActualName()] =
-    &cmGlobalXCodeGenerator::New;
+    cmGlobalXCodeGenerator::NewFactory();
 #endif
 }
 
@@ -2716,9 +2721,7 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
       i != this->Generators.end(); ++i)
     {
     cmDocumentationEntry e;
-    cmGlobalGenerator* generator = (i->second)();
-    generator->GetDocumentation(e);
-    delete generator;
+    i->second->GetDocumentation(e);
     v.push_back(e);
     }
   for(RegisteredExtraGeneratorsMap::const_iterator

+ 2 - 3
Source/cmake.h

@@ -17,6 +17,7 @@
 #include "cmPropertyDefinitionMap.h"
 #include "cmPropertyMap.h"
 
+class cmGlobalGeneratorFactory;
 class cmGlobalGenerator;
 class cmLocalGenerator;
 class cmCacheManager;
@@ -396,10 +397,8 @@ protected:
      cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
   typedef std::map<cmStdString,
                 CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
-
-  typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)();
   typedef std::map<cmStdString,
-                   CreateGeneratorFunctionType> RegisteredGeneratorsMap;
+                   cmGlobalGeneratorFactory*> RegisteredGeneratorsMap;
   RegisteredCommandsMap Commands;
   RegisteredGeneratorsMap Generators;
   RegisteredExtraGeneratorsMap ExtraGenerators;