cmAddCustomCommandCommand.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. " ADD_CUSTOM_COMMAND(TARGET target\n"
  78. " [SOURCE source]\n"
  79. " [COMMAND command]\n"
  80. " [ARGS [args...]]\n"
  81. " [DEPENDS [depends...]]\n"
  82. " [OUTPUTS [outputs...]]\n"
  83. " [COMMENT comment])\n"
  84. "This defines a new command that can be executed during the build "
  85. "process. In makefile terms this creates a new target in the "
  86. "following form:\n"
  87. " OUTPUT1: SOURCE DEPENDS\n"
  88. " COMAND ARGS\n"
  89. " OUTPUT2: SOURCE DEPENDS\n"
  90. " COMAND ARGS\n"
  91. "The TARGET must be specified, but it is not the make target of the "
  92. "build rule. It is the target (library, executable, or custom target) "
  93. "that will use the output generated from this rule. This is necessary "
  94. "to choose a project file in which to generate the rule for Visual "
  95. "Studio.\n"
  96. "Example of usage:\n"
  97. " ADD_CUSTOM_COMMAND(\n"
  98. " TARGET tiff\n"
  99. " SOURCE ${TIFF_FAX_EXE}\n"
  100. " COMMAND ${TIFF_FAX_EXE}\n"
  101. " ARGS -c const ${TIFF_BINARY_DIR}/tif_fax3sm.c\n"
  102. " OUTPUTS ${TIFF_BINARY_DIR}/tif_fax3sm.c\n"
  103. " )\n"
  104. "This will create custom target which will generate file tif_fax3sm.c "
  105. "using command ${TIFF_FAX_EXE}. The rule will be executed as part of "
  106. "building the tiff library because it includes tif_fax3sm.c as a "
  107. "source file with the GENERATED property.";
  108. }
  109. cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
  110. };
  111. #endif