Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmInstallCommand.h
blob1ba84bcfd097de7e0fb658723af44160d78ab510
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmInstallCommand.h,v $
5 Language: C++
6 Date: $Date: 2008/01/28 20:12:12 $
7 Version: $Revision: 1.28 $
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 cmInstallCommand_h
18 #define cmInstallCommand_h
20 #include "cmCommand.h"
22 /** \class cmInstallCommand
23 * \brief Specifies where to install some files
25 * cmInstallCommand is a general-purpose interface command for
26 * specifying install rules.
28 class cmInstallCommand : public cmCommand
30 public:
31 /**
32 * This is a virtual constructor for the command.
34 virtual cmCommand* Clone()
36 return new cmInstallCommand;
39 /**
40 * This is called when the command is first encountered in
41 * the CMakeLists.txt file.
43 virtual bool InitialPass(std::vector<std::string> const& args,
44 cmExecutionStatus &status);
46 /**
47 * The name of the command as specified in CMakeList.txt.
49 virtual const char* GetName() { return "install";}
51 /**
52 * Succinct documentation.
54 virtual const char* GetTerseDocumentation()
56 return "Specify rules to run at install time.";
59 /**
60 * More documentation.
62 virtual const char* GetFullDocumentation()
64 return
65 "This command generates installation rules for a project. "
66 "Rules specified by calls to this command within a source directory "
67 "are executed in order during installation. "
68 "The order across directories is not defined."
69 "\n"
70 "There are multiple signatures for this command. Some of them define "
71 "installation properties for files and targets. Properties common to "
72 "multiple signatures are covered here but they are valid only for "
73 "signatures that specify them.\n"
74 "DESTINATION arguments specify "
75 "the directory on disk to which a file will be installed. "
76 "If a full path (with a leading slash or drive letter) is given it "
77 "is used directly. If a relative path is given it is interpreted "
78 "relative to the value of CMAKE_INSTALL_PREFIX.\n"
79 "PERMISSIONS arguments specify permissions for installed files. "
80 "Valid permissions are "
81 "OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, "
82 "GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, "
83 "WORLD_READ, WORLD_WRITE, WORLD_EXECUTE, "
84 "SETUID, and SETGID. "
85 "Permissions that do not make sense on certain platforms are ignored "
86 "on those platforms.\n"
87 "The CONFIGURATIONS argument specifies a list of build configurations "
88 "for which the install rule applies (Debug, Release, etc.).\n"
89 "The COMPONENT argument specifies an installation component name "
90 "with which the install rule is associated, such as \"runtime\" or "
91 "\"development\". During component-specific installation only "
92 "install rules associated with the given component name will be "
93 "executed. During a full installation all components are installed.\n"
94 "The RENAME argument specifies a name for an installed file that "
95 "may be different from the original file. Renaming is allowed only "
96 "when a single file is installed by the command.\n"
97 "The OPTIONAL argument specifies that it is not an error if the "
98 "file to be installed does not exist. "
99 "\n"
100 "The TARGETS signature:\n"
101 " install(TARGETS targets... [EXPORT <export-name>]\n"
102 " [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|\n"
103 " PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]\n"
104 " [DESTINATION <dir>]\n"
105 " [PERMISSIONS permissions...]\n"
106 " [CONFIGURATIONS [Debug|Release|...]]\n"
107 " [COMPONENT <component>]\n"
108 " [OPTIONAL]\n"
109 " ] [...])\n"
110 "The TARGETS form specifies rules for installing targets from a "
111 "project. There are five kinds of target files that may be "
112 "installed: archive, library, runtime, framework, and bundle. "
114 "Executables are treated as runtime targets, except that those "
115 "marked with the MACOSX_BUNDLE property are treated as bundle "
116 "targets on OS X. "
117 "Static libraries are always treated as archive targets. "
118 "Module libraries are always treated as library targets. "
119 "For non-DLL platforms shared libraries are treated as library "
120 "targets, except that those marked with the FRAMEWORK property "
121 "are treated as framework targets on OS X. "
122 "For DLL platforms the DLL part of a shared library is treated as "
123 "a runtime target and the corresponding import library is treated as "
124 "an archive target. "
125 "All Windows-based systems including Cygwin are DLL platforms. "
126 "The ARCHIVE, LIBRARY, RUNTIME, and FRAMEWORK "
127 "arguments change the type of target to which the subsequent "
128 "properties "
129 "apply. If none is given the installation properties apply to "
130 "all target types. If only one is given then only targets of that "
131 "type will be installed (which can be used to install just a DLL or "
132 "just an import library)."
133 "\n"
134 "The PRIVATE_HEADER, PUBLIC_HEADER, and RESOURCE arguments cause "
135 "subsequent properties to be applied to installing a FRAMEWORK "
136 "shared library target's associated files on non-Apple platforms. "
137 "Rules defined by these arguments are ignored on Apple platforms "
138 "because the associated files are installed into the appropriate "
139 "locations inside the framework folder. "
140 "See documentation of the PRIVATE_HEADER, PUBLIC_HEADER, and RESOURCE "
141 "target properties for details."
142 "\n"
143 "One or more groups of properties may be specified in a single call "
144 "to the TARGETS form of this command. A target may be installed more "
145 "than once to different locations. Consider hypothetical "
146 "targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n"
147 " install(TARGETS myExe mySharedLib myStaticLib\n"
148 " RUNTIME DESTINATION bin\n"
149 " LIBRARY DESTINATION lib\n"
150 " ARCHIVE DESTINATION lib/static)\n"
151 " install(TARGETS mySharedLib DESTINATION /some/full/path)\n"
152 "will install myExe to <prefix>/bin and myStaticLib to "
153 "<prefix>/lib/static. "
154 "On non-DLL platforms mySharedLib will be installed to <prefix>/lib "
155 "and /some/full/path. On DLL platforms the mySharedLib DLL will be "
156 "installed to <prefix>/bin and /some/full/path and its import library "
157 "will be installed to <prefix>/lib/static and /some/full/path. "
158 "On non-DLL platforms mySharedLib will be installed to <prefix>/lib "
159 "and /some/full/path."
160 "\n"
161 "The EXPORT option associates the installed target files with an "
162 "export called <export-name>. "
163 "It must appear before any RUNTIME, LIBRARY, or ARCHIVE options. "
164 "See documentation of the install(EXPORT ...) signature below for "
165 "details."
166 "\n"
167 "Installing a target with EXCLUDE_FROM_ALL set to true has "
168 "undefined behavior."
169 "\n"
170 "The FILES signature:\n"
171 " install(FILES files... DESTINATION <dir>\n"
172 " [PERMISSIONS permissions...]\n"
173 " [CONFIGURATIONS [Debug|Release|...]]\n"
174 " [COMPONENT <component>]\n"
175 " [RENAME <name>] [OPTIONAL])\n"
176 "The FILES form specifies rules for installing files for a "
177 "project. File names given as relative paths are interpreted with "
178 "respect to the current source directory. Files installed by this "
179 "form are by default given permissions OWNER_WRITE, OWNER_READ, "
180 "GROUP_READ, and WORLD_READ if no PERMISSIONS argument is given."
181 "\n"
182 "The PROGRAMS signature:\n"
183 " install(PROGRAMS files... DESTINATION <dir>\n"
184 " [PERMISSIONS permissions...]\n"
185 " [CONFIGURATIONS [Debug|Release|...]]\n"
186 " [COMPONENT <component>]\n"
187 " [RENAME <name>] [OPTIONAL])\n"
188 "The PROGRAMS form is identical to the FILES form except that the "
189 "default permissions for the installed file also include "
190 "OWNER_EXECUTE, GROUP_EXECUTE, and WORLD_EXECUTE. "
191 "This form is intended to install programs that are not targets, "
192 "such as shell scripts. Use the TARGETS form to install targets "
193 "built within the project."
194 "\n"
195 "The DIRECTORY signature:\n"
196 " install(DIRECTORY dirs... DESTINATION <dir>\n"
197 " [FILE_PERMISSIONS permissions...]\n"
198 " [DIRECTORY_PERMISSIONS permissions...]\n"
199 " [USE_SOURCE_PERMISSIONS]\n"
200 " [CONFIGURATIONS [Debug|Release|...]]\n"
201 " [COMPONENT <component>] [FILES_MATCHING]\n"
202 " [[PATTERN <pattern> | REGEX <regex>]\n"
203 " [EXCLUDE] [PERMISSIONS permissions...]] [...])\n"
204 "The DIRECTORY form installs contents of one or more directories "
205 "to a given destination. "
206 "The directory structure is copied verbatim to the destination. "
207 "The last component of each directory name is appended to the "
208 "destination directory but a trailing slash may be used to "
209 "avoid this because it leaves the last component empty. "
210 "Directory names given as relative paths are interpreted with "
211 "respect to the current source directory. "
212 "If no input directory names are given the destination directory "
213 "will be created but nothing will be installed into it. "
214 "The FILE_PERMISSIONS and DIRECTORY_PERMISSIONS options specify "
215 "permissions given to files and directories in the destination. "
216 "If USE_SOURCE_PERMISSIONS is specified and FILE_PERMISSIONS is not, "
217 "file permissions will be copied from the source directory structure. "
218 "If no permissions are specified files will be given the default "
219 "permissions specified in the FILES form of the command, and the "
220 "directories will be given the default permissions specified in the "
221 "PROGRAMS form of the command.\n"
223 "Installation of directories may be controlled with fine granularity "
224 "using the PATTERN or REGEX options. These \"match\" options specify a "
225 "globbing pattern or regular expression to match directories or files "
226 "encountered within input directories. They may be used to apply "
227 "certain options (see below) to a subset of the files and directories "
228 "encountered. "
229 "The full path to each input file or directory "
230 "(with forward slashes) is matched against the expression. "
231 "A PATTERN will match only complete file names: the portion of the "
232 "full path matching the pattern must occur at the end of the file name "
233 "and be preceded by a slash. "
234 "A REGEX will match any portion of the full path but it may use "
235 "'/' and '$' to simulate the PATTERN behavior. "
236 "By default all files and directories are installed whether "
237 "or not they are matched. "
238 "The FILES_MATCHING option may be given before the first match option "
239 "to disable installation of files (but not directories) not matched by "
240 "any expression. For example, the code\n"
241 " install(DIRECTORY src/ DESTINATION include/myproj\n"
242 " FILES_MATCHING PATTERN \"*.h\")\n"
243 "will extract and install header files from a source tree.\n"
244 "Some options may follow a PATTERN or REGEX expression and are "
245 "applied only to files or directories matching them. "
246 "The EXCLUDE option will skip the matched file or directory. "
247 "The PERMISSIONS option overrides the permissions setting for the "
248 "matched file or directory. "
249 "For example the code\n"
250 " install(DIRECTORY icons scripts/ DESTINATION share/myproj\n"
251 " PATTERN \"CVS\" EXCLUDE\n"
252 " PATTERN \"scripts/*\"\n"
253 " PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ\n"
254 " GROUP_EXECUTE GROUP_READ)\n"
255 "will install the icons directory to share/myproj/icons and the "
256 "scripts directory to share/myproj. The icons will get default file "
257 "permissions, the scripts will be given specific permissions, and "
258 "any CVS directories will be excluded."
259 "\n"
260 "The SCRIPT and CODE signature:\n"
261 " install([[SCRIPT <file>] [CODE <code>]] [...])\n"
262 "The SCRIPT form will invoke the given CMake script files during "
263 "installation. If the script file name is a relative path "
264 "it will be interpreted with respect to the current source directory. "
265 "The CODE form will invoke the given CMake code during installation. "
266 "Code is specified as a single argument inside a double-quoted string. "
267 "For example, the code\n"
268 " install(CODE \"MESSAGE(\\\"Sample install message.\\\")\")\n"
269 "will print a message during installation.\n"
271 "The EXPORT signature:\n"
272 " install(EXPORT <export-name> DESTINATION <dir>\n"
273 " [NAMESPACE <namespace>] [FILE <name>.cmake]\n"
274 " [PERMISSIONS permissions...]\n"
275 " [CONFIGURATIONS [Debug|Release|...]]\n"
276 " [COMPONENT <component>])\n"
277 "The EXPORT form generates and installs a CMake file containing code "
278 "to import targets from the installation tree into another project. "
279 "Target installations are associated with the export <export-name> "
280 "using the EXPORT option of the install(TARGETS ...) signature "
281 "documented above. The NAMESPACE option will prepend <namespace> to "
282 "the target names as they are written to the import file. "
283 "By default the generated file will be called <export-name>.cmake but "
284 "the FILE option may be used to specify a different name. The value "
285 "given to the FILE option must be a file name with the \".cmake\" "
286 "extension. "
287 "If a CONFIGURATIONS option is given then the file will only be "
288 "installed when one of the named configurations is installed. "
289 "Additionally, the generated import file will reference only the "
290 "matching target configurations. "
291 "If a COMPONENT option is specified that does not match that given "
292 "to the targets associated with <export-name> the behavior is "
293 "undefined. "
294 "If a library target is included in the export but "
295 "a target to which it links is not included the behavior is "
296 "unspecified."
297 "\n"
298 "The EXPORT form is useful to help outside projects use targets built "
299 "and installed by the current project. For example, the code\n"
300 " install(TARGETS myexe EXPORT myproj DESTINATION bin)\n"
301 " install(EXPORT myproj NAMESPACE mp_ DESTINATION lib/myproj)\n"
302 "will install the executable myexe to <prefix>/bin and code to import "
303 "it in the file \"<prefix>/lib/myproj/myproj.cmake\". "
304 "An outside project may load this file with the include command "
305 "and reference the myexe executable from the installation tree using "
306 "the imported target name mp_myexe as if the target were built "
307 "in its own tree."
308 "\n"
309 "NOTE: This command supercedes the INSTALL_TARGETS command and the "
310 "target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. "
311 "It also replaces the FILES forms of the INSTALL_FILES and "
312 "INSTALL_PROGRAMS commands. "
313 "The processing order of these install rules relative to those "
314 "generated by INSTALL_TARGETS, INSTALL_FILES, and INSTALL_PROGRAMS "
315 "commands is not defined.\n"
319 cmTypeMacro(cmInstallCommand, cmCommand);
321 private:
322 bool HandleScriptMode(std::vector<std::string> const& args);
323 bool HandleTargetsMode(std::vector<std::string> const& args);
324 bool HandleFilesMode(std::vector<std::string> const& args);
325 bool HandleDirectoryMode(std::vector<std::string> const& args);
326 bool HandleExportMode(std::vector<std::string> const& args);
327 bool MakeFilesFullPath(const char* modeName,
328 const std::vector<std::string>& relFiles,
329 std::vector<std::string>& absFiles);
333 #endif