You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
12 KiB

  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 cmInstallCommand_h
  14. #define cmInstallCommand_h
  15. #include "cmCommand.h"
  16. /** \class cmInstallCommand
  17. * \brief Specifies where to install some files
  18. *
  19. * cmInstallCommand is a general-purpose interface command for
  20. * specifying install rules.
  21. */
  22. class cmInstallCommand : public cmCommand
  23. {
  24. public:
  25. /**
  26. * This is a virtual constructor for the command.
  27. */
  28. virtual cmCommand* Clone()
  29. {
  30. return new cmInstallCommand;
  31. }
  32. /**
  33. * This is called when the command is first encountered in
  34. * the CMakeLists.txt file.
  35. */
  36. virtual bool InitialPass(std::vector<std::string> const& args);
  37. /**
  38. * The name of the command as specified in CMakeList.txt.
  39. */
  40. virtual const char* GetName() { return "install";}
  41. /**
  42. * Succinct documentation.
  43. */
  44. virtual const char* GetTerseDocumentation()
  45. {
  46. return "Specify rules to run at install time.";
  47. }
  48. /**
  49. * More documentation.
  50. */
  51. virtual const char* GetFullDocumentation()
  52. {
  53. return
  54. "This command generates installation rules for a project. "
  55. "Rules specified by calls to this command within a source directory "
  56. "are executed in order during installation. "
  57. "The order across directories is not defined."
  58. "\n"
  59. "There are multiple signatures for this command. Some of them define "
  60. "installation properties for files and targets. Properties common to "
  61. "multiple signatures are covered here but they are valid only for "
  62. "signatures that specify them.\n"
  63. "DESTINATION arguments specify "
  64. "the directory on disk to which a file will be installed. "
  65. "If a full path (with a leading slash or drive letter) is given it "
  66. "is used directly. If a relative path is given it is interpreted "
  67. "relative to the value of CMAKE_INSTALL_PREFIX.\n"
  68. "PERMISSIONS arguments specify permissions for installed files. "
  69. "Valid permissions are "
  70. "OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, "
  71. "GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, "
  72. "WORLD_READ, WORLD_WRITE, WORLD_EXECUTE, "
  73. "SETUID, and SETGID. "
  74. "Permissions that do not make sense on certain platforms are ignored "
  75. "on those platforms.\n"
  76. "The CONFIGURATIONS argument specifies a list of build configurations "
  77. "for which the install rule applies (Debug, Release, etc.).\n"
  78. "The COMPONENT argument specifies an installation component name "
  79. "with which the install rule is associated, such as \"runtime\" or "
  80. "\"development\". During component-specific installation only "
  81. "install rules associated with the given component name will be "
  82. "executed. During a full installation all components are installed.\n"
  83. "The RENAME argument specifies a name for an installed file that "
  84. "may be different from the original file. Renaming is allowed only "
  85. "when a single file is installed by the command.\n"
  86. "The OPTIONAL argument specifies that it is not an error if the "
  87. "file to be installed does not exist. "
  88. "\n"
  89. "The TARGETS signature:\n"
  90. " install(TARGETS targets...\n"
  91. " [[ARCHIVE|LIBRARY|RUNTIME]\n"
  92. " [DESTINATION <dir>]\n"
  93. " [PERMISSIONS permissions...]\n"
  94. " [CONFIGURATIONS [Debug|Release|...]]\n"
  95. " [COMPONENT <component>]\n"
  96. " [OPTIONAL]\n"
  97. " ] [...])\n"
  98. "The TARGETS form specifies rules for installing targets from a "
  99. "project. There are three kinds of target files that may be "
  100. "installed: archive, library, and runtime. "
  101. "Executables are always treated as runtime targets. "
  102. "Static libraries are always treated as archive targets. "
  103. "Module libraries are always treated as library targets. "
  104. "For non-DLL platforms shared libraries are treated as library "
  105. "targets. "
  106. "For DLL platforms the DLL part of a shared library is treated as "
  107. "a runtime target and the corresponding import library is treated as "
  108. "an archive target. "
  109. "All Windows-based systems including Cygwin are DLL platforms. "
  110. "The ARCHIVE, LIBRARY, and RUNTIME "
  111. "arguments change the type of target to which the subsequent "
  112. "properties "
  113. "apply. If none is given the installation properties apply to "
  114. "all target types. If only one is given then only targets of that "
  115. "type will be installed (which can be used to install just a DLL or "
  116. "just an import library)."
  117. "\n"
  118. "One or more groups of properties may be specified in a single call "
  119. "to the TARGETS form of this command. A target may be installed more "
  120. "than once to different locations. Consider hypothetical "
  121. "targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n"
  122. " install(TARGETS myExe mySharedLib myStaticLib\n"
  123. " RUNTIME DESTINATION bin\n"
  124. " LIBRARY DESTINATION lib\n"
  125. " ARCHIVE DESTINATION lib/static)\n"
  126. " install(TARGETS mySharedLib DESTINATION /some/full/path)\n"
  127. "will install myExe to <prefix>/bin and myStaticLib to "
  128. "<prefix>/lib/static. "
  129. "On non-DLL platforms mySharedLib will be installed to <prefix>/lib "
  130. "and /some/full/path. On DLL platforms the mySharedLib DLL will be "
  131. "installed to <prefix>/bin and /some/full/path and its import library "
  132. "will be installed to <prefix>/lib/static and /some/full/path. "
  133. "On non-DLL platforms mySharedLib will be installed to <prefix>/lib "
  134. "and /some/full/path."
  135. "\n"
  136. "Installing a target with EXCLUDE_FROM_ALL set to true has "
  137. "undefined behavior."
  138. "\n"
  139. "The FILES signature:\n"
  140. " install(FILES files... DESTINATION <dir>\n"
  141. " [PERMISSIONS permissions...]\n"
  142. " [CONFIGURATIONS [Debug|Release|...]]\n"
  143. " [COMPONENT <component>]\n"
  144. " [RENAME <name>] [OPTIONAL])\n"
  145. "The FILES form specifies rules for installing files for a "
  146. "project. File names given as relative paths are interpreted with "
  147. "respect to the current source directory. Files installed by this "
  148. "form are by default given permissions OWNER_WRITE, OWNER_READ, "
  149. "GROUP_READ, and WORLD_READ if no PERMISSIONS argument is given."
  150. "\n"
  151. "The PROGRAMS signature:\n"
  152. " install(PROGRAMS files... DESTINATION <dir>\n"
  153. " [PERMISSIONS permissions...]\n"
  154. " [CONFIGURATIONS [Debug|Release|...]]\n"
  155. " [COMPONENT <component>]\n"
  156. " [RENAME <name>] [OPTIONAL])\n"
  157. "The PROGRAMS form is identical to the FILES form except that the "
  158. "default permissions for the installed file also include "
  159. "OWNER_EXECUTE, GROUP_EXECUTE, and WORLD_EXECUTE. "
  160. "This form is intended to install programs that are not targets, "
  161. "such as shell scripts. Use the TARGETS form to install targets "
  162. "built within the project."
  163. "\n"
  164. "The DIRECTORY signature:\n"
  165. " install(DIRECTORY dirs... DESTINATION <dir>\n"
  166. " [FILE_PERMISSIONS permissions...]\n"
  167. " [DIRECTORY_PERMISSIONS permissions...]\n"
  168. " [USE_SOURCE_PERMISSIONS]\n"
  169. " [CONFIGURATIONS [Debug|Release|...]]\n"
  170. " [COMPONENT <component>]\n"
  171. " [[PATTERN <pattern> | REGEX <regex>]\n"
  172. " [EXCLUDE] [PERMISSIONS permissions...]] [...])\n"
  173. "The DIRECTORY form installs contents of one or more directories "
  174. "to a given destination. "
  175. "The directory structure is copied verbatim to the destination. "
  176. "The last component of each directory name is appended to the "
  177. "destination directory but a trailing slash may be used to "
  178. "avoid this because it leaves the last component empty. "
  179. "Directory names given as relative paths are interpreted with "
  180. "respect to the current source directory. "
  181. "If no input directory names are given the destination directory "
  182. "will be created but nothing will be installed into it. "
  183. "The FILE_PERMISSIONS and DIRECTORY_PERMISSIONS options specify "
  184. "permissions given to files and directories in the destination. "
  185. "If USE_SOURCE_PERMISSIONS is specified and FILE_PERMISSIONS is not, "
  186. "file permissions will be copied from the source directory structure. "
  187. "If no permissions are specified files will be given the default "
  188. "permissions specified in the FILES form of the command, and the "
  189. "directories will be given the default permissions specified in the "
  190. "PROGRAMS form of the command. "
  191. "The PATTERN and REGEX options specify a globbing pattern or regular "
  192. "expression to match directories or files encountered during traversal "
  193. "of an input directory. The full path to an input file or directory "
  194. "(with forward slashes) is matched against the expression. "
  195. "A PATTERN will match only complete file names: the portion of the "
  196. "full path matching the pattern must occur at the end of the file name "
  197. "and be preceded by a slash. "
  198. "A REGEX will match any portion of the full path but it may use "
  199. "'/' and '$' to simulate the PATTERN behavior. "
  200. "Options following one of these matching expressions "
  201. "are applied only to files or directories matching them. "
  202. "The EXCLUDE option will skip the matched file or directory. "
  203. "The PERMISSIONS option overrides the permissions setting for the "
  204. "matched file or directory. "
  205. "For example the code\n"
  206. " install(DIRECTORY icons scripts/ DESTINATION share/myproj\n"
  207. " PATTERN \"CVS\" EXCLUDE\n"
  208. " PATTERN \"scripts/*\"\n"
  209. " PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ\n"
  210. " GROUP_EXECUTE GROUP_READ)\n"
  211. "will install the icons directory to share/myproj/icons and the "
  212. "scripts directory to share/myproj. The icons will get default file "
  213. "permissions, the scripts will be given specific permissions, and "
  214. "any CVS directories will be excluded."
  215. "\n"
  216. "The SCRIPT and CODE signature:\n"
  217. " install([[SCRIPT <file>] [CODE <code>]] [...])\n"
  218. "The SCRIPT form will invoke the given CMake script files during "
  219. "installation. If the script file name is a relative path "
  220. "it will be interpreted with respect to the current source directory. "
  221. "The CODE form will invoke the given CMake code during installation. "
  222. "Code is specified as a single argument inside a double-quoted string. "
  223. "For example, the code\n"
  224. " install(CODE \"MESSAGE(\\\"Sample install message.\\\")\")\n"
  225. "will print a message during installation.\n"
  226. "NOTE: This command supercedes the INSTALL_TARGETS command and the "
  227. "target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. "
  228. "It also replaces the FILES forms of the INSTALL_FILES and "
  229. "INSTALL_PROGRAMS commands. "
  230. "The processing order of these install rules relative to those "
  231. "generated by INSTALL_TARGETS, INSTALL_FILES, and INSTALL_PROGRAMS "
  232. "commands is not defined.\n"
  233. ;
  234. }
  235. cmTypeMacro(cmInstallCommand, cmCommand);
  236. private:
  237. bool HandleScriptMode(std::vector<std::string> const& args);
  238. bool HandleTargetsMode(std::vector<std::string> const& args);
  239. bool HandleFilesMode(std::vector<std::string> const& args);
  240. bool HandleDirectoryMode(std::vector<std::string> const& args);
  241. bool HandleExportMode(std::vector<std::string> const& args);
  242. bool MakeFilesFullPath(const char* modeName,
  243. const std::vector<std::string>& relFiles,
  244. std::vector<std::string>& absFiles);
  245. };
  246. #endif