cmVariableWatchCommand.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmVariableWatchCommand_h
  4. #define cmVariableWatchCommand_h
  5. #include <cmConfigure.h>
  6. #include <set>
  7. #include <string>
  8. #include <vector>
  9. #include "cmCommand.h"
  10. #include "cmTypeMacro.h"
  11. class cmExecutionStatus;
  12. /** \class cmVariableWatchCommand
  13. * \brief Watch when the variable changes and invoke command
  14. *
  15. */
  16. class cmVariableWatchCommand : public cmCommand
  17. {
  18. public:
  19. /**
  20. * This is a virtual constructor for the command.
  21. */
  22. cmCommand* Clone() CM_OVERRIDE { return new cmVariableWatchCommand; }
  23. //! Default constructor
  24. cmVariableWatchCommand();
  25. //! Destructor.
  26. ~cmVariableWatchCommand() CM_OVERRIDE;
  27. /**
  28. * This is called when the command is first encountered in
  29. * the CMakeLists.txt file.
  30. */
  31. bool InitialPass(std::vector<std::string> const& args,
  32. cmExecutionStatus& status) CM_OVERRIDE;
  33. /**
  34. * This determines if the command is invoked when in script mode.
  35. */
  36. bool IsScriptable() const CM_OVERRIDE { return true; }
  37. /** This command does not really have a final pass but it needs to
  38. stay alive since it owns variable watch callback information. */
  39. bool HasFinalPass() const CM_OVERRIDE { return true; }
  40. /**
  41. * The name of the command as specified in CMakeList.txt.
  42. */
  43. std::string GetName() const CM_OVERRIDE { return "variable_watch"; }
  44. cmTypeMacro(cmVariableWatchCommand, cmCommand);
  45. protected:
  46. std::set<std::string> WatchedVariables;
  47. };
  48. #endif