ENH: Registered global generators are now kept in a table in the cmake instance. Added support for documentation with a Generators section.

This commit is contained in:
Brad King 2003-07-07 21:52:10 -04:00
parent cbb1de923a
commit e5ed57ec18
21 changed files with 193 additions and 59 deletions

View File

@ -44,6 +44,14 @@ static const cmDocumentationEntry cmDocumentationCommandsHeader[] =
{0,0,0} {0,0,0}
}; };
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationGeneratorsHeader[] =
{
{0,
"The following generators are available on this platform:", 0},
{0,0,0}
};
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const cmDocumentationEntry cmDocumentationMailingList[] = const cmDocumentationEntry cmDocumentationMailingList[] =
{ {
@ -259,6 +267,13 @@ void cmDocumentation::SetCommandsSection(const cmDocumentationEntry* section)
this->CommandsSection); this->CommandsSection);
} }
//----------------------------------------------------------------------------
void cmDocumentation::SetGeneratorsSection(const cmDocumentationEntry* section)
{
this->SetSection(cmDocumentationGeneratorsHeader, section, 0,
this->GeneratorsSection);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmDocumentation::PrintSection(std::ostream& os, void cmDocumentation::PrintSection(std::ostream& os,
const cmDocumentationEntry* section, const cmDocumentationEntry* section,
@ -720,6 +735,10 @@ void cmDocumentation::CreateFullDocumentation()
{ {
this->AddSection(0, &this->DescriptionSection[0]); this->AddSection(0, &this->DescriptionSection[0]);
} }
if(!this->GeneratorsSection.empty())
{
this->AddSection("Generators", &this->GeneratorsSection[0]);
}
if(!this->OptionsSection.empty()) if(!this->OptionsSection.empty())
{ {
this->AddSection("Command-Line Options", &this->OptionsSection[0]); this->AddSection("Command-Line Options", &this->OptionsSection[0]);
@ -748,6 +767,10 @@ void cmDocumentation::CreateManDocumentation()
{ {
this->AddSection("DESCRIPTION", &this->DescriptionSection[0]); this->AddSection("DESCRIPTION", &this->DescriptionSection[0]);
} }
if(!this->GeneratorsSection.empty())
{
this->AddSection("GENERATORS", &this->GeneratorsSection[0]);
}
if(!this->OptionsSection.empty()) if(!this->OptionsSection.empty())
{ {
this->AddSection("OPTIONS", &this->OptionsSection[0]); this->AddSection("OPTIONS", &this->OptionsSection[0]);

View File

@ -56,6 +56,9 @@ public:
/** Set the listfile commands for standard document generation. */ /** Set the listfile commands for standard document generation. */
void SetCommandsSection(const cmDocumentationEntry*); void SetCommandsSection(const cmDocumentationEntry*);
/** Set the generator descriptions for standard document generation. */
void SetGeneratorsSection(const cmDocumentationEntry*);
// Low-level interface for custom documents: // Low-level interface for custom documents:
/** Forms of documentation output. */ /** Forms of documentation output. */
@ -124,6 +127,7 @@ private:
std::vector<cmDocumentationEntry> DescriptionSection; std::vector<cmDocumentationEntry> DescriptionSection;
std::vector<cmDocumentationEntry> OptionsSection; std::vector<cmDocumentationEntry> OptionsSection;
std::vector<cmDocumentationEntry> CommandsSection; std::vector<cmDocumentationEntry> CommandsSection;
std::vector<cmDocumentationEntry> GeneratorsSection;
std::vector< const char* > Names; std::vector< const char* > Names;
std::vector< const cmDocumentationEntry* > Sections; std::vector< const cmDocumentationEntry* > Sections;

View File

@ -58,3 +58,12 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator()
lg->SetGlobalGenerator(this); lg->SetGlobalGenerator(this);
return lg; return lg;
} }
//----------------------------------------------------------------------------
void cmGlobalBorlandMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.name = this->GetName();
entry.brief = "Generates Borland makefiles.";
entry.full = "";
}

View File

@ -28,11 +28,16 @@ class cmGlobalBorlandMakefileGenerator : public cmGlobalNMakeMakefileGenerator
{ {
public: public:
cmGlobalBorlandMakefileGenerator(); cmGlobalBorlandMakefileGenerator();
static cmGlobalGenerator* New() { return new cmGlobalBorlandMakefileGenerator; }
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() { virtual const char* GetName() const {
return cmGlobalBorlandMakefileGenerator::GetActualName();} return cmGlobalBorlandMakefileGenerator::GetActualName();}
static const char* GetActualName() {return "Borland Makefiles";} 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 ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();

View File

@ -287,3 +287,12 @@ void cmGlobalCodeWarriorGenerator::LocalGenerate()
{ {
this->cmGlobalGenerator::LocalGenerate(); this->cmGlobalGenerator::LocalGenerate();
} }
//----------------------------------------------------------------------------
void cmGlobalCodeWarriorGenerator::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.name = this->GetName();
entry.brief = "Generates CodeWarrior project files.";
entry.full = "";
}

View File

@ -29,11 +29,16 @@ class cmTarget;
class cmGlobalCodeWarriorGenerator : public cmGlobalGenerator class cmGlobalCodeWarriorGenerator : public cmGlobalGenerator
{ {
public: public:
static cmGlobalGenerator* New() { return new cmGlobalCodeWarriorGenerator; }
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() { virtual const char* GetName() const {
return cmGlobalCodeWarriorGenerator::GetActualName();} return cmGlobalCodeWarriorGenerator::GetActualName();}
static const char* GetActualName() {return "Code Warrior Not Working";} 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 ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();

View File

@ -519,3 +519,10 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
} }
} }
//----------------------------------------------------------------------------
void cmGlobalGenerator::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.name = this->GetName();
entry.brief = "";
entry.full = "";
}

View File

@ -41,7 +41,10 @@ public:
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();
///! Get the name for this generator ///! 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 * Create LocalGenerators and process the CMakeLists files. This does not

View File

@ -42,3 +42,11 @@ cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator()
lg->SetGlobalGenerator(this); lg->SetGlobalGenerator(this);
return lg; return lg;
} }
//----------------------------------------------------------------------------
void cmGlobalNMakeMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.name = this->GetName();
entry.brief = "Generates NMake makefiles.";
entry.full = "";
}

View File

@ -28,11 +28,15 @@ class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator
{ {
public: public:
cmGlobalNMakeMakefileGenerator(); cmGlobalNMakeMakefileGenerator();
static cmGlobalGenerator* New() { return new cmGlobalNMakeMakefileGenerator; }
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() { virtual const char* GetName() const {
return cmGlobalNMakeMakefileGenerator::GetActualName();} return cmGlobalNMakeMakefileGenerator::GetActualName();}
static const char* GetActualName() {return "NMake Makefiles";} 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 ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();

View File

@ -94,3 +94,10 @@ cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator()
return lg; return lg;
} }
//----------------------------------------------------------------------------
void cmGlobalUnixMakefileGenerator::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.name = this->GetName();
entry.brief = "Generates standard UNIX makefiles.";
entry.full = "full UNIX!";
}

View File

@ -28,11 +28,16 @@ class cmGlobalUnixMakefileGenerator : public cmGlobalGenerator
{ {
public: public:
cmGlobalUnixMakefileGenerator(); cmGlobalUnixMakefileGenerator();
static cmGlobalGenerator* New() { return new cmGlobalUnixMakefileGenerator; }
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() { virtual const char* GetName() const {
return cmGlobalUnixMakefileGenerator::GetActualName();} return cmGlobalUnixMakefileGenerator::GetActualName();}
static const char* GetActualName() {return "Unix Makefiles";} 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 ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();

View File

@ -447,3 +447,11 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout)
fout << "Microsoft Developer Studio Workspace File, Format Version 6.00\n"; fout << "Microsoft Developer Studio Workspace File, Format Version 6.00\n";
fout << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\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 = "";
}

View File

@ -30,12 +30,16 @@ class cmGlobalVisualStudio6Generator : public cmGlobalGenerator
{ {
public: public:
cmGlobalVisualStudio6Generator(); cmGlobalVisualStudio6Generator();
static cmGlobalGenerator* New() { return new cmGlobalVisualStudio6Generator; }
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() { virtual const char* GetName() const {
return cmGlobalVisualStudio6Generator::GetActualName();} return cmGlobalVisualStudio6Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 6";} 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 ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();

View File

@ -282,4 +282,10 @@ void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout)
fout << "Microsoft Visual Studio Solution File, Format Version 8.00\n"; 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 = "";
}

View File

@ -29,11 +29,16 @@ class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
{ {
public: public:
cmGlobalVisualStudio71Generator(); cmGlobalVisualStudio71Generator();
static cmGlobalGenerator* New() { return new cmGlobalVisualStudio71Generator; }
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() { virtual const char* GetName() const {
return cmGlobalVisualStudio71Generator::GetActualName();} return cmGlobalVisualStudio71Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 7 .NET 2003";} 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 ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(); virtual cmLocalGenerator *CreateLocalGenerator();

View File

@ -584,3 +584,11 @@ std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
{ {
return &m_Configurations; return &m_Configurations;
}; };
//----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.name = this->GetName();
entry.brief = "Generates Visual Studio .NET 2002 project files.";
entry.full = "";
}

View File

@ -30,14 +30,19 @@ class cmGlobalVisualStudio7Generator : public cmGlobalGenerator
{ {
public: public:
cmGlobalVisualStudio7Generator(); cmGlobalVisualStudio7Generator();
static cmGlobalGenerator* New() { return new cmGlobalVisualStudio7Generator; }
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() { virtual const char* GetName() const {
return cmGlobalVisualStudio7Generator::GetActualName();} return cmGlobalVisualStudio7Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 7";} static const char* GetActualName() {return "Visual Studio 7";}
///! Create a local generator appropriate to this Global Generator ///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator(); 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 * Try to determine system infomation such as shared library
* extension, pthreads, byte order etc. * extension, pthreads, byte order etc.

View File

@ -94,6 +94,7 @@ cmake::cmake()
m_ProgressCallbackClientData = 0; m_ProgressCallbackClientData = 0;
m_VariableWatch = new cmVariableWatch; m_VariableWatch = new cmVariableWatch;
this->AddDefaultGenerators();
this->AddDefaultCommands(); this->AddDefaultCommands();
m_VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN", 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) void cmake::GetRegisteredGenerators(std::vector<std::string>& names)
{ {
#if defined(_WIN32) && !defined(__CYGWIN__) for(RegisteredGeneratorsMap::const_iterator i = m_Generators.begin();
names.push_back(cmGlobalVisualStudio6Generator::GetActualName()); i != m_Generators.end(); ++i)
names.push_back(cmGlobalVisualStudio7Generator::GetActualName()); {
names.push_back(cmGlobalVisualStudio71Generator::GetActualName()); names.push_back(i->first);
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
} }
cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name) cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
{ {
cmGlobalGenerator *ret = 0; RegisteredGeneratorsMap::const_iterator i = m_Generators.find(name);
#if defined(_WIN32) && !defined(__CYGWIN__) if(i != m_Generators.end())
if (!strcmp(name,cmGlobalNMakeMakefileGenerator::GetActualName()))
{ {
ret = new cmGlobalNMakeMakefileGenerator; cmGlobalGenerator* generator = (i->second)();
ret->SetCMakeInstance(this); generator->SetCMakeInstance(this);
return generator;
} }
if (!strcmp(name,cmGlobalVisualStudio6Generator::GetActualName())) else
{ {
ret = new cmGlobalVisualStudio6Generator; return 0;
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()))
{
ret = new cmGlobalUnixMakefileGenerator;
ret->SetCMakeInstance(this);
}
#endif
return ret;
} }
void cmake::SetHomeDirectory(const char* dir) 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() int cmake::LoadCache()
{ {
m_CacheManager->LoadCache(this->GetHomeOutputDirectory()); m_CacheManager->LoadCache(this->GetHomeOutputDirectory());
@ -1188,3 +1174,18 @@ void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const
cmDocumentationEntry empty = {0,0,0}; cmDocumentationEntry empty = {0,0,0};
v.push_back(empty); 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);
}

View File

@ -235,14 +235,19 @@ class cmake
cmVariableWatch* GetVariableWatch() { return m_VariableWatch; } cmVariableWatch* GetVariableWatch() { return m_VariableWatch; }
void GetCommandDocumentation(std::vector<cmDocumentationEntry>&) const; void GetCommandDocumentation(std::vector<cmDocumentationEntry>&) const;
void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
///! Do all the checks before running configure ///! Do all the checks before running configure
int DoPreConfigureChecks(); int DoPreConfigureChecks();
protected: protected:
typedef cmGlobalGenerator* (*CreateGeneratorFunctionType)();
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap; typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
typedef std::map<cmStdString, CreateGeneratorFunctionType> RegisteredGeneratorsMap;
RegisteredCommandsMap m_Commands; RegisteredCommandsMap m_Commands;
RegisteredGeneratorsMap m_Generators;
void AddDefaultCommands(); void AddDefaultCommands();
void AddDefaultGenerators();
cmGlobalGenerator *m_GlobalGenerator; cmGlobalGenerator *m_GlobalGenerator;
cmCacheManager *m_CacheManager; cmCacheManager *m_CacheManager;

View File

@ -98,10 +98,13 @@ int do_cmake(int ac, char** av)
// Construct and print requested documentation. // Construct and print requested documentation.
cmake hcm; cmake hcm;
std::vector<cmDocumentationEntry> commands; std::vector<cmDocumentationEntry> commands;
std::vector<cmDocumentationEntry> generators;
hcm.GetCommandDocumentation(commands); hcm.GetCommandDocumentation(commands);
hcm.GetGeneratorDocumentation(generators);
doc.SetNameSection(cmDocumentationName); doc.SetNameSection(cmDocumentationName);
doc.SetUsageSection(cmDocumentationUsage); doc.SetUsageSection(cmDocumentationUsage);
doc.SetDescriptionSection(cmDocumentationDescription); doc.SetDescriptionSection(cmDocumentationDescription);
doc.SetGeneratorsSection(&generators[0]);
doc.SetOptionsSection(cmDocumentationOptions); doc.SetOptionsSection(cmDocumentationOptions);
doc.SetCommandsSection(&commands[0]); doc.SetCommandsSection(&commands[0]);
doc.PrintDocumentation(ht, std::cout); doc.PrintDocumentation(ht, std::cout);