moved commands into cmake
This commit is contained in:
parent
38e412626b
commit
9149cdd078
|
@ -19,6 +19,8 @@
|
||||||
#include "cmCacheManager.h"
|
#include "cmCacheManager.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmLocalGenerator.h"
|
#include "cmLocalGenerator.h"
|
||||||
|
#include "cmCommands.h"
|
||||||
|
#include "cmCommand.h"
|
||||||
|
|
||||||
// include the generator
|
// include the generator
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
@ -35,6 +37,7 @@ cmake::cmake()
|
||||||
m_Verbose = false;
|
m_Verbose = false;
|
||||||
m_CacheManager = new cmCacheManager;
|
m_CacheManager = new cmCacheManager;
|
||||||
m_GlobalGenerator = 0;
|
m_GlobalGenerator = 0;
|
||||||
|
this->AddDefaultCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmake::~cmake()
|
cmake::~cmake()
|
||||||
|
@ -45,8 +48,34 @@ cmake::~cmake()
|
||||||
delete m_GlobalGenerator;
|
delete m_GlobalGenerator;
|
||||||
m_GlobalGenerator = 0;
|
m_GlobalGenerator = 0;
|
||||||
}
|
}
|
||||||
|
for(RegisteredCommandsMap::iterator j = m_Commands.begin();
|
||||||
|
j != m_Commands.end(); ++j)
|
||||||
|
{
|
||||||
|
delete (*j).second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmake::CommandExists(const char* name) const
|
||||||
|
{
|
||||||
|
return (m_Commands.find(name) != m_Commands.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
cmCommand *cmake::GetCommand(const char *name)
|
||||||
|
{
|
||||||
|
cmCommand* rm = 0;
|
||||||
|
RegisteredCommandsMap::iterator pos = m_Commands.find(name);
|
||||||
|
if (pos != m_Commands.end())
|
||||||
|
{
|
||||||
|
rm = (*pos).second;
|
||||||
|
}
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmake::AddCommand(cmCommand* wg)
|
||||||
|
{
|
||||||
|
std::string name = wg->GetName();
|
||||||
|
m_Commands.insert( RegisteredCommandsMap::value_type(name, wg));
|
||||||
|
}
|
||||||
|
|
||||||
void cmake::Usage(const char* program)
|
void cmake::Usage(const char* program)
|
||||||
{
|
{
|
||||||
|
@ -811,3 +840,40 @@ const char* cmake::GetCacheDefinition(const char* name) const
|
||||||
{
|
{
|
||||||
return m_CacheManager->GetCacheValue(name);
|
return m_CacheManager->GetCacheValue(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cmake::DumpDocumentationToFile(std::ostream& f)
|
||||||
|
{
|
||||||
|
// Loop over all registered commands and print out documentation
|
||||||
|
const char *name;
|
||||||
|
const char *terse;
|
||||||
|
const char *full;
|
||||||
|
char tmp[1024];
|
||||||
|
sprintf(tmp,"Version %d.%d", cmake::GetMajorVersion(),
|
||||||
|
cmake::GetMinorVersion());
|
||||||
|
f << "<html>\n";
|
||||||
|
f << "<h1>Documentation for commands of CMake " << tmp << "</h1>\n";
|
||||||
|
f << "<ul>\n";
|
||||||
|
for(RegisteredCommandsMap::iterator j = m_Commands.begin();
|
||||||
|
j != m_Commands.end(); ++j)
|
||||||
|
{
|
||||||
|
name = (*j).second->GetName();
|
||||||
|
terse = (*j).second->GetTerseDocumentation();
|
||||||
|
full = (*j).second->GetFullDocumentation();
|
||||||
|
f << "<li><b>" << name << "</b> - " << terse << std::endl
|
||||||
|
<< "<br><i>Usage:</i> " << full << "</li>" << std::endl << std::endl;
|
||||||
|
}
|
||||||
|
f << "</ul></html>\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmake::AddDefaultCommands()
|
||||||
|
{
|
||||||
|
std::list<cmCommand*> commands;
|
||||||
|
GetPredefinedCommands(commands);
|
||||||
|
for(std::list<cmCommand*>::iterator i = commands.begin();
|
||||||
|
i != commands.end(); ++i)
|
||||||
|
{
|
||||||
|
this->AddCommand(*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ class cmGlobalGenerator;
|
||||||
class cmLocalGenerator;
|
class cmLocalGenerator;
|
||||||
class cmCacheManager;
|
class cmCacheManager;
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
|
class cmCommand;
|
||||||
|
|
||||||
class cmake
|
class cmake
|
||||||
{
|
{
|
||||||
|
@ -89,6 +90,12 @@ class cmake
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump documentation to a file. If 0 is returned, the
|
||||||
|
* operation failed.
|
||||||
|
*/
|
||||||
|
int DumpDocumentationToFile(std::ostream&);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a command line invocation of cmake.
|
* Handle a command line invocation of cmake.
|
||||||
*/
|
*/
|
||||||
|
@ -140,6 +147,19 @@ class cmake
|
||||||
*/
|
*/
|
||||||
static int CMakeCommand(std::vector<std::string>&);
|
static int CMakeCommand(std::vector<std::string>&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a command to this cmake instance
|
||||||
|
*/
|
||||||
|
void AddCommand(cmCommand* );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a command by its name
|
||||||
|
*/
|
||||||
|
cmCommand *GetCommand(const char *name);
|
||||||
|
|
||||||
|
/** Check if a command exists. */
|
||||||
|
bool CommandExists(const char* name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is cmake in the process of a local cmake invocation. If so, we know the
|
* Is cmake in the process of a local cmake invocation. If so, we know the
|
||||||
* cache is already configured and ready to go.
|
* cache is already configured and ready to go.
|
||||||
|
@ -156,6 +176,10 @@ class cmake
|
||||||
void SetArgs(const std::vector<std::string>&);
|
void SetArgs(const std::vector<std::string>&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
|
||||||
|
RegisteredCommandsMap m_Commands;
|
||||||
|
void AddDefaultCommands();
|
||||||
|
|
||||||
cmGlobalGenerator *m_GlobalGenerator;
|
cmGlobalGenerator *m_GlobalGenerator;
|
||||||
cmCacheManager *m_CacheManager;
|
cmCacheManager *m_CacheManager;
|
||||||
std::string m_cmHomeDirectory;
|
std::string m_cmHomeDirectory;
|
||||||
|
|
Loading…
Reference in New Issue