From e5ed57ec18e1cd1d460bd77391db15a5d4afdcc1 Mon Sep 17 00:00:00 2001
From: Brad King <brad.king@kitware.com>
Date: Mon, 7 Jul 2003 21:52:10 -0400
Subject: ENH: Registered global generators are now kept in a table in the
 cmake instance.  Added support for documentation with a Generators section.

---
 Source/cmDocumentation.cxx                  |  23 +++++++
 Source/cmDocumentation.h                    |   4 ++
 Source/cmGlobalBorlandMakefileGenerator.cxx |   9 +++
 Source/cmGlobalBorlandMakefileGenerator.h   |   7 +-
 Source/cmGlobalCodeWarriorGenerator.cxx     |   9 +++
 Source/cmGlobalCodeWarriorGenerator.h       |   7 +-
 Source/cmGlobalGenerator.cxx                |   7 ++
 Source/cmGlobalGenerator.h                  |   5 +-
 Source/cmGlobalNMakeMakefileGenerator.cxx   |   8 +++
 Source/cmGlobalNMakeMakefileGenerator.h     |   6 +-
 Source/cmGlobalUnixMakefileGenerator.cxx    |   7 ++
 Source/cmGlobalUnixMakefileGenerator.h      |   7 +-
 Source/cmGlobalVisualStudio6Generator.cxx   |   8 +++
 Source/cmGlobalVisualStudio6Generator.h     |   6 +-
 Source/cmGlobalVisualStudio71Generator.cxx  |   8 ++-
 Source/cmGlobalVisualStudio71Generator.h    |   7 +-
 Source/cmGlobalVisualStudio7Generator.cxx   |   8 +++
 Source/cmGlobalVisualStudio7Generator.h     |   7 +-
 Source/cmake.cxx                            | 101 ++++++++++++++--------------
 Source/cmake.h                              |   5 ++
 Source/cmakemain.cxx                        |   3 +
 21 files changed, 193 insertions(+), 59 deletions(-)

diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 121afc7..0e853d9 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -45,6 +45,14 @@ static const cmDocumentationEntry cmDocumentationCommandsHeader[] =
 };
 
 //----------------------------------------------------------------------------
+static const cmDocumentationEntry cmDocumentationGeneratorsHeader[] =
+{
+  {0,
+   "The following generators are available on this platform:", 0},
+  {0,0,0}
+};
+
+//----------------------------------------------------------------------------
 const cmDocumentationEntry cmDocumentationMailingList[] =
 {
   {0,
@@ -260,6 +268,13 @@ void cmDocumentation::SetCommandsSection(const cmDocumentationEntry* section)
 }
 
 //----------------------------------------------------------------------------
+void cmDocumentation::SetGeneratorsSection(const cmDocumentationEntry* section)
+{
+  this->SetSection(cmDocumentationGeneratorsHeader, section, 0,
+                   this->GeneratorsSection);
+}
+
+//----------------------------------------------------------------------------
 void cmDocumentation::PrintSection(std::ostream& os,
                                    const cmDocumentationEntry* section,
                                    const char* name)
@@ -720,6 +735,10 @@ void cmDocumentation::CreateFullDocumentation()
     {
     this->AddSection(0, &this->DescriptionSection[0]);
     }
+  if(!this->GeneratorsSection.empty())
+    {
+    this->AddSection("Generators", &this->GeneratorsSection[0]);
+    }
   if(!this->OptionsSection.empty())
     {
     this->AddSection("Command-Line Options", &this->OptionsSection[0]);
@@ -748,6 +767,10 @@ void cmDocumentation::CreateManDocumentation()
     {
     this->AddSection("DESCRIPTION", &this->DescriptionSection[0]);
     }
+  if(!this->GeneratorsSection.empty())
+    {
+    this->AddSection("GENERATORS", &this->GeneratorsSection[0]);
+    }
   if(!this->OptionsSection.empty())
     {
     this->AddSection("OPTIONS", &this->OptionsSection[0]);
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index 5e507a0..b5cf85c 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -56,6 +56,9 @@ public:
   /** Set the listfile commands for standard document generation.  */
   void SetCommandsSection(const cmDocumentationEntry*);
   
+  /** Set the generator descriptions for standard document generation.  */
+  void SetGeneratorsSection(const cmDocumentationEntry*);
+  
   // Low-level interface for custom documents:
   
   /** Forms of documentation output.  */
@@ -124,6 +127,7 @@ private:
   std::vector<cmDocumentationEntry> DescriptionSection;
   std::vector<cmDocumentationEntry> OptionsSection;
   std::vector<cmDocumentationEntry> CommandsSection;
+  std::vector<cmDocumentationEntry> GeneratorsSection;
   
   std::vector< const char* > Names;
   std::vector< const cmDocumentationEntry* > Sections;
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index baf8807..5d9b6c3 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -58,3 +58,12 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator()
   lg->SetGlobalGenerator(this);
   return lg;
 }
+
+
+//----------------------------------------------------------------------------
+void cmGlobalBorlandMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "Generates Borland makefiles.";
+  entry.full = "";
+}
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 7f66932..6f5b64e 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -28,11 +28,16 @@ class cmGlobalBorlandMakefileGenerator : public cmGlobalNMakeMakefileGenerator
 {
 public:
   cmGlobalBorlandMakefileGenerator();
+  static cmGlobalGenerator* New() { return new cmGlobalBorlandMakefileGenerator; }
+  
   ///! Get the name for the generator.
-  virtual const char* GetName() {
+  virtual const char* GetName() const {
     return cmGlobalBorlandMakefileGenerator::GetActualName();}
   static const char* GetActualName() {return "Borland Makefiles";}
 
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
+  
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
diff --git a/Source/cmGlobalCodeWarriorGenerator.cxx b/Source/cmGlobalCodeWarriorGenerator.cxx
index 828199d..91ff5b3 100644
--- a/Source/cmGlobalCodeWarriorGenerator.cxx
+++ b/Source/cmGlobalCodeWarriorGenerator.cxx
@@ -287,3 +287,12 @@ void cmGlobalCodeWarriorGenerator::LocalGenerate()
 {
   this->cmGlobalGenerator::LocalGenerate();
 }
+
+
+//----------------------------------------------------------------------------
+void cmGlobalCodeWarriorGenerator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "Generates CodeWarrior project files.";
+  entry.full = "";
+}
diff --git a/Source/cmGlobalCodeWarriorGenerator.h b/Source/cmGlobalCodeWarriorGenerator.h
index 2981efd..d4859ad 100644
--- a/Source/cmGlobalCodeWarriorGenerator.h
+++ b/Source/cmGlobalCodeWarriorGenerator.h
@@ -29,11 +29,16 @@ class cmTarget;
 class cmGlobalCodeWarriorGenerator : public cmGlobalGenerator
 {
 public:
+  static cmGlobalGenerator* New() { return new cmGlobalCodeWarriorGenerator; }
+  
   ///! Get the name for the generator.
-  virtual const char* GetName() {
+  virtual const char* GetName() const {
     return cmGlobalCodeWarriorGenerator::GetActualName();}
   static const char* GetActualName() {return "Code Warrior Not Working";}
 
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
+  
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6699638..48251f1 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -519,3 +519,10 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
     }
 }
 
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "";
+  entry.full = "";
+}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 8b9176c..54efa76 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -41,7 +41,10 @@ public:
   virtual cmLocalGenerator *CreateLocalGenerator();
 
   ///! Get the name for this generator
-  virtual const char *GetName() { return "Generic"; };
+  virtual const char *GetName() const { return "Generic"; };
+  
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
   
   /**
    * Create LocalGenerators and process the CMakeLists files. This does not
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index abf3426..a1db99f 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -42,3 +42,11 @@ cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator()
   lg->SetGlobalGenerator(this);
   return lg;
 }
+
+//----------------------------------------------------------------------------
+void cmGlobalNMakeMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "Generates NMake makefiles.";
+  entry.full = "";
+}
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index 1c233c6..4647c2d 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -28,11 +28,15 @@ class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator
 {
 public:
   cmGlobalNMakeMakefileGenerator();
+  static cmGlobalGenerator* New() { return new cmGlobalNMakeMakefileGenerator; }
   ///! Get the name for the generator.
-  virtual const char* GetName() {
+  virtual const char* GetName() const {
     return cmGlobalNMakeMakefileGenerator::GetActualName();}
   static const char* GetActualName() {return "NMake Makefiles";}
 
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
+  
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
diff --git a/Source/cmGlobalUnixMakefileGenerator.cxx b/Source/cmGlobalUnixMakefileGenerator.cxx
index d11954e..1a71cc4 100644
--- a/Source/cmGlobalUnixMakefileGenerator.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator.cxx
@@ -94,3 +94,10 @@ cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator()
   return lg;
 }
 
+//----------------------------------------------------------------------------
+void cmGlobalUnixMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "Generates standard UNIX makefiles.";
+  entry.full = "full UNIX!";
+}
diff --git a/Source/cmGlobalUnixMakefileGenerator.h b/Source/cmGlobalUnixMakefileGenerator.h
index 43abe57..77a781e 100644
--- a/Source/cmGlobalUnixMakefileGenerator.h
+++ b/Source/cmGlobalUnixMakefileGenerator.h
@@ -28,11 +28,16 @@ class cmGlobalUnixMakefileGenerator : public cmGlobalGenerator
 {
 public:
   cmGlobalUnixMakefileGenerator();
+  static cmGlobalGenerator* New() { return new cmGlobalUnixMakefileGenerator; }
+
   ///! Get the name for the generator.
-  virtual const char* GetName() {
+  virtual const char* GetName() const {
     return cmGlobalUnixMakefileGenerator::GetActualName();}
   static const char* GetActualName() {return "Unix Makefiles";}
 
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
+  
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 2189679..233a9e2 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -447,3 +447,11 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout)
   fout << "Microsoft Developer Studio Workspace File, Format Version 6.00\n";
   fout << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n";
 }
+
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudio6Generator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "Generates Visual Studio 6 project files.";
+  entry.full = "";
+}
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
index be2dfd9..4df1a70 100644
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ b/Source/cmGlobalVisualStudio6Generator.h
@@ -30,12 +30,16 @@ class cmGlobalVisualStudio6Generator : public cmGlobalGenerator
 {
 public:
   cmGlobalVisualStudio6Generator();
+  static cmGlobalGenerator* New() { return new cmGlobalVisualStudio6Generator; }
   
   ///! Get the name for the generator.
-  virtual const char* GetName() {
+  virtual const char* GetName() const {
     return cmGlobalVisualStudio6Generator::GetActualName();}
   static const char* GetActualName() {return "Visual Studio 6";}
 
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
+  
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 4564901..09b7392 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -282,4 +282,10 @@ void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout)
   fout << "Microsoft Visual Studio Solution File, Format Version 8.00\n";
 }
 
-
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudio71Generator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "Generates Visual Studio .NET 2003 project files.";
+  entry.full = "";
+}
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 306ad9b..6acb562 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -29,11 +29,16 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
 {
 public:
   cmGlobalVisualStudio71Generator();
+  static cmGlobalGenerator* New() { return new cmGlobalVisualStudio71Generator; }
+  
   ///! Get the name for the generator.
-  virtual const char* GetName() {
+  virtual const char* GetName() const {
     return cmGlobalVisualStudio71Generator::GetActualName();}
   static const char* GetActualName() {return "Visual Studio 7 .NET 2003";}
 
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
+  
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index c7d0324..4486f3c 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -584,3 +584,11 @@ std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
 {
   return &m_Configurations;
 };
+
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudio7Generator::GetDocumentation(cmDocumentationEntry& entry) const
+{
+  entry.name = this->GetName();
+  entry.brief = "Generates Visual Studio .NET 2002 project files.";
+  entry.full = "";
+}
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index c703bea..a268a44 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -30,14 +30,19 @@ class cmGlobalVisualStudio7Generator : public cmGlobalGenerator
 {
 public:
   cmGlobalVisualStudio7Generator();
+  static cmGlobalGenerator* New() { return new cmGlobalVisualStudio7Generator; }
+  
   ///! Get the name for the generator.
-  virtual const char* GetName() {
+  virtual const char* GetName() const {
     return cmGlobalVisualStudio7Generator::GetActualName();}
   static const char* GetActualName() {return "Visual Studio 7";}
 
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
 
+  /** Get the documentation entry for this generator.  */
+  virtual void GetDocumentation(cmDocumentationEntry& entry) const;
+  
   /**
    * Try to determine system infomation such as shared library
    * extension, pthreads, byte order etc.  
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 22e747f..f073271 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -94,6 +94,7 @@ cmake::cmake()
   m_ProgressCallbackClientData = 0;
   m_VariableWatch = new cmVariableWatch;
 
+  this->AddDefaultGenerators();
   this->AddDefaultCommands();
 
   m_VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN",
@@ -662,64 +663,26 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
 
 void cmake::GetRegisteredGenerators(std::vector<std::string>& names)
 {
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  names.push_back(cmGlobalVisualStudio6Generator::GetActualName());
-  names.push_back(cmGlobalVisualStudio7Generator::GetActualName());
-  names.push_back(cmGlobalVisualStudio71Generator::GetActualName());
-  names.push_back(cmGlobalBorlandMakefileGenerator::GetActualName());
-  names.push_back(cmGlobalNMakeMakefileGenerator::GetActualName());
-#else
-#if defined(__APPLE__) && defined(CMAKE_BUILD_WITH_CMAKE)
-  names.push_back(cmGlobalCodeWarriorGenerator::GetActualName());
-#endif
-  names.push_back(cmGlobalUnixMakefileGenerator::GetActualName());
-#endif
+  for(RegisteredGeneratorsMap::const_iterator i = m_Generators.begin();
+      i != m_Generators.end(); ++i)
+    {
+    names.push_back(i->first);
+    }
 }
 
 cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
 {
-  cmGlobalGenerator *ret = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  if (!strcmp(name,cmGlobalNMakeMakefileGenerator::GetActualName()))
+  RegisteredGeneratorsMap::const_iterator i = m_Generators.find(name);
+  if(i != m_Generators.end())
     {
-    ret = new cmGlobalNMakeMakefileGenerator;
-    ret->SetCMakeInstance(this);
+    cmGlobalGenerator* generator = (i->second)();
+    generator->SetCMakeInstance(this);
+    return generator;
     }
-  if (!strcmp(name,cmGlobalVisualStudio6Generator::GetActualName()))
-    {
-    ret = new cmGlobalVisualStudio6Generator;
-    ret->SetCMakeInstance(this);
-    }
-  if (!strcmp(name,cmGlobalVisualStudio7Generator::GetActualName()))
-    {
-    ret = new cmGlobalVisualStudio7Generator;
-    ret->SetCMakeInstance(this);
-    } 
-  if (!strcmp(name,cmGlobalVisualStudio71Generator::GetActualName()))
-    {
-    ret = new cmGlobalVisualStudio71Generator;
-    ret->SetCMakeInstance(this);
-    } 
-  if (!strcmp(name,cmGlobalBorlandMakefileGenerator::GetActualName()))
-    {
-    ret = new cmGlobalBorlandMakefileGenerator;
-    ret->SetCMakeInstance(this);
-    }
-#else
-#if defined(__APPLE__) && defined(CMAKE_BUILD_WITH_CMAKE)
-  if (!strcmp(name,cmGlobalCodeWarriorGenerator::GetActualName()))
-    {
-    ret = new cmGlobalCodeWarriorGenerator;
-    ret->SetCMakeInstance(this);
-    }
-#endif
-  if (!strcmp(name,cmGlobalUnixMakefileGenerator::GetActualName()))
+  else
     {
-    ret = new cmGlobalUnixMakefileGenerator;
-    ret->SetCMakeInstance(this);
+    return 0;
     }
-#endif
-  return ret;
 }
 
 void cmake::SetHomeDirectory(const char* dir) 
@@ -1126,6 +1089,29 @@ void cmake::AddDefaultCommands()
     }
 }
 
+void cmake::AddDefaultGenerators()
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  m_Generators[cmGlobalVisualStudio6Generator::GetActualName()] =
+    &cmGlobalVisualStudio6Generator::New;
+  m_Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
+    &cmGlobalVisualStudio7Generator::New;
+  m_Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
+    &cmGlobalVisualStudio71Generator::New;
+  m_Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] =
+    &cmGlobalBorlandMakefileGenerator::New;
+  m_Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
+    &cmGlobalNMakeMakefileGenerator::New;
+#else
+# if defined(__APPLE__) && defined(CMAKE_BUILD_WITH_CMAKE)
+  m_Generators[cmGlobalCodeWarriorGenerator::GetActualName()] =
+    &cmGlobalCodeWarriorGenerator::New;
+# endif
+  m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] =
+    &cmGlobalUnixMakefileGenerator::New;
+#endif
+}
+
 int cmake::LoadCache()
 {
   m_CacheManager->LoadCache(this->GetHomeOutputDirectory());
@@ -1188,3 +1174,18 @@ void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const
   cmDocumentationEntry empty = {0,0,0};
   v.push_back(empty);
 }
+
+void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
+{
+  for(RegisteredGeneratorsMap::const_iterator i = m_Generators.begin();
+      i != m_Generators.end(); ++i)
+    {
+    cmDocumentationEntry e;
+    cmGlobalGenerator* generator = (i->second)();
+    generator->GetDocumentation(e);
+    delete generator;
+    v.push_back(e);
+    }
+  cmDocumentationEntry empty = {0,0,0};
+  v.push_back(empty);
+}
diff --git a/Source/cmake.h b/Source/cmake.h
index f01c065..35c3c3f 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -235,14 +235,19 @@ class cmake
   cmVariableWatch* GetVariableWatch() { return m_VariableWatch; }
 
   void GetCommandDocumentation(std::vector<cmDocumentationEntry>&) const;
+  void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
 
   ///! Do all the checks before running configure
   int DoPreConfigureChecks();
   
 protected:
+  typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)();
   typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
+  typedef std::map<cmStdString, CreateGeneratorFunctionType> RegisteredGeneratorsMap;
   RegisteredCommandsMap m_Commands;
+  RegisteredGeneratorsMap m_Generators;
   void AddDefaultCommands();
+  void AddDefaultGenerators();
 
   cmGlobalGenerator *m_GlobalGenerator;
   cmCacheManager *m_CacheManager;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 299a954..0d35894 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -98,10 +98,13 @@ int do_cmake(int ac, char** av)
     // Construct and print requested documentation.
     cmake hcm;
     std::vector<cmDocumentationEntry> commands;
+    std::vector<cmDocumentationEntry> generators;
     hcm.GetCommandDocumentation(commands);
+    hcm.GetGeneratorDocumentation(generators);
     doc.SetNameSection(cmDocumentationName);
     doc.SetUsageSection(cmDocumentationUsage);
     doc.SetDescriptionSection(cmDocumentationDescription);
+    doc.SetGeneratorsSection(&generators[0]);
     doc.SetOptionsSection(cmDocumentationOptions);
     doc.SetCommandsSection(&commands[0]);
     doc.PrintDocumentation(ht, std::cout);
-- 
cgit v0.12