cmInstallCommand.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 RENAME argument specifies a name for an installed file that "
  77. "may be different from the original file. Renaming is allowed only "
  78. "when a single file is installed by the command. "
  79. "\n"
  80. "The TARGETS signature:\n"
  81. " INSTALL(TARGETS targets... [[LIBRARY|RUNTIME]\n"
  82. " [DESTINATION <dir>]\n"
  83. " [PERMISSIONS permissions...]\n"
  84. " ] [...])\n"
  85. "The TARGETS form specifies rules for installing targets from a "
  86. "project. There are two kinds of target files that may be "
  87. "installed: library and runtime. Static libraries and modules "
  88. "are always treated as library targets. Executables are always "
  89. "treated as runtime targets. For non-DLL platforms, shared libraries "
  90. "are treated as library targets. For DLL platforms, the DLL part of "
  91. "a shared library is treated as a runtime target and the corresponding "
  92. "import library is treated as a library target. All Windows-based "
  93. "systems including Cygwin are DLL platforms. The LIBRARY and RUNTIME "
  94. "arguments change the type of target to which the following properties "
  95. "apply. If neither is given the installation properties apply to "
  96. "both target types. If only one is given then only targets of that "
  97. "type will be installed (which can be used to install just a DLL or "
  98. "just an import library)."
  99. "\n"
  100. "One or more groups of properties may be specified in a single call "
  101. "to the TARGETS form of this command. A target may be installed more "
  102. "than once to different locations. Consider hypothetical "
  103. "targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n"
  104. " INSTALL(TARGETS myExe mySharedLib myStaticLib\n"
  105. " RUNTIME DESTINATION bin\n"
  106. " LIBRARY DESTINATION lib)\n"
  107. " INSTALL(TARGETS mySharedLib DESTINATION /some/full/path)\n"
  108. "will install myExe to <prefix>/bin and myStaticLib to <prefix>/lib. "
  109. "On non-DLL platforms mySharedLib will be installed to <prefix>/lib and "
  110. "/some/full/path. On DLL platforms the mySharedLib DLL will be "
  111. "installed to <prefix>/bin and /some/full/path and its import library "
  112. "will be installed to <prefix>/lib and /some/full/path. On non-DLL "
  113. "platforms mySharedLib will be installed to <prefix>/lib and "
  114. "/some/full/path."
  115. "\n"
  116. "The FILES signature:\n"
  117. " INSTALL(FILES files... DESTINATION <dir>\n"
  118. " [PERMISSIONS permissions...] [RENAME <name>])\n"
  119. "The FILES form specifies rules for installing files for a "
  120. "project. File names given as relative paths are interpreted with "
  121. "respect to the current source directory. Files installed by this "
  122. "form are given the same permissions as the original file by default."
  123. "\n"
  124. "The PROGRAMS signature:\n"
  125. " INSTALL(PROGRAMS files... DESTINATION <dir>\n"
  126. " [PERMISSIONS permissions...] [RENAME <name>])\n"
  127. "The PROGRAMS form is identical to the FILES form except that the "
  128. "default permissions for the installed file mark it as executable. "
  129. "This form is intended to install programs that are not targets, "
  130. "such as shell scripts. Use the TARGETS form to install targets "
  131. "built within the project."
  132. "\n"
  133. "The SCRIPT signature:\n"
  134. " INSTALL(SCRIPT <file1> [SCRIPT <file2> [...]])\n"
  135. "The SCRIPT form will invoke the given CMake script files during "
  136. "installation. If the script file name is a relative path "
  137. "it will be interpreted with respect to the current source directory."
  138. "\n"
  139. "NOTE: This command supercedes the INSTALL_TARGETS command and the "
  140. "target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. "
  141. "It also replaces the FILES forms of the INSTALL_FILES and "
  142. "INSTALL_PROGRAMS commands. "
  143. "The processing order of these install rules relative to those "
  144. "generated by INSTALL_TARGETS, INSTALL_FILES, and INSTALL_PROGRAMS "
  145. "commands is not defined.\n"
  146. ;
  147. }
  148. cmTypeMacro(cmInstallCommand, cmCommand);
  149. private:
  150. bool HandleScriptMode(std::vector<std::string> const& args);
  151. bool HandleTargetsMode(std::vector<std::string> const& args);
  152. bool HandleFilesMode(std::vector<std::string> const& args);
  153. void ComputeDestination(const char* destination, std::string& dest);
  154. bool CheckPermissions(std::string const& arg, std::string& permissions);
  155. };
  156. #endif