1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmIfCommand.h,v $
6 Date: $Date: 2002-07-10 15:38:38 $
7 Version: $Revision: 1.15 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
20 #include "cmStandardIncludes.h"
21 #include "cmCommand.h"
22 #include "cmFunctionBlocker.h"
24 /** \class cmIfFunctionBlocker
25 * \brief subclass of function blocker
29 class cmIfFunctionBlocker
: public cmFunctionBlocker
32 cmIfFunctionBlocker() {}
33 virtual ~cmIfFunctionBlocker() {}
34 virtual bool IsFunctionBlocked(const char *name
,
35 const std::vector
<std::string
> &args
,
37 virtual bool ShouldRemove(const char *name
,
38 const std::vector
<std::string
> &args
,
40 virtual void ScopeEnded(cmMakefile
&mf
);
42 std::vector
<std::string
> m_Args
;
46 /** \class cmIfCommand
47 * \brief starts an if block
49 * cmIfCommand starts an if block
51 class cmIfCommand
: public cmCommand
55 * This is a virtual constructor for the command.
57 virtual cmCommand
* Clone()
59 return new cmIfCommand
;
63 * This is called when the command is first encountered in
64 * the CMakeLists.txt file.
66 virtual bool InitialPass(std::vector
<std::string
> const& args
);
69 * The name of the command as specified in CMakeList.txt.
71 virtual const char* GetName() { return "IF";}
74 * Succinct documentation.
76 virtual const char* GetTerseDocumentation()
78 return "start an if block";
82 * This determines if the command gets propagated down
83 * to makefiles located in subdirectories.
85 virtual bool IsInherited() {return true;}
90 virtual const char* GetFullDocumentation()
93 "IF (define) Starts an if block. Optionally it can be invoked "
94 "using (NOT define) (def AND def2) (def OR def2) (def MATCHES def2) "
95 "(COMMAND cmd) (EXISTS file) MATCHES checks if def matches the "
96 "regular expression def2. COMMAND checks if the cmake command cmd "
97 "is in this cmake executable. EXISTS file checks if file exists."
98 "Additionally you can do comparisons using LESS GREATER STRLESS "
99 "and STRGREATER. LESS and GREATER do numeric comparison while "
100 "STRLESS and STRGREATER do string comparisons.";
103 // this is a shared function for both If and Else to determine if
104 // the arguments were valid, and if so, was the response true
105 static bool IsTrue(const std::vector
<std::string
> &args
,
106 bool &isValid
, const cmMakefile
*mf
);
108 cmTypeMacro(cmIfCommand
, cmCommand
);