cmMacroCommand.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmMacroCommand_h
  14. #define cmMacroCommand_h
  15. #include "cmCommand.h"
  16. #include "cmFunctionBlocker.h"
  17. /** \class cmMacroFunctionBlocker
  18. * \brief subclass of function blocker
  19. *
  20. *
  21. */
  22. class cmMacroFunctionBlocker : public cmFunctionBlocker
  23. {
  24. public:
  25. cmMacroFunctionBlocker() {m_Executing = false;}
  26. virtual ~cmMacroFunctionBlocker() {}
  27. virtual bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile &mf);
  28. virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile &mf);
  29. virtual void ScopeEnded(cmMakefile &mf);
  30. std::vector<std::string> m_Args;
  31. std::vector<cmListFileFunction> m_Functions;
  32. bool m_Executing;
  33. };
  34. /** \class cmMacroCommand
  35. * \brief starts an if block
  36. *
  37. * cmMacroCommand starts an if block
  38. */
  39. class cmMacroCommand : public cmCommand
  40. {
  41. public:
  42. /**
  43. * This is a virtual constructor for the command.
  44. */
  45. virtual cmCommand* Clone()
  46. {
  47. return new cmMacroCommand;
  48. }
  49. /**
  50. * This is called when the command is first encountered in
  51. * the CMakeLists.txt file.
  52. */
  53. virtual bool InitialPass(std::vector<std::string> const& args);
  54. /**
  55. * This determines if the command gets propagated down
  56. * to makefiles located in subdirectories.
  57. */
  58. virtual bool IsInherited() {return true;}
  59. /**
  60. * The name of the command as specified in CMakeList.txt.
  61. */
  62. virtual const char* GetName() { return "MACRO";}
  63. /**
  64. * Succinct documentation.
  65. */
  66. virtual const char* GetTerseDocumentation()
  67. {
  68. return "Start recording a macro for later invocation as a command.";
  69. }
  70. /**
  71. * More documentation.
  72. */
  73. virtual const char* GetFullDocumentation()
  74. {
  75. return
  76. " MACRO(<name> [arg1 [arg2 [arg3 ...]]])\n"
  77. " COMMAND1(ARGS ...)\n"
  78. " COMMAND2(ARGS ...)\n"
  79. " ...\n"
  80. " ENDMACRO(<name>)\n"
  81. "Define a macro named <name> that takes arguments named "
  82. "arg1 arg2 arg3 (...). Commands listed after MACRO, "
  83. "but before the matching ENDMACRO, are not invoked until the macro "
  84. "is invoked. When it is invoked, the commands recorded in the "
  85. "macro are first modified by replacing formal parameters (${arg1}) with "
  86. "the arguments passed, and then invoked as normal commands.";
  87. }
  88. cmTypeMacro(cmMacroCommand, cmCommand);
  89. };
  90. #endif