cmAddCustomTargetCommand.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmAddCustomTargetCommand_h
  11. #define cmAddCustomTargetCommand_h
  12. #include "cmCommand.h"
  13. /** \class cmAddCustomTargetCommand
  14. * \brief Command that adds a target to the build system.
  15. *
  16. * cmAddCustomTargetCommand adds an extra target to the build system.
  17. * This is useful when you would like to add special
  18. * targets like "install,", "clean," and so on.
  19. */
  20. class cmAddCustomTargetCommand : public cmCommand
  21. {
  22. public:
  23. /**
  24. * This is a virtual constructor for the command.
  25. */
  26. virtual cmCommand* Clone()
  27. {
  28. return new cmAddCustomTargetCommand;
  29. }
  30. /**
  31. * This is called when the command is first encountered in
  32. * the CMakeLists.txt file.
  33. */
  34. virtual bool InitialPass(std::vector<std::string> const& args,
  35. cmExecutionStatus &status);
  36. /**
  37. * The name of the command as specified in CMakeList.txt.
  38. */
  39. virtual const char* GetName() const
  40. {return "add_custom_target";}
  41. /**
  42. * Succinct documentation.
  43. */
  44. virtual const char* GetTerseDocumentation() const
  45. {
  46. return "Add a target with no output so it will always be built.";
  47. }
  48. /**
  49. * More documentation.
  50. */
  51. virtual const char* GetFullDocumentation() const
  52. {
  53. return
  54. " add_custom_target(Name [ALL] [command1 [args1...]]\n"
  55. " [COMMAND command2 [args2...] ...]\n"
  56. " [DEPENDS depend depend depend ... ]\n"
  57. " [WORKING_DIRECTORY dir]\n"
  58. " [COMMENT comment] [VERBATIM]\n"
  59. " [SOURCES src1 [src2...]])\n"
  60. "Adds a target with the given name that executes the given commands. "
  61. "The target has no output file and is ALWAYS CONSIDERED OUT OF DATE "
  62. "even if the commands try to create a file with the name of the "
  63. "target. Use ADD_CUSTOM_COMMAND to generate a file with dependencies. "
  64. "By default nothing depends on the custom target. Use "
  65. "ADD_DEPENDENCIES to add dependencies to or from other targets. "
  66. "If the ALL option is specified "
  67. "it indicates that this target should be added to the default build "
  68. "target so that it will be run every time "
  69. "(the command cannot be called ALL). "
  70. "The command and arguments are optional and if not specified an "
  71. "empty target will be created. "
  72. "If WORKING_DIRECTORY is set, then the command will be run in that "
  73. "directory. "
  74. "If it is a relative path it will be interpreted relative to the "
  75. "build tree directory corresponding to the current source directory. "
  76. "If COMMENT is set, the value will be displayed as a "
  77. "message before the commands are executed at build time. "
  78. "Dependencies listed with the DEPENDS argument may reference files "
  79. "and outputs of custom commands created with add_custom_command() in "
  80. "the same directory (CMakeLists.txt file).\n"
  81. "If VERBATIM is given then all arguments to the commands will be "
  82. "escaped properly for the build tool so that the invoked command "
  83. "receives each argument unchanged. "
  84. "Note that one level of escapes is still used by the CMake language "
  85. "processor before add_custom_target even sees the arguments. "
  86. "Use of VERBATIM is recommended as it enables correct behavior. "
  87. "When VERBATIM is not given the behavior is platform specific because "
  88. "there is no protection of tool-specific special characters."
  89. "\n"
  90. "The SOURCES option specifies additional source files to be included "
  91. "in the custom target. "
  92. "Specified source files will be added to IDE project files for "
  93. "convenience in editing even if they have not build rules."
  94. ;
  95. }
  96. cmTypeMacro(cmAddCustomTargetCommand, cmCommand);
  97. };
  98. #endif