cmInstallCommand.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. "
  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. "
  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. "
  76. "The CONFIGURATIONS argument specifies a list of build configurations "
  77. "for which the install rule applies (Debug, Release, etc.). "
  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. "
  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. "
  86. "\n"
  87. "The TARGETS signature:\n"
  88. " INSTALL(TARGETS targets... [[ARCHIVE|LIBRARY|RUNTIME]\n"
  89. " [DESTINATION <dir>]\n"
  90. " [PERMISSIONS permissions...]\n"
  91. " [CONFIGURATIONS [Debug|Release|...]]\n"
  92. " [COMPONENT <component>]\n"
  93. " ] [...])\n"
  94. "The TARGETS form specifies rules for installing targets from a "
  95. "project. There are three kinds of target files that may be "
  96. "installed: archive, library, and runtime. "
  97. "Executables are always treated as runtime targets. "
  98. "Static libraries are always treated as archive targets. "
  99. "Module libraries are always treated as library targets. "
  100. "For non-DLL platforms shared libraries are treated as library "
  101. "targets. "
  102. "For DLL platforms the DLL part of a shared library is treated as "
  103. "a runtime target and the corresponding import library is treated as "
  104. "an archive target. "
  105. "All Windows-based systems including Cygwin are DLL platforms. "
  106. "The ARCHIVE, LIBRARY, and RUNTIME "
  107. "arguments change the type of target to which the subsequent "
  108. "properties "
  109. "apply. If none is given the installation properties apply to "
  110. "all target types. If only one is given then only targets of that "
  111. "type will be installed (which can be used to install just a DLL or "
  112. "just an import library)."
  113. "\n"
  114. "One or more groups of properties may be specified in a single call "
  115. "to the TARGETS form of this command. A target may be installed more "
  116. "than once to different locations. Consider hypothetical "
  117. "targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n"
  118. " INSTALL(TARGETS myExe mySharedLib myStaticLib\n"
  119. " RUNTIME DESTINATION bin\n"
  120. " LIBRARY DESTINATION lib\n"
  121. " ARCHIVE DESTINATION lib/static)\n"
  122. " INSTALL(TARGETS mySharedLib DESTINATION /some/full/path)\n"
  123. "will install myExe to <prefix>/bin and myStaticLib to "
  124. "<prefix>/lib/static. "
  125. "On non-DLL platforms mySharedLib will be installed to <prefix>/lib "
  126. "and /some/full/path. On DLL platforms the mySharedLib DLL will be "
  127. "installed to <prefix>/bin and /some/full/path and its import library "
  128. "will be installed to <prefix>/lib/static and /some/full/path. "
  129. "On non-DLL platforms mySharedLib will be installed to <prefix>/lib "
  130. "and /some/full/path."
  131. "\n"
  132. "The FILES signature:\n"
  133. " INSTALL(FILES files... DESTINATION <dir>\n"
  134. " [PERMISSIONS permissions...]\n"
  135. " [CONFIGURATIONS [Debug|Release|...]]\n"
  136. " [COMPONENT <component>]\n"
  137. " [RENAME <name>])\n"
  138. "The FILES form specifies rules for installing files for a "
  139. "project. File names given as relative paths are interpreted with "
  140. "respect to the current source directory. Files installed by this "
  141. "form are by default given permissions OWNER_WRITE, OWNER_READ, "
  142. "GROUP_READ, and WORLD_READ if no PERMISSIONS argument is given."
  143. "\n"
  144. "The PROGRAMS signature:\n"
  145. " INSTALL(PROGRAMS files... DESTINATION <dir>\n"
  146. " [PERMISSIONS permissions...]\n"
  147. " [CONFIGURATIONS [Debug|Release|...]]\n"
  148. " [COMPONENT <component>]\n"
  149. " [RENAME <name>])\n"
  150. "The PROGRAMS form is identical to the FILES form except that the "
  151. "default permissions for the installed file also include "
  152. "OWNER_EXECUTE, GROUP_EXECUTE, and WORLD_EXECUTE. "
  153. "This form is intended to install programs that are not targets, "
  154. "such as shell scripts. Use the TARGETS form to install targets "
  155. "built within the project."
  156. "\n"
  157. "The SCRIPT and CODE signature:\n"
  158. " INSTALL([[SCRIPT <file>] [CODE <code>]] [...])\n"
  159. "The SCRIPT form will invoke the given CMake script files during "
  160. "installation. If the script file name is a relative path "
  161. "it will be interpreted with respect to the current source directory. "
  162. "The CODE form will invoke the given CMake code during installation. "
  163. "Code is specified as a single argument inside a double-quoted string. "
  164. "For example, the code\n"
  165. " INSTALL(CODE \"MESSAGE(\\\"Sample install message.\\\")\")\n"
  166. "will print a message during installation.\n"
  167. "NOTE: This command supercedes the INSTALL_TARGETS command and the "
  168. "target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. "
  169. "It also replaces the FILES forms of the INSTALL_FILES and "
  170. "INSTALL_PROGRAMS commands. "
  171. "The processing order of these install rules relative to those "
  172. "generated by INSTALL_TARGETS, INSTALL_FILES, and INSTALL_PROGRAMS "
  173. "commands is not defined.\n"
  174. ;
  175. }
  176. cmTypeMacro(cmInstallCommand, cmCommand);
  177. private:
  178. bool HandleScriptMode(std::vector<std::string> const& args);
  179. bool HandleTargetsMode(std::vector<std::string> const& args);
  180. bool HandleFilesMode(std::vector<std::string> const& args);
  181. void ComputeDestination(const char* destination, std::string& dest);
  182. bool CheckPermissions(std::string const& arg, std::string& permissions);
  183. };
  184. #endif