1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #ifndef cmWhileCommand_h
13 #define cmWhileCommand_h
15 #include "cmCommand.h"
16 #include "cmFunctionBlocker.h"
17 #include "cmListFileCache.h"
19 class cmWhileFunctionBlocker : public cmFunctionBlocker
22 cmWhileFunctionBlocker() {this->Depth=0;}
23 virtual ~cmWhileFunctionBlocker() {}
24 virtual bool IsFunctionBlocked(const cmListFileFunction& lff,
27 virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
29 std::vector<cmListFileArgument> Args;
30 std::vector<cmListFileFunction> Functions;
35 /// \brief Starts a while loop
36 class cmWhileCommand : public cmCommand
40 * This is a virtual constructor for the command.
42 virtual cmCommand* Clone()
44 return new cmWhileCommand;
48 * This overrides the default InvokeInitialPass implementation.
49 * It records the arguments before expansion.
51 virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
55 * This is called when the command is first encountered in
56 * the CMakeLists.txt file.
58 virtual bool InitialPass(std::vector<std::string> const&,
59 cmExecutionStatus &) { return false; }
62 * This determines if the command is invoked when in script mode.
64 virtual bool IsScriptable() const { return true; }
67 * The name of the command as specified in CMakeList.txt.
69 virtual const char* GetName() const { return "while";}
72 * Succinct documentation.
74 virtual const char* GetTerseDocumentation() const
76 return "Evaluate a group of commands while a condition is true";
82 virtual const char* GetFullDocumentation() const
86 " COMMAND1(ARGS ...)\n"
87 " COMMAND2(ARGS ...)\n"
89 " endwhile(condition)\n"
90 "All commands between while and the matching endwhile are recorded "
91 "without being invoked. Once the endwhile is evaluated, the "
92 "recorded list of commands is invoked as long as the condition "
93 "is true. The condition is evaluated using the same logic as the "
97 cmTypeMacro(cmWhileCommand, cmCommand);