summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2002-09-10 20:51:29 (GMT)
committerKen Martin <ken.martin@kitware.com>2002-09-10 20:51:29 (GMT)
commit9149cdd078a1f1ab03eb0a60d30628aeb2395023 (patch)
tree998ee59b89e278926ec862721c31a0b270c619a3 /Source/cmake.cxx
parent38e412626b604d7f79cac82153047fc59b55597f (diff)
downloadCMake-9149cdd078a1f1ab03eb0a60d30628aeb2395023.zip
CMake-9149cdd078a1f1ab03eb0a60d30628aeb2395023.tar.gz
CMake-9149cdd078a1f1ab03eb0a60d30628aeb2395023.tar.bz2
moved commands into cmake
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx66
1 files changed, 66 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index d816726..5ed7183 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -19,6 +19,8 @@
#include "cmCacheManager.h"
#include "cmMakefile.h"
#include "cmLocalGenerator.h"
+#include "cmCommands.h"
+#include "cmCommand.h"
// include the generator
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -35,6 +37,7 @@ cmake::cmake()
m_Verbose = false;
m_CacheManager = new cmCacheManager;
m_GlobalGenerator = 0;
+ this->AddDefaultCommands();
}
cmake::~cmake()
@@ -45,8 +48,34 @@ cmake::~cmake()
delete m_GlobalGenerator;
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)
{
@@ -811,3 +840,40 @@ const char* cmake::GetCacheDefinition(const char* name) const
{
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);
+ }
+}
+