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 cmVariableWatchCommand_h
13 #define cmVariableWatchCommand_h
15 #include "cmCommand.h"
17 /** \class cmVariableWatchCommand
18 * \brief Watch when the variable changes and invoke command
21 class cmVariableWatchCommand : public cmCommand
25 * This is a virtual constructor for the command.
27 virtual cmCommand* Clone()
29 return new cmVariableWatchCommand;
32 //! Default constructor
33 cmVariableWatchCommand();
36 ~cmVariableWatchCommand();
39 * This is called when the command is first encountered in
40 * the CMakeLists.txt file.
42 virtual bool InitialPass(std::vector<std::string> const& args,
43 cmExecutionStatus &status);
46 * This determines if the command is invoked when in script mode.
48 virtual bool IsScriptable() const { return true; }
50 /** This command does not really have a final pass but it needs to
51 stay alive since it owns variable watch callback information. */
52 virtual bool HasFinalPass() const { return true; }
55 * The name of the command as specified in CMakeList.txt.
57 virtual const char* GetName() const { return "variable_watch";}
60 * Succinct documentation.
62 virtual const char* GetTerseDocumentation() const
64 return "Watch the CMake variable for change.";
70 virtual const char* GetFullDocumentation() const
73 " variable_watch(<variable name> [<command to execute>])\n"
74 "If the specified variable changes, the message will be printed about "
75 "the variable being changed. If the command is specified, the command "
76 "will be executed. The command will receive the following arguments:"
77 " COMMAND(<variable> <access> <value> <current list file> <stack>)";
80 cmTypeMacro(cmVariableWatchCommand, cmCommand);
83 std::set<std::string> WatchedVariables;