cmAddCustomCommandCommand.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 "cmStandardIncludes.h"
  16. #include "cmCommand.h"
  17. /** \class cmAddCustomCommandCommand
  18. * \brief
  19. *
  20. * cmAddCustomCommandCommand defines a new command that can
  21. * be executed within the CMake
  22. *
  23. * In makefile terms this creates new target in the following form:
  24. * OUTPUT1: SOURCE DEPENDS
  25. * COMMAND ARGS
  26. * OUTPUT2: SOURCE DEPENDS
  27. * COMMAND ARGS
  28. * ...
  29. * Example of usage:
  30. * ADD_CUSTOM_COMMAND(
  31. * SOURCE ${VTK_TIFF_FAX_EXE}
  32. * COMMAND ${VTK_TIFF_FAX_EXE}
  33. * ARGS -c const ${VTK_BINARY_DIR}/Utilities/tiff/tif_fax3sm.c
  34. * TARGET vtktiff
  35. * OUTPUTS ${VTK_BINARY_DIR}/Utilities/tiff/tif_fax3sm.c
  36. * )
  37. * This will create custom target which will generate file tif_fax3sm.c
  38. * using command ${VTK_TIFF_FAX_EXE}.
  39. */
  40. class cmAddCustomCommandCommand : public cmCommand
  41. {
  42. public:
  43. /**
  44. * This is a virtual constructor for the command.
  45. */
  46. virtual cmCommand* Clone()
  47. {
  48. return new cmAddCustomCommandCommand;
  49. }
  50. /**
  51. * This is called when the command is first encountered in
  52. * the CMakeLists.txt file.
  53. */
  54. virtual bool InitialPass(std::vector<std::string> const& args);
  55. /**
  56. * This determines if the command gets propagated down
  57. * to makefiles located in subdirectories.
  58. */
  59. virtual bool IsInherited() {return true;}
  60. /**
  61. * The name of the command as specified in CMakeList.txt.
  62. */
  63. virtual const char* GetName() {return "ADD_CUSTOM_COMMAND";}
  64. /**
  65. * Succinct documentation.
  66. */
  67. virtual const char* GetTerseDocumentation()
  68. {
  69. return "Add a custom build rule to the generated build system.";
  70. }
  71. /**
  72. * More documentation.
  73. */
  74. virtual const char* GetFullDocumentation()
  75. {
  76. return
  77. "There are two main signatures for ADD_CUSTOM_COMMAND "
  78. "The first signature is for adding a custom command "
  79. "to a source file.\n"
  80. " ADD_CUSTOM_COMMAND(OUTPUT result\n"
  81. " COMMAND command\n"
  82. " [ARGS [args...]]\n"
  83. " [MAIN_DEPENDENCY depend]\n"
  84. " [DEPENDS [depends...]]\n"
  85. " [COMMENT comment])\n"
  86. "This defines a new command that can be executed during the build "
  87. "process. In makefile terms this creates a new target in the "
  88. "following form:\n"
  89. " OUTPUT: MAIN_DEPENDENCY DEPENDS\n"
  90. " COMMAND ARGS\n"
  91. "\n"
  92. "The second signature adds a custom command to a target "
  93. "such as a library or executable. This is useful for "
  94. "performing an operation before or after building the target "
  95. "\n"
  96. " ADD_CUSTOM_COMMAND(TARGET target\n"
  97. " PRE_BUILD | PRE_LINK | POST_BUILD\n"
  98. " COMMAND command\n"
  99. " [ARGS [args...]]\n"
  100. " [COMMENT comment])\n"
  101. "This defines a new command that will be associated with "
  102. "building the specified target. When the command will "
  103. "happen is determined by whether you specify\n"
  104. "PRE_BUILD - run before all other dependencies\n"
  105. "PRE_LINK - run after other dependencies\n"
  106. "POST_BUILD - run after the target has been built\n";
  107. }
  108. cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
  109. };
  110. /*
  111. target: normal depends
  112. pre rules
  113. normal rules
  114. post rules
  115. output1: source other depends
  116. rule
  117. output2: source other dpeends
  118. rule
  119. another option is
  120. output1: depends
  121. rule
  122. output2: depends
  123. rule
  124. use case1 - an executable that depending on args create diff output files
  125. */
  126. #endif