Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmAddCustomCommandCommand.h
blobc6580cbfeb8378228b9e6c3b05a948fa66056159
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmAddCustomCommandCommand.h,v $
5 Language: C++
6 Date: $Date: 2009-04-01 14:31:39 $
7 Version: $Revision: 1.37 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmAddCustomCommandCommand_h
18 #define cmAddCustomCommandCommand_h
20 #include "cmCommand.h"
22 /** \class cmAddCustomCommandCommand
23 * \brief
25 * cmAddCustomCommandCommand defines a new command (rule) that can
26 * be executed within the build process
30 class cmAddCustomCommandCommand : public cmCommand
32 public:
33 /**
34 * This is a virtual constructor for the command.
36 virtual cmCommand* Clone()
38 return new cmAddCustomCommandCommand;
41 /**
42 * This is called when the command is first encountered in
43 * the CMakeLists.txt file.
45 virtual bool InitialPass(std::vector<std::string> const& args,
46 cmExecutionStatus &status);
48 /**
49 * The name of the command as specified in CMakeList.txt.
51 virtual const char* GetName() {return "add_custom_command";}
53 /**
54 * Succinct documentation.
56 virtual const char* GetTerseDocumentation()
58 return "Add a custom build rule to the generated build system.";
61 /**
62 * More documentation.
64 virtual const char* GetFullDocumentation()
66 return
67 "There are two main signatures for add_custom_command "
68 "The first signature is for adding a custom command "
69 "to produce an output.\n"
70 " add_custom_command(OUTPUT output1 [output2 ...]\n"
71 " COMMAND command1 [ARGS] [args1...]\n"
72 " [COMMAND command2 [ARGS] [args2...] ...]\n"
73 " [MAIN_DEPENDENCY depend]\n"
74 " [DEPENDS [depends...]]\n"
75 " [IMPLICIT_DEPENDS <lang1> depend1 ...]\n"
76 " [WORKING_DIRECTORY dir]\n"
77 " [COMMENT comment] [VERBATIM] [APPEND])\n"
78 "This defines a command to generate specified OUTPUT file(s). "
79 "A target created in the same directory (CMakeLists.txt file) that "
80 "specifies any output of the custom command as a source file is given "
81 "a rule to generate the file using the command at build time. "
82 "If an output name is a relative path it will be interpreted "
83 "relative to the build tree directory corresponding to the current "
84 "source directory. "
85 "Note that MAIN_DEPENDENCY is completely optional and is "
86 "used as a suggestion to visual studio about where to hang the "
87 "custom command. In makefile terms this creates a new target in the "
88 "following form:\n"
89 " OUTPUT: MAIN_DEPENDENCY DEPENDS\n"
90 " COMMAND\n"
91 "If more than one command is specified they will be executed in order. "
92 "The optional ARGS argument is for backward compatibility and will be "
93 "ignored.\n"
94 "The second signature adds a custom command to a target "
95 "such as a library or executable. This is useful for "
96 "performing an operation before or after building the target. "
97 "The command becomes part of the target and will only execute "
98 "when the target itself is built. If the target is already built,"
99 " the command will not execute.\n"
100 " add_custom_command(TARGET target\n"
101 " PRE_BUILD | PRE_LINK | POST_BUILD\n"
102 " COMMAND command1 [ARGS] [args1...]\n"
103 " [COMMAND command2 [ARGS] [args2...] ...]\n"
104 " [WORKING_DIRECTORY dir]\n"
105 " [COMMENT comment] [VERBATIM])\n"
106 "This defines a new command that will be associated with "
107 "building the specified target. When the command will "
108 "happen is determined by which of the following is specified:\n"
109 " PRE_BUILD - run before all other dependencies\n"
110 " PRE_LINK - run after other dependencies\n"
111 " POST_BUILD - run after the target has been built\n"
112 "Note that the PRE_BUILD option is only supported on Visual "
113 "Studio 7 or later. For all other generators PRE_BUILD "
114 "will be treated as PRE_LINK.\n"
115 "If WORKING_DIRECTORY is specified the command will be executed "
116 "in the directory given. "
117 "If COMMENT is set, the value will be displayed as a "
118 "message before the commands are executed at build time. "
119 "If APPEND is specified the COMMAND and DEPENDS option values "
120 "are appended to the custom command for the first output specified. "
121 "There must have already been a previous call to this command with "
122 "the same output. The COMMENT, WORKING_DIRECTORY, and MAIN_DEPENDENCY "
123 "options are currently ignored when APPEND is given, "
124 "but may be used in the future."
125 "\n"
126 "If VERBATIM is given then all arguments to the commands will be "
127 "escaped properly for the build tool so that the invoked command "
128 "receives each argument unchanged. "
129 "Note that one level of escapes is still used by the CMake language "
130 "processor before add_custom_command even sees the arguments. "
131 "Use of VERBATIM is recommended as it enables correct behavior. "
132 "When VERBATIM is not given the behavior is platform specific because "
133 "there is no protection of tool-specific special characters."
134 "\n"
135 "If the output of the custom command is not actually "
136 "created as a file on disk it should be marked as SYMBOLIC with "
137 "SET_SOURCE_FILES_PROPERTIES.\n"
139 "The IMPLICIT_DEPENDS option requests scanning of implicit "
140 "dependencies of an input file. The language given specifies the "
141 "programming language whose corresponding dependency scanner should "
142 "be used. Currently only C and CXX language scanners are supported. "
143 "Dependencies discovered from the scanning are added to those of "
144 "the custom command at build time. Note that the IMPLICIT_DEPENDS "
145 "option is currently supported only for Makefile generators and "
146 "will be ignored by other generators."
147 "\n"
148 "If COMMAND specifies an executable target (created by "
149 "ADD_EXECUTABLE) it will automatically be replaced by the location "
150 "of the executable created at build time. Additionally a "
151 "target-level dependency will be added so that the executable target "
152 "will be built before any target using this custom command. However "
153 "this does NOT add a file-level dependency that would cause the "
154 "custom command to re-run whenever the executable is recompiled.\n"
156 "The DEPENDS option specifies files on which the command depends. "
157 "If any dependency is an OUTPUT of another custom command in the "
158 "same directory (CMakeLists.txt file) CMake automatically brings the "
159 "other custom command into the target in which this command is built. "
160 "If DEPENDS specifies any target (created by an ADD_* command) "
161 "a target-level dependency is created to make sure the target is "
162 "built before any target using this custom command. Additionally, "
163 "if the target is an executable or library a file-level dependency "
164 "is created to cause the custom command to re-run whenever the target "
165 "is recompiled.\n"
169 cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
170 protected:
171 bool CheckOutputs(const std::vector<std::string>& outputs);
175 #endif