1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmWhileCommand.h,v $
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.9 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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 =========================================================================*/
17 #ifndef cmWhileCommand_h
18 #define cmWhileCommand_h
20 #include "cmCommand.h"
21 #include "cmFunctionBlocker.h"
22 #include "cmListFileCache.h"
24 /** \class cmWhileFunctionBlocker
25 * \brief subclass of function blocker
29 class cmWhileFunctionBlocker
: public cmFunctionBlocker
32 cmWhileFunctionBlocker() {Executing
= false; Depth
=0;}
33 virtual ~cmWhileFunctionBlocker() {}
34 virtual bool IsFunctionBlocked(const cmListFileFunction
& lff
,
37 virtual bool ShouldRemove(const cmListFileFunction
& lff
, cmMakefile
&mf
);
38 virtual void ScopeEnded(cmMakefile
&mf
);
40 std::vector
<cmListFileArgument
> Args
;
41 std::vector
<cmListFileFunction
> Functions
;
47 /** \class cmWhileCommand
48 * \brief starts a while loop
50 * cmWhileCommand starts a while loop
52 class cmWhileCommand
: public cmCommand
56 * This is a virtual constructor for the command.
58 virtual cmCommand
* Clone()
60 return new cmWhileCommand
;
64 * This overrides the default InvokeInitialPass implementation.
65 * It records the arguments before expansion.
67 virtual bool InvokeInitialPass(const std::vector
<cmListFileArgument
>& args
,
71 * This is called when the command is first encountered in
72 * the CMakeLists.txt file.
74 virtual bool InitialPass(std::vector
<std::string
> const&,
75 cmExecutionStatus
&) { return false; }
78 * This determines if the command is invoked when in script mode.
80 virtual bool IsScriptable() { return true; }
83 * The name of the command as specified in CMakeList.txt.
85 virtual const char* GetName() { return "while";}
88 * Succinct documentation.
90 virtual const char* GetTerseDocumentation()
92 return "Evaluate a group of commands while a condition is true";
98 virtual const char* GetFullDocumentation()
101 " while(condition)\n"
102 " COMMAND1(ARGS ...)\n"
103 " COMMAND2(ARGS ...)\n"
105 " endwhile(condition)\n"
106 "All commands between while and the matching endwhile are recorded "
107 "without being invoked. Once the endwhile is evaluated, the "
108 "recorded list of commands is invoked as long as the condition "
109 "is true. The condition is evaluated using the same logic as the "
113 cmTypeMacro(cmWhileCommand
, cmCommand
);