external.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. CPack External Generator
  2. ------------------------
  3. CPack provides many generators to create packages for a variety of platforms
  4. and packaging systems. The intention is for CMake/CPack to be a complete
  5. end-to-end solution for building and packaging a software project. However, it
  6. may not always be possible to use CPack for the entire packaging process, due
  7. to either technical limitations or policies that require the use of certain
  8. tools. For this reason, CPack provides the "External" generator, which allows
  9. external packaging software to take advantage of some of the functionality
  10. provided by CPack, such as component installation and the dependency graph.
  11. Integration with External Packaging Tools
  12. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  13. The CPack External generator generates a ``.json`` file containing the
  14. CPack internal metadata, which gives external software information
  15. on how to package the software. External packaging software may itself
  16. invoke CPack, consume the generated metadata,
  17. install and package files as required.
  18. Alternatively CPack can invoke an external packaging software
  19. through an optional custom CMake script in
  20. :variable:`CPACK_EXTERNAL_PACKAGE_SCRIPT` instead.
  21. Staging of installation files may also optionally be
  22. taken care of by the generator when enabled through the
  23. :variable:`CPACK_EXTERNAL_ENABLE_STAGING` variable.
  24. JSON Format
  25. ^^^^^^^^^^^
  26. The JSON metadata file contains a list of CPack components and component groups,
  27. the various options passed to :command:`cpack_add_component` and
  28. :command:`cpack_add_component_group`, the dependencies between the components
  29. and component groups, and various other options passed to CPack.
  30. The JSON's root object will always provide two fields:
  31. ``formatVersionMajor`` and ``formatVersionMinor``, which are always integers
  32. that describe the output format of the generator. Backwards-compatible changes
  33. to the output format (for example, adding a new field that didn't exist before)
  34. cause the minor version to be incremented, and backwards-incompatible changes
  35. (for example, deleting a field or changing its meaning) cause the major version
  36. to be incremented and the minor version reset to 0. The format version is
  37. always of the format ``major.minor``. In other words, it always has exactly two
  38. parts, separated by a period.
  39. You can request one or more specific versions of the output format as described
  40. below with :variable:`CPACK_EXTERNAL_REQUESTED_VERSIONS`. The output format will
  41. have a major version that exactly matches the requested major version, and a
  42. minor version that is greater than or equal to the requested minor version. If
  43. no version is requested with :variable:`CPACK_EXTERNAL_REQUESTED_VERSIONS`, the
  44. latest known major version is used by default. Currently, the only supported
  45. format is 1.0, which is described below.
  46. Version 1.0
  47. ***********
  48. In addition to the standard format fields, format version 1.0 provides the
  49. following fields in the root:
  50. ``components``
  51. The ``components`` field is an object with component names as the keys and
  52. objects describing the components as the values. The component objects have
  53. the following fields:
  54. ``name``
  55. The name of the component. This is always the same as the key in the
  56. ``components`` object.
  57. ``displayName``
  58. The value of the ``DISPLAY_NAME`` field passed to
  59. :command:`cpack_add_component`.
  60. ``description``
  61. The value of the ``DESCRIPTION`` field passed to
  62. :command:`cpack_add_component`.
  63. ``isHidden``
  64. True if ``HIDDEN`` was passed to :command:`cpack_add_component`, false if
  65. it was not.
  66. ``isRequired``
  67. True if ``REQUIRED`` was passed to :command:`cpack_add_component`, false if
  68. it was not.
  69. ``isDisabledByDefault``
  70. True if ``DISABLED`` was passed to :command:`cpack_add_component`, false if
  71. it was not.
  72. ``group``
  73. Only present if ``GROUP`` was passed to :command:`cpack_add_component`. If
  74. so, this field is a string value containing the component's group.
  75. ``dependencies``
  76. An array of components the component depends on. This contains the values
  77. in the ``DEPENDS`` argument passed to :command:`cpack_add_component`. If no
  78. ``DEPENDS`` argument was passed, this is an empty list.
  79. ``installationTypes``
  80. An array of installation types the component is part of. This contains the
  81. values in the ``INSTALL_TYPES`` argument passed to
  82. :command:`cpack_add_component`. If no ``INSTALL_TYPES`` argument was
  83. passed, this is an empty list.
  84. ``isDownloaded``
  85. True if ``DOWNLOADED`` was passed to :command:`cpack_add_component`, false
  86. if it was not.
  87. ``archiveFile``
  88. The name of the archive file passed with the ``ARCHIVE_FILE`` argument to
  89. :command:`cpack_add_component`. If no ``ARCHIVE_FILE`` argument was passed,
  90. this is an empty string.
  91. ``componentGroups``
  92. The ``componentGroups`` field is an object with component group names as the
  93. keys and objects describing the component groups as the values. The component
  94. group objects have the following fields:
  95. ``name``
  96. The name of the component group. This is always the same as the key in the
  97. ``componentGroups`` object.
  98. ``displayName``
  99. The value of the ``DISPLAY_NAME`` field passed to
  100. :command:`cpack_add_component_group`.
  101. ``description``
  102. The value of the ``DESCRIPTION`` field passed to
  103. :command:`cpack_add_component_group`.
  104. ``parentGroup``
  105. Only present if ``PARENT_GROUP`` was passed to
  106. :command:`cpack_add_component_group`. If so, this field is a string value
  107. containing the component group's parent group.
  108. ``isExpandedByDefault``
  109. True if ``EXPANDED`` was passed to :command:`cpack_add_component_group`,
  110. false if it was not.
  111. ``isBold``
  112. True if ``BOLD_TITLE`` was passed to :command:`cpack_add_component_group`,
  113. false if it was not.
  114. ``components``
  115. An array of names of components that are direct members of the group
  116. (components that have this group as their ``GROUP``). Components of
  117. subgroups are not included.
  118. ``subgroups``
  119. An array of names of component groups that are subgroups of the group
  120. (groups that have this group as their ``PARENT_GROUP``).
  121. ``installationTypes``
  122. The ``installationTypes`` field is an object with installation type names as
  123. the keys and objects describing the installation types as the values. The
  124. installation type objects have the following fields:
  125. ``name``
  126. The name of the installation type. This is always the same as the key in
  127. the ``installationTypes`` object.
  128. ``displayName``
  129. The value of the ``DISPLAY_NAME`` field passed to
  130. :command:`cpack_add_install_type`.
  131. ``index``
  132. The integer index of the installation type in the list.
  133. ``projects``
  134. The ``projects`` field is an array of objects describing CMake projects which
  135. comprise the CPack project. The values in this field are derived from
  136. :variable:`CPACK_INSTALL_CMAKE_PROJECTS`. In most cases, this will be only a
  137. single project. The project objects have the following fields:
  138. ``projectName``
  139. The project name passed to :variable:`CPACK_INSTALL_CMAKE_PROJECTS`.
  140. ``component``
  141. The name of the component or component set which comprises the project.
  142. ``directory``
  143. The build directory of the CMake project. This is the directory which
  144. contains the ``cmake_install.cmake`` script.
  145. ``subDirectory``
  146. The subdirectory to install the project into inside the CPack package.
  147. ``packageName``
  148. The package name given in :variable:`CPACK_PACKAGE_NAME`. Only present if
  149. this option is set.
  150. ``packageVersion``
  151. The package version given in :variable:`CPACK_PACKAGE_VERSION`. Only present
  152. if this option is set.
  153. ``packageDescriptionFile``
  154. The package description file given in
  155. :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`. Only present if this option is
  156. set.
  157. ``packageDescriptionSummary``
  158. The package description summary given in
  159. :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`. Only present if this option is
  160. set.
  161. ``buildConfig``
  162. The build configuration given to CPack with the ``-C`` option. Only present
  163. if this option is set.
  164. ``defaultDirectoryPermissions``
  165. The default directory permissions given in
  166. :variable:`CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`. Only present if this
  167. option is set.
  168. ``setDestdir``
  169. True if :variable:`CPACK_SET_DESTDIR` is true, false if it is not.
  170. ``packagingInstallPrefix``
  171. The install prefix given in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`. Only
  172. present if :variable:`CPACK_SET_DESTDIR` is true.
  173. ``stripFiles``
  174. True if :variable:`CPACK_STRIP_FILES` is true, false if it is not.
  175. ``warnOnAbsoluteInstallDestination``
  176. True if :variable:`CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION` is true, false
  177. if it is not.
  178. ``errorOnAbsoluteInstallDestination``
  179. True if :variable:`CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION` is true,
  180. false if it is not.
  181. Variables specific to CPack External generator
  182. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  183. .. variable:: CPACK_EXTERNAL_REQUESTED_VERSIONS
  184. This variable is used to request a specific version of the CPack External
  185. generator. It is a list of ``major.minor`` values, separated by semicolons.
  186. If this variable is set to a non-empty value, the CPack External generator
  187. will iterate through each item in the list to search for a version that it
  188. knows how to generate. Requested versions should be listed in order of
  189. descending preference by the client software, as the first matching version
  190. in the list will be generated.
  191. The generator knows how to generate the version if it has a versioned
  192. generator whose major version exactly matches the requested major version,
  193. and whose minor version is greater than or equal to the requested minor
  194. version. For example, if ``CPACK_EXTERNAL_REQUESTED_VERSIONS`` contains 1.0, and
  195. the CPack External generator knows how to generate 1.1, it will generate 1.1.
  196. If the generator doesn't know how to generate a version in the list, it skips
  197. the version and looks at the next one. If it doesn't know how to generate any
  198. of the requested versions, an error is thrown.
  199. If this variable is not set, or is empty, the CPack External generator will
  200. generate the highest major and minor version that it knows how to generate.
  201. If an invalid version is encountered in ``CPACK_EXTERNAL_REQUESTED_VERSIONS`` (one
  202. that doesn't match ``major.minor``, where ``major`` and ``minor`` are
  203. integers), it is ignored.
  204. .. variable:: CPACK_EXTERNAL_ENABLE_STAGING
  205. This variable can be set to true to enable optional installation
  206. into a temporary staging area which can then be picked up
  207. and packaged by an external packaging tool.
  208. The top level directory used by CPack for the current packaging
  209. task is contained in ``CPACK_TOPLEVEL_DIRECTORY``.
  210. It is automatically cleaned up on each run before packaging is initiated
  211. and can be used for custom temporary files required by
  212. the external packaging tool.
  213. It also contains the staging area ``CPACK_TEMPORARY_DIRECTORY``
  214. into which CPack performs the installation when staging is enabled.
  215. .. variable:: CPACK_EXTERNAL_PACKAGE_SCRIPT
  216. This variable can optionally specify the full path to
  217. a CMake script file to be run as part of the CPack invocation.
  218. It is invoked after (optional) staging took place and may
  219. run an external packaging tool. The script has access to
  220. the variables defined by the CPack config file.