cmAddCustomCommandCommand.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 cmAddCustomCommandCommand_h
  14. #define cmAddCustomCommandCommand_h
  15. #include "cmCommand.h"
  16. /** \class cmAddCustomCommandCommand
  17. * \brief
  18. *
  19. * cmAddCustomCommandCommand defines a new command (rule) that can
  20. * be executed within the build process
  21. *
  22. */
  23. class cmAddCustomCommandCommand : public cmCommand
  24. {
  25. public:
  26. /**
  27. * This is a virtual constructor for the command.
  28. */
  29. virtual cmCommand* Clone()
  30. {
  31. return new cmAddCustomCommandCommand;
  32. }
  33. /**
  34. * This is called when the command is first encountered in
  35. * the CMakeLists.txt file.
  36. */
  37. virtual bool InitialPass(std::vector<std::string> const& args);
  38. /**
  39. * The name of the command as specified in CMakeList.txt.
  40. */
  41. virtual const char* GetName() {return "ADD_CUSTOM_COMMAND";}
  42. /**
  43. * Succinct documentation.
  44. */
  45. virtual const char* GetTerseDocumentation()
  46. {
  47. return "Add a custom build rule to the generated build system.";
  48. }
  49. /**
  50. * More documentation.
  51. */
  52. virtual const char* GetFullDocumentation()
  53. {
  54. return
  55. "There are two main signatures for ADD_CUSTOM_COMMAND "
  56. "The first signature is for adding a custom command "
  57. "to produce an output.\n"
  58. " ADD_CUSTOM_COMMAND(OUTPUT result\n"
  59. " COMMAND command1 [ARGS] [args1...]\n"
  60. " [COMMAND command2 [ARGS] [args2...] ...]\n"
  61. " [MAIN_DEPENDENCY depend]\n"
  62. " [DEPENDS [depends...]]\n"
  63. " [WORKING_DIRECTORY dir]\n"
  64. " [COMMENT comment])\n"
  65. "This defines a new command that can be executed during the build "
  66. "process. Note that MAIN_DEPENDENCY is completely optional and is "
  67. "used as a suggestion to visual studio about where to hang the "
  68. "custom command. In makefile terms this creates a new target in the "
  69. "following form:\n"
  70. " OUTPUT: MAIN_DEPENDENCY DEPENDS\n"
  71. " COMMAND\n"
  72. "If more than one command is specified they will be executed in order. "
  73. "The optional ARGS argument is for backward compatibility and will be "
  74. "ignored.\n"
  75. "The second signature adds a custom command to a target "
  76. "such as a library or executable. This is useful for "
  77. "performing an operation before or after building the target:\n"
  78. " ADD_CUSTOM_COMMAND(TARGET target\n"
  79. " PRE_BUILD | PRE_LINK | POST_BUILD\n"
  80. " COMMAND command1 [ARGS] [args1...]\n"
  81. " [COMMAND command2 [ARGS] [args2...] ...]\n"
  82. " [WORKING_DIRECTORY dir]\n"
  83. " [COMMENT comment])\n"
  84. "This defines a new command that will be associated with "
  85. "building the specified target. When the command will "
  86. "happen is determined by which of the following is specified:\n"
  87. " PRE_BUILD - run before all other dependencies\n"
  88. " PRE_LINK - run after other dependencies\n"
  89. " POST_BUILD - run after the target has been built\n"
  90. "Note that the PRE_BUILD option is only supported on Visual "
  91. "Studio 7 or later. For all other generators PRE_BUILD "
  92. "will be treated as PRE_LINK."
  93. "If WORKING_DIRECTORY is specified the command a cd \"dir\" is "
  94. "done prior to running the command.";
  95. }
  96. cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
  97. };
  98. #endif