Commit bea21587 authored by Ken Martin's avatar Ken Martin
Browse files

updated makefile moved commands into cmake and fixed try compile

parent 74e13ad2
...@@ -53,7 +53,6 @@ cmMakefile::cmMakefile() ...@@ -53,7 +53,6 @@ cmMakefile::cmMakefile()
this->AddSourceGroup("", "^.*$"); this->AddSourceGroup("", "^.*$");
this->AddSourceGroup("Source Files", "\\.(cpp|C|c|cxx|rc|def|r|odl|idl|hpj|bat)$"); this->AddSourceGroup("Source Files", "\\.(cpp|C|c|cxx|rc|def|r|odl|idl|hpj|bat)$");
this->AddSourceGroup("Header Files", "\\.(h|hh|hpp|hxx|hm|inl)$"); this->AddSourceGroup("Header Files", "\\.(h|hh|hpp|hxx|hm|inl)$");
this->AddDefaultCommands();
this->AddDefaultDefinitions(); this->AddDefaultDefinitions();
} }
...@@ -76,30 +75,6 @@ unsigned int cmMakefile::GetCacheMinorVersion() ...@@ -76,30 +75,6 @@ unsigned int cmMakefile::GetCacheMinorVersion()
} }
void cmMakefile::AddDefaultCommands()
{
std::list<cmCommand*> commands;
GetPredefinedCommands(commands);
for(std::list<cmCommand*>::iterator i = commands.begin();
i != commands.end(); ++i)
{
this->AddCommand(*i);
}
#if defined(_WIN32) || defined(__CYGWIN__)
this->AddDefinition("WIN32", "1");
#else
this->AddDefinition("UNIX", "1");
#endif
// Cygwin is more like unix so enable the unix commands
#if defined(__CYGWIN__)
this->AddDefinition("UNIX", "1");
this->AddDefinition("CYGWIN", "1");
#endif
#if defined(__APPLE__)
this->AddDefinition("APPLE", "1");
#endif
}
cmMakefile::~cmMakefile() cmMakefile::~cmMakefile()
{ {
for(std::vector<cmSourceFile*>::iterator i = m_SourceFiles.begin(); for(std::vector<cmSourceFile*>::iterator i = m_SourceFiles.begin();
...@@ -111,11 +86,6 @@ cmMakefile::~cmMakefile() ...@@ -111,11 +86,6 @@ cmMakefile::~cmMakefile()
{ {
delete m_UsedCommands[i]; delete m_UsedCommands[i];
} }
for(RegisteredCommandsMap::iterator j = m_Commands.begin();
j != m_Commands.end(); ++j)
{
delete (*j).second;
}
for(DataMap::const_iterator d = m_DataMap.begin(); for(DataMap::const_iterator d = m_DataMap.begin();
d != m_DataMap.end(); ++d) d != m_DataMap.end(); ++d)
{ {
...@@ -184,7 +154,7 @@ void cmMakefile::Print() const ...@@ -184,7 +154,7 @@ void cmMakefile::Print() const
bool cmMakefile::CommandExists(const char* name) const bool cmMakefile::CommandExists(const char* name) const
{ {
return (m_Commands.find(name) != m_Commands.end()); return m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->CommandExists(name);
} }
void cmMakefile::ExecuteCommand(std::string const &name, void cmMakefile::ExecuteCommand(std::string const &name,
...@@ -196,10 +166,10 @@ void cmMakefile::ExecuteCommand(std::string const &name, ...@@ -196,10 +166,10 @@ void cmMakefile::ExecuteCommand(std::string const &name,
return; return;
} }
// execute the command // execute the command
RegisteredCommandsMap::iterator pos = m_Commands.find(name); cmCommand *rm =
if(pos != m_Commands.end()) m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->GetCommand(name.c_str());
if(rm)
{ {
cmCommand* rm = (*pos).second;
cmCommand* usedCommand = rm->Clone(); cmCommand* usedCommand = rm->Clone();
usedCommand->SetMakefile(this); usedCommand->SetMakefile(this);
bool keepCommand = false; bool keepCommand = false;
...@@ -378,8 +348,7 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external) ...@@ -378,8 +348,7 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external)
void cmMakefile::AddCommand(cmCommand* wg) void cmMakefile::AddCommand(cmCommand* wg)
{ {
std::string name = wg->GetName(); m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->AddCommand(wg);
m_Commands.insert( RegisteredCommandsMap::value_type(name, wg));
} }
// Set the make file // Set the make file
...@@ -898,32 +867,6 @@ const char* cmMakefile::GetDefinition(const char* name) const ...@@ -898,32 +867,6 @@ const char* cmMakefile::GetDefinition(const char* name) const
return this->GetCacheManager()->GetCacheValue(name); return this->GetCacheManager()->GetCacheValue(name);
} }
int cmMakefile::DumpDocumentationToFile(std::ostream& f)
{
// Open the supplied filename
// 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", cmMakefile::GetMajorVersion(),
cmMakefile::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;
}
const char *cmMakefile::ExpandVariablesInString(std::string& source) const const char *cmMakefile::ExpandVariablesInString(std::string& source) const
...@@ -1124,6 +1067,20 @@ void cmMakefile::RemoveVariablesInString(std::string& source, ...@@ -1124,6 +1067,20 @@ void cmMakefile::RemoveVariablesInString(std::string& source,
*/ */
void cmMakefile::AddDefaultDefinitions() void cmMakefile::AddDefaultDefinitions()
{ {
#if defined(_WIN32) || defined(__CYGWIN__)
this->AddDefinition("WIN32", "1");
#else
this->AddDefinition("UNIX", "1");
#endif
// Cygwin is more like unix so enable the unix commands
#if defined(__CYGWIN__)
this->AddDefinition("UNIX", "1");
this->AddDefinition("CYGWIN", "1");
#endif
#if defined(__APPLE__)
this->AddDefinition("APPLE", "1");
#endif
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
this->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)"); this->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)");
#else #else
...@@ -1373,7 +1330,7 @@ void cmMakefile::ExpandSourceListArguments( ...@@ -1373,7 +1330,7 @@ void cmMakefile::ExpandSourceListArguments(
} }
int cmMakefile::TryCompile(const char *srcdir, const char *bindir, int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
const char *projectName) const char *projectName, const char *targetName)
{ {
if (!m_LocalGenerator) if (!m_LocalGenerator)
{ {
...@@ -1433,17 +1390,13 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, ...@@ -1433,17 +1390,13 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
} }
// finally call the generator to actually build the resulting project // finally call the generator to actually build the resulting project
gg->TryCompile(srcdir,bindir,projectName); int ret = gg->TryCompile(srcdir,bindir,projectName, targetName);
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
return 0; return ret;
} }
cmCacheManager *cmMakefile::GetCacheManager() const cmCacheManager *cmMakefile::GetCacheManager() const
{ {
if (m_LocalGenerator) return m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->GetCacheManager();
{
return m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->GetCacheManager();
}
return 0;
} }
...@@ -70,11 +70,6 @@ public: ...@@ -70,11 +70,6 @@ public:
*/ */
bool ReadListFile(const char* listfile, const char* external= 0); bool ReadListFile(const char* listfile, const char* external= 0);
/**
* Add a wrapper generator.
*/
void AddCommand(cmCommand* );
/** /**
* Add a function blocker to this makefile * Add a function blocker to this makefile
*/ */
...@@ -89,7 +84,7 @@ public: ...@@ -89,7 +84,7 @@ public:
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.
*/ */
int TryCompile(const char *srcdir, const char *bindir, int TryCompile(const char *srcdir, const char *bindir,
const char *projectName); const char *projectName, const char *targetName);
/** /**
* Specify the makefile generator. This is platform/compiler * Specify the makefile generator. This is platform/compiler
...@@ -457,12 +452,6 @@ public: ...@@ -457,12 +452,6 @@ public:
void AddCMakeDependFile(const char* file) void AddCMakeDependFile(const char* file)
{ m_ListFiles.push_back(file);} { m_ListFiles.push_back(file);}
/**
* Dump documentation to a file. If 0 is returned, the
* operation failed.
*/
int DumpDocumentationToFile(std::ostream&);
/** /**
* Expand all defined varibles in the string. * Expand all defined varibles in the string.
* Defined varibles come from the m_Definitions map. * Defined varibles come from the m_Definitions map.
...@@ -503,6 +492,11 @@ public: ...@@ -503,6 +492,11 @@ public:
/** Check if a command exists. */ /** Check if a command exists. */
bool CommandExists(const char* name) const; bool CommandExists(const char* name) const;
/**
* Add a command to this cmake instance
*/
void AddCommand(cmCommand* );
///! Enable support for the named language, if null then all languages are enabled. ///! Enable support for the named language, if null then all languages are enabled.
void EnableLanguage(const char* ); void EnableLanguage(const char* );
...@@ -554,10 +548,8 @@ protected: ...@@ -554,10 +548,8 @@ protected:
std::vector<std::string> m_HeaderFileExtensions; std::vector<std::string> m_HeaderFileExtensions;
std::string m_DefineFlags; std::string m_DefineFlags;
std::vector<cmSourceGroup> m_SourceGroups; std::vector<cmSourceGroup> m_SourceGroups;
typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
typedef std::map<cmStdString, cmStdString> DefinitionMap; typedef std::map<cmStdString, cmStdString> DefinitionMap;
DefinitionMap m_Definitions; DefinitionMap m_Definitions;
RegisteredCommandsMap m_Commands;
std::vector<cmCommand*> m_UsedCommands; std::vector<cmCommand*> m_UsedCommands;
cmLocalGenerator* m_LocalGenerator; cmLocalGenerator* m_LocalGenerator;
bool IsFunctionBlocked(const char *name, std::vector<std::string> const& args); bool IsFunctionBlocked(const char *name, std::vector<std::string> const& args);
...@@ -573,7 +565,6 @@ private: ...@@ -573,7 +565,6 @@ private:
friend class cmMakeDepend; // make depend needs direct access friend class cmMakeDepend; // make depend needs direct access
// to the m_Sources array // to the m_Sources array
void PrintStringVector(const char* s, const std::vector<std::string>& v) const; void PrintStringVector(const char* s, const std::vector<std::string>& v) const;
void AddDefaultCommands();
void AddDefaultDefinitions(); void AddDefaultDefinitions();
std::list<cmFunctionBlocker *> m_FunctionBlockers; std::list<cmFunctionBlocker *> m_FunctionBlockers;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment