summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-12-18 14:39:26 (GMT)
committerBrad King <brad.king@kitware.com>2001-12-18 14:39:26 (GMT)
commitfd37e46eb31a418302ba789fa99bb807cf2b5450 (patch)
treea7968d313066cb97828c33b8e14233db9cdf566c
parentdca0fd0859a941665c9c1648f8ca3cf42fda1141 (diff)
downloadCMake-fd37e46eb31a418302ba789fa99bb807cf2b5450.zip
CMake-fd37e46eb31a418302ba789fa99bb807cf2b5450.tar.gz
CMake-fd37e46eb31a418302ba789fa99bb807cf2b5450.tar.bz2
ENH: Added option to IF command to test if a command exists. Syntax is IF(COMMAND name-of-command).
-rw-r--r--Source/cmIfCommand.cxx8
-rw-r--r--Source/cmMakefile.cxx6
-rw-r--r--Source/cmMakefile.h2
3 files changed, 14 insertions, 2 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 903746a..e25502e 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -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"))
{
def = m_Makefile->GetDefinition(args[0].c_str());
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 81b4b33..c9cf6ee 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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,
std::vector<std::string> const& arguments)
@@ -1187,7 +1190,6 @@ cmMakefile::FindSourceGroup(const char* source,
return groups.front();
}
-
bool cmMakefile::IsFunctionBlocked(const char *name,
std::vector<std::string> const&args)
{
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 44d4d61..9631bd3 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -534,6 +534,8 @@ public:
*/
void ExecuteCommand(std::string &name, std::vector<std::string> const& args);
+ /** Check if a command exists. */
+ bool CommandExists(const char* name) const;
protected:
std::string m_Prefix;