ENH: Added option to IF command to test if a command exists. Syntax is IF(COMMAND name-of-command).

This commit is contained in:
Brad King 2001-12-18 09:39:26 -05:00
parent dca0fd0859
commit fd37e46eb3
3 changed files with 14 additions and 2 deletions

View File

@ -110,6 +110,14 @@ bool cmIfCommand::InitialPass(std::vector<std::string> const& args)
} }
} }
if (args.size() == 2 && (args[0] == "COMMAND"))
{
if(!m_Makefile->CommandExists(args[1].c_str()))
{
f = new cmIfFunctionBlocker();
}
}
if (args.size() == 3 && (args[1] == "AND")) if (args.size() == 3 && (args[1] == "AND"))
{ {
def = m_Makefile->GetDefinition(args[0].c_str()); def = m_Makefile->GetDefinition(args[0].c_str());

View File

@ -214,7 +214,10 @@ void cmMakefile::Print() const
} }
} }
bool cmMakefile::CommandExists(const char* name) const
{
return (m_Commands.find(name) != m_Commands.end());
}
void cmMakefile::ExecuteCommand(std::string &name, void cmMakefile::ExecuteCommand(std::string &name,
std::vector<std::string> const& arguments) std::vector<std::string> const& arguments)
@ -1187,7 +1190,6 @@ cmMakefile::FindSourceGroup(const char* source,
return groups.front(); return groups.front();
} }
bool cmMakefile::IsFunctionBlocked(const char *name, bool cmMakefile::IsFunctionBlocked(const char *name,
std::vector<std::string> const&args) std::vector<std::string> const&args)
{ {

View File

@ -534,6 +534,8 @@ public:
*/ */
void ExecuteCommand(std::string &name, std::vector<std::string> const& args); void ExecuteCommand(std::string &name, std::vector<std::string> const& args);
/** Check if a command exists. */
bool CommandExists(const char* name) const;
protected: protected:
std::string m_Prefix; std::string m_Prefix;