From bea21587cf35f9d373314dd67c24b99fd0e11e49 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Tue, 10 Sep 2002 16:52:39 -0400 Subject: [PATCH] updated makefile moved commands into cmake and fixed try compile --- Source/cmMakefile.cxx | 93 +++++++++++-------------------------------- Source/cmMakefile.h | 21 +++------- 2 files changed, 29 insertions(+), 85 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a3f532d5f..e8da4dc89 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -53,7 +53,6 @@ cmMakefile::cmMakefile() this->AddSourceGroup("", "^.*$"); 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->AddDefaultCommands(); this->AddDefaultDefinitions(); } @@ -76,30 +75,6 @@ unsigned int cmMakefile::GetCacheMinorVersion() } -void cmMakefile::AddDefaultCommands() -{ - std::list commands; - GetPredefinedCommands(commands); - for(std::list::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() { for(std::vector::iterator i = m_SourceFiles.begin(); @@ -111,11 +86,6 @@ cmMakefile::~cmMakefile() { 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(); d != m_DataMap.end(); ++d) { @@ -184,7 +154,7 @@ void cmMakefile::Print() 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, @@ -196,10 +166,10 @@ void cmMakefile::ExecuteCommand(std::string const &name, return; } // execute the command - RegisteredCommandsMap::iterator pos = m_Commands.find(name); - if(pos != m_Commands.end()) + cmCommand *rm = + m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->GetCommand(name.c_str()); + if(rm) { - cmCommand* rm = (*pos).second; cmCommand* usedCommand = rm->Clone(); usedCommand->SetMakefile(this); bool keepCommand = false; @@ -378,8 +348,7 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external) void cmMakefile::AddCommand(cmCommand* wg) { - std::string name = wg->GetName(); - m_Commands.insert( RegisteredCommandsMap::value_type(name, wg)); + m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->AddCommand(wg); } // Set the make file @@ -898,32 +867,6 @@ const char* cmMakefile::GetDefinition(const char* name) const 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 << "\n"; - f << "

Documentation for commands of CMake " << tmp << "

\n"; - f << "
    \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 << "
  • " << name << " - " << terse << std::endl - << "
    Usage: " << full << "
  • " << std::endl << std::endl; - } - f << "
\n"; - return 1; -} const char *cmMakefile::ExpandVariablesInString(std::string& source) const @@ -1124,6 +1067,20 @@ void cmMakefile::RemoveVariablesInString(std::string& source, */ 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__) this->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)"); #else @@ -1373,7 +1330,7 @@ void cmMakefile::ExpandSourceListArguments( } int cmMakefile::TryCompile(const char *srcdir, const char *bindir, - const char *projectName) + const char *projectName, const char *targetName) { if (!m_LocalGenerator) { @@ -1433,17 +1390,13 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, } // 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()); - return 0; + return ret; } cmCacheManager *cmMakefile::GetCacheManager() const { - if (m_LocalGenerator) - { - return m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->GetCacheManager(); - } - return 0; + return m_LocalGenerator->GetGlobalGenerator()->GetCMakeInstance()->GetCacheManager(); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1deee8ef7..76ed2a10c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -70,11 +70,6 @@ public: */ bool ReadListFile(const char* listfile, const char* external= 0); - /** - * Add a wrapper generator. - */ - void AddCommand(cmCommand* ); - /** * Add a function blocker to this makefile */ @@ -89,7 +84,7 @@ public: * loaded commands, not as part of the usual build process. */ 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 @@ -457,12 +452,6 @@ public: void AddCMakeDependFile(const char* 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. * Defined varibles come from the m_Definitions map. @@ -503,6 +492,11 @@ public: /** Check if a command exists. */ 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. void EnableLanguage(const char* ); @@ -554,10 +548,8 @@ protected: std::vector m_HeaderFileExtensions; std::string m_DefineFlags; std::vector m_SourceGroups; - typedef std::map RegisteredCommandsMap; typedef std::map DefinitionMap; DefinitionMap m_Definitions; - RegisteredCommandsMap m_Commands; std::vector m_UsedCommands; cmLocalGenerator* m_LocalGenerator; bool IsFunctionBlocked(const char *name, std::vector const& args); @@ -573,7 +565,6 @@ private: friend class cmMakeDepend; // make depend needs direct access // to the m_Sources array void PrintStringVector(const char* s, const std::vector& v) const; - void AddDefaultCommands(); void AddDefaultDefinitions(); std::list m_FunctionBlockers;