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}
};
//----------------------------------------------------------------------------
static const cmDocumentationEntry cmDocumentationGeneratorsHeader[] =
{
{0,
"The following generators are available on this platform:", 0},
{0,0,0}
};
//----------------------------------------------------------------------------
const cmDocumentationEntry cmDocumentationMailingList[] =
{
@ -259,6 +267,13 @@ void cmDocumentation::SetCommandsSection(const cmDocumentationEntry* section)
this->CommandsSection);
}
//----------------------------------------------------------------------------
void cmDocumentation::SetGeneratorsSection(const cmDocumentationEntry* section)
{
this->SetSection(cmDocumentationGeneratorsHeader, section, 0,
this->GeneratorsSection);
}
//----------------------------------------------------------------------------
void cmDocumentation::PrintSection(std::ostream& os,
const cmDocumentationEntry* section,
@ -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]);

View File

@ -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;

View File

@ -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 = "";
}

View File

@ -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();

View File

@ -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 = "";
}

View File

@ -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();

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();
///! 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

View File

@ -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 = "";
}

View File

@ -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();

View File

@ -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!";
}

View File

@ -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();

View File

@ -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 = "";
}

View File

@ -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();

View File

@ -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 = "";
}

View File

@ -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();

View File

@ -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 = "";
}

View File

@ -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.

View File

@ -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()))
else
{
ret = new cmGlobalVisualStudio6Generator;
ret->SetCMakeInstance(this);
return 0;
}
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)
@ -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);
}

View File

@ -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;

View File

@ -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);