From e07ea14e31e1d91632bdd5d56124ab394042f0d1 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 2 Jan 2002 16:46:08 -0500 Subject: [PATCH] added exists option for if statement --- Source/cmElseCommand.cxx | 8 ++++++++ Source/cmIfCommand.cxx | 8 ++++++++ Source/cmIfCommand.h | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/cmElseCommand.cxx b/Source/cmElseCommand.cxx index 7daca42cf5..c04dbeb4ee 100644 --- a/Source/cmElseCommand.cxx +++ b/Source/cmElseCommand.cxx @@ -73,6 +73,14 @@ bool cmElseCommand::InitialPass(std::vector const& args) } } + if (args.size() == 2 && (args[0] == "EXISTS")) + { + if(cmSystemTools::FileExists(args[1].c_str())) + { + f = new cmIfFunctionBlocker(); + } + } + if (args.size() == 2 && (args[0] == "NOT")) { def = m_Makefile->GetDefinition(args[1].c_str()); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index f549e5cebd..83da56f599 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -134,6 +134,14 @@ bool cmIfCommand::InitialPass(std::vector const& args) } } + if (args.size() == 2 && (args[0] == "EXISTS")) + { + if(!cmSystemTools::FileExists(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/cmIfCommand.h b/Source/cmIfCommand.h index 9d8910fa8a..d663253dcd 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -115,7 +115,9 @@ public: return "IF (define) Starts an if block. Optionally it can be invoked " "using (NOT define) (def AND def2) (def OR def2) (def MATCHES def2) " - "MATCHES checks if def matches the regular expression def2 "; + "(COMMAND cmd) (EXISTS file) MATCHES checks if def matches the " + "regular expression def2. COMMAND checks if the cmake command cmd " + "is in this cmake executable. EXISTS file checks if file exists"; } cmTypeMacro(cmIfCommand, cmCommand);