1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmVariableWatchCommand.h,v $
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.4 $
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 cmVariableWatchCommand_h
18 #define cmVariableWatchCommand_h
20 #include "cmCommand.h"
22 class cmVariableWatchCommandHandler
25 typedef std::vector
<std::string
> VectorOfCommands
;
26 VectorOfCommands Commands
;
29 /** \class cmVariableWatchCommand
30 * \brief Watch when the variable changes and invoke command
33 class cmVariableWatchCommand
: public cmCommand
37 * This is a virtual constructor for the command.
39 virtual cmCommand
* Clone()
41 return new cmVariableWatchCommand
;
44 //! Default constructor
45 cmVariableWatchCommand();
48 * This is called when the command is first encountered in
49 * the CMakeLists.txt file.
51 virtual bool InitialPass(std::vector
<std::string
> const& args
,
52 cmExecutionStatus
&status
);
55 * This determines if the command is invoked when in script mode.
57 virtual bool IsScriptable() { return true; }
60 * The name of the command as specified in CMakeList.txt.
62 virtual const char* GetName() { return "variable_watch";}
65 * Succinct documentation.
67 virtual const char* GetTerseDocumentation()
69 return "Watch the CMake variable for change.";
75 virtual const char* GetFullDocumentation()
78 " variable_watch(<variable name> [<command to execute>])\n"
79 "If the specified variable changes, the message will be printed about "
80 "the variable being changed. If the command is specified, the command "
81 "will be executed. The command will receive the following arguments:"
82 " COMMAND(<variable> <access> <value> <current list file> <stack>)";
85 cmTypeMacro(cmVariableWatchCommand
, cmCommand
);
87 void VariableAccessed(const std::string
& variable
, int access_type
,
88 const char* newValue
, const cmMakefile
* mf
);
91 std::map
<std::string
, cmVariableWatchCommandHandler
> Handlers
;