CPackDeb.cmake 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # CPackDeb
  5. # --------
  6. #
  7. # The built in (binary) CPack Deb generator (Unix only)
  8. #
  9. # Variables specific to CPack Debian (DEB) generator
  10. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  11. #
  12. # CPackDeb may be used to create Deb package using :module:`CPack`.
  13. # CPackDeb is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
  14. # variables used by :module:`CPack`.
  15. #
  16. # CPackDeb generator should work on any Linux host but it will produce
  17. # better deb package when Debian specific tools ``dpkg-xxx`` are usable on
  18. # the build system.
  19. #
  20. # CPackDeb has specific features which are controlled by the specifics
  21. # :code:`CPACK_DEBIAN_XXX` variables.
  22. #
  23. # :code:`CPACK_DEBIAN_<COMPONENT>_XXXX` variables may be used in order to have
  24. # **component** specific values. Note however that ``<COMPONENT>`` refers to
  25. # the **grouping name** written in upper case. It may be either a component name
  26. # or a component GROUP name.
  27. #
  28. # Here are some CPackDeb wiki resources that are here for historic reasons and
  29. # are no longer maintained but may still prove useful:
  30. #
  31. # - https://cmake.org/Wiki/CMake:CPackConfiguration
  32. # - https://cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
  33. #
  34. # List of CPackDEB specific variables:
  35. #
  36. # .. variable:: CPACK_DEB_COMPONENT_INSTALL
  37. #
  38. # Enable component packaging for CPackDEB
  39. #
  40. # * Mandatory : NO
  41. # * Default : OFF
  42. #
  43. # If enabled (ON) multiple packages are generated. By default a single package
  44. # containing files of all components is generated.
  45. #
  46. # .. variable:: CPACK_DEBIAN_PACKAGE_NAME
  47. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
  48. #
  49. # Set Package control field (variable is automatically transformed to lower
  50. # case).
  51. #
  52. # * Mandatory : YES
  53. # * Default :
  54. #
  55. # - :variable:`CPACK_PACKAGE_NAME` for non-component based
  56. # installations
  57. # - :variable:`CPACK_DEBIAN_PACKAGE_NAME` suffixed with -<COMPONENT>
  58. # for component-based installations.
  59. #
  60. # See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
  61. #
  62. # .. variable:: CPACK_DEBIAN_FILE_NAME
  63. # CPACK_DEBIAN_<COMPONENT>_FILE_NAME
  64. #
  65. # Package file name.
  66. #
  67. # * Mandatory : YES
  68. # * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb``
  69. #
  70. # This may be set to ``DEB-DEFAULT`` to allow CPackDeb to generate package file
  71. # name by itself in deb format::
  72. #
  73. # <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
  74. #
  75. # Alternatively provided package file name must end
  76. # with either ``.deb`` or ``.ipk`` suffix.
  77. #
  78. # .. note::
  79. #
  80. # Preferred setting of this variable is ``DEB-DEFAULT`` but for backward
  81. # compatibility with CPackDeb in CMake prior to version 3.6 this feature
  82. # is disabled by default.
  83. #
  84. # .. note::
  85. #
  86. # By using non default filenames duplicate names may occur. Duplicate files
  87. # get overwritten and it is up to the packager to set the variables in a
  88. # manner that will prevent such errors.
  89. #
  90. # .. variable:: CPACK_DEBIAN_PACKAGE_EPOCH
  91. #
  92. # The Debian package epoch
  93. #
  94. # * Mandatory : No
  95. # * Default : -
  96. #
  97. # Optional number that should be incremented when changing versioning schemas
  98. # or fixing mistakes in the version numbers of older packages.
  99. #
  100. # .. variable:: CPACK_DEBIAN_PACKAGE_VERSION
  101. #
  102. # The Debian package version
  103. #
  104. # * Mandatory : YES
  105. # * Default : :variable:`CPACK_PACKAGE_VERSION`
  106. #
  107. # This variable may contain only alphanumerics (A-Za-z0-9) and the characters
  108. # . + - ~ (full stop, plus, hyphen, tilde) and should start with a digit. If
  109. # :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` is not set then hyphens are not
  110. # allowed.
  111. #
  112. # .. note::
  113. #
  114. # For backward compatibility with CMake 3.9 and lower a failed test of this
  115. # variable's content is not a hard error when both
  116. # :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` and
  117. # :variable:`CPACK_DEBIAN_PACKAGE_EPOCH` variables are not set. An author
  118. # warning is reported instead.
  119. #
  120. # .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
  121. #
  122. # The Debian package release - Debian revision number.
  123. #
  124. # * Mandatory : No
  125. # * Default : -
  126. #
  127. # This is the numbering of the DEB package itself, i.e. the version of the
  128. # packaging and not the version of the content (see
  129. # :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value
  130. # if the previous packaging was buggy and/or you want to put here a fancy Linux
  131. # distro specific numbering.
  132. #
  133. # .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE
  134. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
  135. #
  136. # The Debian package architecture
  137. #
  138. # * Mandatory : YES
  139. # * Default : Output of :code:`dpkg --print-architecture` (or :code:`i386`
  140. # if :code:`dpkg` is not found)
  141. #
  142. # .. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS
  143. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
  144. #
  145. # Sets the Debian dependencies of this package.
  146. #
  147. # * Mandatory : NO
  148. # * Default :
  149. #
  150. # - An empty string for non-component based installations
  151. # - :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS` for component-based
  152. # installations.
  153. #
  154. # .. note::
  155. #
  156. # If :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` or
  157. # more specifically :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS`
  158. # is set for this component, the discovered dependencies will be appended
  159. # to :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` instead of
  160. # :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS`. If
  161. # :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` is an empty string,
  162. # only the automatically discovered dependencies will be set for this
  163. # component.
  164. #
  165. # Example::
  166. #
  167. # set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)")
  168. #
  169. # .. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS
  170. #
  171. # Sets inter component dependencies if listed with
  172. # :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables.
  173. #
  174. # * Mandatory : NO
  175. # * Default : -
  176. #
  177. # .. variable:: CPACK_DEBIAN_PACKAGE_MAINTAINER
  178. #
  179. # The Debian package maintainer
  180. #
  181. # * Mandatory : YES
  182. # * Default : :code:`CPACK_PACKAGE_CONTACT`
  183. #
  184. # .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION
  185. # CPACK_COMPONENT_<COMPONENT>_DESCRIPTION
  186. #
  187. # The Debian package description
  188. #
  189. # * Mandatory : YES
  190. # * Default :
  191. #
  192. # - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or
  193. # - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
  194. #
  195. #
  196. # .. variable:: CPACK_DEBIAN_PACKAGE_SECTION
  197. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION
  198. #
  199. # Set Section control field e.g. admin, devel, doc, ...
  200. #
  201. # * Mandatory : YES
  202. # * Default : "devel"
  203. #
  204. # See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
  205. #
  206. # .. variable:: CPACK_DEBIAN_ARCHIVE_TYPE
  207. #
  208. # The archive format used for creating the Debian package.
  209. #
  210. # * Mandatory : YES
  211. # * Default : "paxr"
  212. #
  213. # Possible values are:
  214. #
  215. # - paxr
  216. # - gnutar
  217. #
  218. # .. note::
  219. #
  220. # Default pax archive format is the most portable format and generates
  221. # packages that do not treat sparse files specially.
  222. # GNU tar format on the other hand supports longer filenames.
  223. #
  224. # .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
  225. #
  226. # The compression used for creating the Debian package.
  227. #
  228. # * Mandatory : YES
  229. # * Default : "gzip"
  230. #
  231. # Possible values are:
  232. #
  233. # - lzma
  234. # - xz
  235. # - bzip2
  236. # - gzip
  237. #
  238. # .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
  239. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
  240. #
  241. # Set Priority control field e.g. required, important, standard, optional,
  242. # extra
  243. #
  244. # * Mandatory : YES
  245. # * Default : "optional"
  246. #
  247. # See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
  248. #
  249. # .. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
  250. #
  251. # The URL of the web site for this package, preferably (when applicable) the
  252. # site from which the original source can be obtained and any additional
  253. # upstream documentation or information may be found.
  254. #
  255. # * Mandatory : NO
  256. # * Default : -
  257. #
  258. # .. note::
  259. #
  260. # The content of this field is a simple URL without any surrounding
  261. # characters such as <>.
  262. #
  263. # .. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS
  264. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS
  265. #
  266. # May be set to ON in order to use :code:`dpkg-shlibdeps` to generate
  267. # better package dependency list.
  268. #
  269. # * Mandatory : NO
  270. # * Default :
  271. #
  272. # - :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` if set or
  273. # - OFF
  274. #
  275. # .. note::
  276. #
  277. # You may need set :variable:`CMAKE_INSTALL_RPATH` to an appropriate value
  278. # if you use this feature, because if you don't :code:`dpkg-shlibdeps`
  279. # may fail to find your own shared libs.
  280. # See https://cmake.org/Wiki/CMake_RPATH_handling.
  281. #
  282. # .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
  283. #
  284. # May be set when invoking cpack in order to trace debug information
  285. # during CPackDeb run.
  286. #
  287. # * Mandatory : NO
  288. # * Default : -
  289. #
  290. # .. variable:: CPACK_DEBIAN_PACKAGE_PREDEPENDS
  291. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS
  292. #
  293. # Sets the `Pre-Depends` field of the Debian package.
  294. # Like :variable:`Depends <CPACK_DEBIAN_PACKAGE_DEPENDS>`, except that it
  295. # also forces :code:`dpkg` to complete installation of the packages named
  296. # before even starting the installation of the package which declares the
  297. # pre-dependency.
  298. #
  299. # * Mandatory : NO
  300. # * Default :
  301. #
  302. # - An empty string for non-component based installations
  303. # - :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based
  304. # installations.
  305. #
  306. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  307. #
  308. # .. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES
  309. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES
  310. #
  311. # Sets the `Enhances` field of the Debian package.
  312. # Similar to :variable:`Suggests <CPACK_DEBIAN_PACKAGE_SUGGESTS>` but works
  313. # in the opposite direction: declares that a package can enhance the
  314. # functionality of another package.
  315. #
  316. # * Mandatory : NO
  317. # * Default :
  318. #
  319. # - An empty string for non-component based installations
  320. # - :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based
  321. # installations.
  322. #
  323. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  324. #
  325. # .. variable:: CPACK_DEBIAN_PACKAGE_BREAKS
  326. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS
  327. #
  328. # Sets the `Breaks` field of the Debian package.
  329. # When a binary package (P) declares that it breaks other packages (B),
  330. # :code:`dpkg` will not allow the package (P) which declares `Breaks` be
  331. # **unpacked** unless the packages that will be broken (B) are deconfigured
  332. # first.
  333. # As long as the package (P) is configured, the previously deconfigured
  334. # packages (B) cannot be reconfigured again.
  335. #
  336. # * Mandatory : NO
  337. # * Default :
  338. #
  339. # - An empty string for non-component based installations
  340. # - :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based
  341. # installations.
  342. #
  343. # See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
  344. #
  345. # .. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
  346. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS
  347. #
  348. # Sets the `Conflicts` field of the Debian package.
  349. # When one binary package declares a conflict with another using a `Conflicts`
  350. # field, :code:`dpkg` will not allow them to be unpacked on the system at
  351. # the same time.
  352. #
  353. # * Mandatory : NO
  354. # * Default :
  355. #
  356. # - An empty string for non-component based installations
  357. # - :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based
  358. # installations.
  359. #
  360. # See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
  361. #
  362. # .. note::
  363. #
  364. # This is a stronger restriction than
  365. # :variable:`Breaks <CPACK_DEBIAN_PACKAGE_BREAKS>`, which prevents the
  366. # broken package from being configured while the breaking package is in
  367. # the "Unpacked" state but allows both packages to be unpacked at the same
  368. # time.
  369. #
  370. # .. variable:: CPACK_DEBIAN_PACKAGE_PROVIDES
  371. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES
  372. #
  373. # Sets the `Provides` field of the Debian package.
  374. # A virtual package is one which appears in the `Provides` control field of
  375. # another package.
  376. #
  377. # * Mandatory : NO
  378. # * Default :
  379. #
  380. # - An empty string for non-component based installations
  381. # - :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based
  382. # installations.
  383. #
  384. # See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
  385. #
  386. # .. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
  387. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES
  388. #
  389. # Sets the `Replaces` field of the Debian package.
  390. # Packages can declare in their control file that they should overwrite
  391. # files in certain other packages, or completely replace other packages.
  392. #
  393. # * Mandatory : NO
  394. # * Default :
  395. #
  396. # - An empty string for non-component based installations
  397. # - :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based
  398. # installations.
  399. #
  400. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  401. #
  402. # .. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
  403. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS
  404. #
  405. # Sets the `Recommends` field of the Debian package.
  406. # Allows packages to declare a strong, but not absolute, dependency on other
  407. # packages.
  408. #
  409. # * Mandatory : NO
  410. # * Default :
  411. #
  412. # - An empty string for non-component based installations
  413. # - :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based
  414. # installations.
  415. #
  416. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  417. #
  418. # .. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
  419. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS
  420. #
  421. # Sets the `Suggests` field of the Debian package.
  422. # Allows packages to declare a suggested package install grouping.
  423. #
  424. # * Mandatory : NO
  425. # * Default :
  426. #
  427. # - An empty string for non-component based installations
  428. # - :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based
  429. # installations.
  430. #
  431. # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
  432. #
  433. # .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
  434. #
  435. # * Mandatory : NO
  436. # * Default : OFF
  437. #
  438. # Allows to generate shlibs control file automatically. Compatibility is defined by
  439. # :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value.
  440. #
  441. # .. note::
  442. #
  443. # Libraries are only considered if they have both library name and version
  444. # set. This can be done by setting SOVERSION property with
  445. # :command:`set_target_properties` command.
  446. #
  447. # .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
  448. #
  449. # Compatibility policy for auto-generated shlibs control file.
  450. #
  451. # * Mandatory : NO
  452. # * Default : "="
  453. #
  454. # Defines compatibility policy for auto-generated shlibs control file.
  455. # Possible values: "=", ">="
  456. #
  457. # See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
  458. #
  459. # .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  460. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
  461. #
  462. # This variable allow advanced user to add custom script to the
  463. # control.tar.gz.
  464. # Typical usage is for conffiles, postinst, postrm, prerm.
  465. #
  466. # * Mandatory : NO
  467. # * Default : -
  468. #
  469. # Usage::
  470. #
  471. # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  472. # "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
  473. #
  474. # .. note::
  475. #
  476. # The original permissions of the files will be used in the final
  477. # package unless the variable
  478. # :variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set.
  479. # In particular, the scripts should have the proper executable
  480. # flag prior to the generation of the package.
  481. #
  482. # .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
  483. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION
  484. #
  485. # This variable indicates if the Debian policy on control files should be
  486. # strictly followed.
  487. #
  488. # * Mandatory : NO
  489. # * Default : FALSE
  490. #
  491. # Usage::
  492. #
  493. # set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
  494. #
  495. # .. note::
  496. #
  497. # This overrides the permissions on the original files, following the rules
  498. # set by Debian policy
  499. # https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
  500. #
  501. # .. variable:: CPACK_DEBIAN_PACKAGE_SOURCE
  502. # CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE
  503. #
  504. # Sets the ``Source`` field of the binary Debian package.
  505. # When the binary package name is not the same as the source package name
  506. # (in particular when several components/binaries are generated from one
  507. # source) the source from which the binary has been generated should be
  508. # indicated with the field ``Source``.
  509. #
  510. # * Mandatory : NO
  511. # * Default :
  512. #
  513. # - An empty string for non-component based installations
  514. # - :variable:`CPACK_DEBIAN_PACKAGE_SOURCE` for component-based
  515. # installations.
  516. #
  517. # See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
  518. #
  519. # .. note::
  520. #
  521. # This value is not interpreted. It is possible to pass an optional
  522. # revision number of the referenced source package as well.
  523. #
  524. # Building Debian packages on Windows
  525. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  526. #
  527. # To communicate UNIX file permissions from the install stage
  528. # to the CPack DEB generator the "cmake_mode_t" NTFS
  529. # alternate data stream (ADT) is used.
  530. #
  531. # When a filesystem without ADT support is used only owner read/write
  532. # permissions can be preserved.
  533. # CPack script for creating Debian package
  534. # Author: Mathieu Malaterre
  535. #
  536. # http://wiki.debian.org/HowToPackageForDebian
  537. if(CMAKE_BINARY_DIR)
  538. message(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
  539. endif()
  540. function(cpack_deb_variable_fallback OUTPUT_VAR_NAME)
  541. set(FALLBACK_VAR_NAMES ${ARGN})
  542. foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
  543. if(${variable_name})
  544. set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
  545. break()
  546. endif()
  547. endforeach()
  548. endfunction()
  549. function(get_component_package_name var component)
  550. string(TOUPPER "${component}" component_upcase)
  551. if(CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME)
  552. string(TOLOWER "${CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME}" package_name)
  553. else()
  554. string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${component}" package_name)
  555. endif()
  556. set("${var}" "${package_name}" PARENT_SCOPE)
  557. endfunction()
  558. #extract library name and version for given shared object
  559. function(extract_so_info shared_object libname version)
  560. if(READELF_EXECUTABLE)
  561. execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}"
  562. WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
  563. RESULT_VARIABLE result
  564. OUTPUT_VARIABLE output
  565. ERROR_QUIET
  566. OUTPUT_STRIP_TRAILING_WHITESPACE)
  567. if(result EQUAL 0)
  568. string(REGEX MATCH "\\(SONAME\\)[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
  569. set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE)
  570. set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE)
  571. else()
  572. message(WARNING "Error running readelf for \"${shared_object}\"")
  573. endif()
  574. else()
  575. message(FATAL_ERROR "Readelf utility is not available.")
  576. endif()
  577. endfunction()
  578. function(cpack_deb_prepare_package_vars)
  579. # CPACK_DEBIAN_PACKAGE_SHLIBDEPS
  580. # If specify OFF, only user depends are used
  581. if(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
  582. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
  583. endif()
  584. set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}")
  585. # per component automatic discover: some of the component might not have
  586. # binaries.
  587. if(CPACK_DEB_PACKAGE_COMPONENT)
  588. string(TOUPPER "${CPACK_DEB_PACKAGE_COMPONENT}" _local_component_name)
  589. set(_component_shlibdeps_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_SHLIBDEPS")
  590. # if set, overrides the global configuration
  591. if(DEFINED ${_component_shlibdeps_var})
  592. set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "${${_component_shlibdeps_var}}")
  593. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  594. message("CPackDeb Debug: component '${CPACK_DEB_PACKAGE_COMPONENT}' dpkg-shlibdeps set to ${CPACK_DEBIAN_PACKAGE_SHLIBDEPS}")
  595. endif()
  596. endif()
  597. endif()
  598. if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
  599. # Generating binary list - Get type of all install files
  600. file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
  601. find_program(FILE_EXECUTABLE file)
  602. if(NOT FILE_EXECUTABLE)
  603. message(FATAL_ERROR "CPackDeb: file utility is not available. CPACK_DEBIAN_PACKAGE_SHLIBDEPS and CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS options are not available.")
  604. endif()
  605. # get file info so that we can determine if file is executable or not
  606. unset(CPACK_DEB_INSTALL_FILES)
  607. foreach(FILE_ IN LISTS FILE_PATHS_)
  608. execute_process(COMMAND env LC_ALL=C ${FILE_EXECUTABLE} "./${FILE_}"
  609. WORKING_DIRECTORY "${WDIR}"
  610. RESULT_VARIABLE FILE_RESULT_
  611. OUTPUT_VARIABLE INSTALL_FILE_)
  612. if(NOT FILE_RESULT_ EQUAL 0)
  613. message (FATAL_ERROR "CPackDeb: execution of command: '${FILE_EXECUTABLE} ./${FILE_}' failed with exit code: ${FILE_RESULT_}")
  614. endif()
  615. list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
  616. endforeach()
  617. # Only dynamically linked ELF files are included
  618. # Extract only file name infront of ":"
  619. foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES)
  620. if(_FILE MATCHES "ELF.*dynamically linked")
  621. string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
  622. list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
  623. set(CONTAINS_EXECUTABLE_FILES_ TRUE)
  624. endif()
  625. if(_FILE MATCHES "ELF.*shared object")
  626. string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
  627. list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}")
  628. endif()
  629. endforeach()
  630. endif()
  631. if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
  632. # dpkg-shlibdeps is a Debian utility for generating dependency list
  633. find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
  634. if(SHLIBDEPS_EXECUTABLE)
  635. # Check version of the dpkg-shlibdeps tool using CPackDEB method
  636. execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version
  637. OUTPUT_VARIABLE _TMP_VERSION
  638. ERROR_QUIET
  639. OUTPUT_STRIP_TRAILING_WHITESPACE)
  640. if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)")
  641. set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
  642. else()
  643. set(SHLIBDEPS_EXECUTABLE_VERSION "")
  644. endif()
  645. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  646. message("CPackDeb Debug: dpkg-shlibdeps --version output is '${_TMP_VERSION}'")
  647. message("CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>")
  648. endif()
  649. if(CONTAINS_EXECUTABLE_FILES_)
  650. message("CPackDeb: - Generating dependency list")
  651. # Create blank control file for running dpkg-shlibdeps
  652. # There might be some other way to invoke dpkg-shlibdeps without creating this file
  653. # but standard debian package should not have anything that can collide with this file or directory
  654. file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian)
  655. file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "")
  656. # Create a DEBIAN directory so that dpkg-shlibdeps can find the package dir when resolving $ORIGIN.
  657. file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
  658. # Add --ignore-missing-info if the tool supports it
  659. execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help
  660. OUTPUT_VARIABLE _TMP_HELP
  661. ERROR_QUIET
  662. OUTPUT_STRIP_TRAILING_WHITESPACE)
  663. if(_TMP_HELP MATCHES "--ignore-missing-info")
  664. set(IGNORE_MISSING_INFO_FLAG "--ignore-missing-info")
  665. endif()
  666. # Execute dpkg-shlibdeps
  667. # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package
  668. # -O : print to STDOUT
  669. execute_process(COMMAND ${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}
  670. WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
  671. OUTPUT_VARIABLE SHLIBDEPS_OUTPUT
  672. RESULT_VARIABLE SHLIBDEPS_RESULT
  673. ERROR_VARIABLE SHLIBDEPS_ERROR
  674. OUTPUT_STRIP_TRAILING_WHITESPACE )
  675. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  676. # dpkg-shlibdeps will throw some warnings if some input files are not binary
  677. message( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}")
  678. endif()
  679. if(NOT SHLIBDEPS_RESULT EQUAL 0)
  680. message (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: '${SHLIBDEPS_ERROR}';\n"
  681. "executed command: '${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}';\n"
  682. "found files: '${INSTALL_FILE_}';\n"
  683. "files info: '${CPACK_DEB_INSTALL_FILES}';\n"
  684. "binary files: '${CPACK_DEB_BINARY_FILES}'")
  685. endif()
  686. #Get rid of prefix generated by dpkg-shlibdeps
  687. string(REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS "${SHLIBDEPS_OUTPUT}")
  688. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  689. message("CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS} from output ${SHLIBDEPS_OUTPUT}")
  690. endif()
  691. # Remove blank control file
  692. # Might not be safe if package actual contain file or directory named debian
  693. file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian")
  694. # remove temporary directory that was created only for dpkg-shlibdeps execution
  695. file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
  696. else()
  697. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  698. message(AUTHOR_WARNING "CPackDeb Debug: Using only user-provided depends because package does not contain executable files that link to shared libraries.")
  699. endif()
  700. endif()
  701. else()
  702. message("CPackDeb: Using only user-provided dependencies because dpkg-shlibdeps is not found.")
  703. endif()
  704. else()
  705. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  706. message("CPackDeb Debug: Using only user-provided dependencies")
  707. endif()
  708. endif()
  709. # Let's define the control file found in debian package:
  710. # Binary package:
  711. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
  712. # DEBIAN/control
  713. # debian policy enforce lower case for package name
  714. # Package: (mandatory)
  715. if(NOT CPACK_DEBIAN_PACKAGE_NAME)
  716. string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
  717. endif()
  718. # Version: (mandatory)
  719. if(NOT CPACK_DEBIAN_PACKAGE_VERSION)
  720. if(NOT CPACK_PACKAGE_VERSION)
  721. message(FATAL_ERROR "CPackDeb: Debian package requires a package version")
  722. endif()
  723. set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
  724. endif()
  725. if(DEFINED CPACK_DEBIAN_PACKAGE_RELEASE OR DEFINED CPACK_DEBIAN_PACKAGE_EPOCH)
  726. # only test the version format if CPACK_DEBIAN_PACKAGE_RELEASE or
  727. # CPACK_DEBIAN_PACKAGE_EPOCH is set
  728. if(NOT CPACK_DEBIAN_PACKAGE_VERSION MATCHES "^[0-9][A-Za-z0-9.+~-]*$")
  729. message(FATAL_ERROR
  730. "CPackDeb: Debian package version must confirm to \"^[0-9][A-Za-z0-9.+~-]*$\" regex!")
  731. endif()
  732. else()
  733. # before CMake 3.10 version format was not tested so only warn to preserve
  734. # backward compatibility
  735. if(NOT CPACK_DEBIAN_PACKAGE_VERSION MATCHES "^([0-9]+:)?[0-9][A-Za-z0-9.+~-]*$")
  736. message(AUTHOR_WARNING
  737. "CPackDeb: Debian package versioning ([<epoch>:]<version>[-<release>])"
  738. " should confirm to \"^([0-9]+:)?[0-9][A-Za-z0-9.+~-]*$\" regex in"
  739. " order to satisfy Debian packaging rules.")
  740. endif()
  741. endif()
  742. if(CPACK_DEBIAN_PACKAGE_RELEASE)
  743. if(NOT CPACK_DEBIAN_PACKAGE_RELEASE MATCHES "^[A-Za-z0-9.+~]+$")
  744. message(FATAL_ERROR
  745. "CPackDeb: Debian package release must confirm to \"^[A-Za-z0-9.+~]+$\" regex!")
  746. endif()
  747. string(APPEND CPACK_DEBIAN_PACKAGE_VERSION
  748. "-${CPACK_DEBIAN_PACKAGE_RELEASE}")
  749. elseif(DEFINED CPACK_DEBIAN_PACKAGE_EPOCH)
  750. # only test the version format if CPACK_DEBIAN_PACKAGE_RELEASE or
  751. # CPACK_DEBIAN_PACKAGE_EPOCH is set - versions CPack/Deb generator before
  752. # CMake 3.10 did not check for version format so we have to preserve
  753. # backward compatibility
  754. if(CPACK_DEBIAN_PACKAGE_VERSION MATCHES ".*-.*")
  755. message(FATAL_ERROR
  756. "CPackDeb: Debian package version must not contain hyphens when CPACK_DEBIAN_PACKAGE_RELEASE is not provided!")
  757. endif()
  758. endif()
  759. if(CPACK_DEBIAN_PACKAGE_EPOCH)
  760. if(NOT CPACK_DEBIAN_PACKAGE_EPOCH MATCHES "^[0-9]+$")
  761. message(FATAL_ERROR
  762. "CPackDeb: Debian package epoch must confirm to \"^[0-9]+$\" regex!")
  763. endif()
  764. set(CPACK_DEBIAN_PACKAGE_VERSION
  765. "${CPACK_DEBIAN_PACKAGE_EPOCH}:${CPACK_DEBIAN_PACKAGE_VERSION}")
  766. endif()
  767. # Architecture: (mandatory)
  768. if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE)
  769. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}")
  770. elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
  771. # There is no such thing as i686 architecture on debian, you should use i386 instead
  772. # $ dpkg --print-architecture
  773. find_program(DPKG_CMD dpkg)
  774. if(NOT DPKG_CMD)
  775. message(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.")
  776. set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
  777. endif()
  778. execute_process(COMMAND "${DPKG_CMD}" --print-architecture
  779. OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
  780. OUTPUT_STRIP_TRAILING_WHITESPACE
  781. )
  782. endif()
  783. # Source: (optional)
  784. # in case several packages are constructed from a unique source
  785. # (multipackaging), the source may be indicated as well.
  786. # The source might contain a version if the generated package
  787. # version is different from the source version
  788. if(NOT CPACK_DEBIAN_PACKAGE_SOURCE)
  789. set(CPACK_DEBIAN_PACKAGE_SOURCE "")
  790. endif()
  791. # have a look at get_property(result GLOBAL PROPERTY ENABLED_FEATURES),
  792. # this returns the successful find_package() calls, maybe this can help
  793. # Depends:
  794. # You should set: DEBIAN_PACKAGE_DEPENDS
  795. # TODO: automate 'objdump -p | grep NEEDED'
  796. # if per-component variable, overrides the global CPACK_DEBIAN_PACKAGE_${variable_type_}
  797. # automatic dependency discovery will be performed afterwards.
  798. if(CPACK_DEB_PACKAGE_COMPONENT)
  799. foreach(value_type_ DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME)
  800. set(_component_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_${value_type_}")
  801. # if set, overrides the global variable
  802. if(DEFINED ${_component_var})
  803. set(CPACK_DEBIAN_PACKAGE_${value_type_} "${${_component_var}}")
  804. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  805. message("CPackDeb Debug: component '${_local_component_name}' ${value_type_} "
  806. "value set to '${CPACK_DEBIAN_PACKAGE_${value_type_}}'")
  807. endif()
  808. endif()
  809. endforeach()
  810. if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS)
  811. set(COMPONENT_DEPENDS "")
  812. foreach (_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS})
  813. get_component_package_name(_PACK_NAME "${_PACK}")
  814. if(COMPONENT_DEPENDS)
  815. set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}")
  816. else()
  817. set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
  818. endif()
  819. endforeach()
  820. if(COMPONENT_DEPENDS)
  821. if(CPACK_DEBIAN_PACKAGE_DEPENDS)
  822. set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
  823. else()
  824. set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}")
  825. endif()
  826. endif()
  827. endif()
  828. endif()
  829. # at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set
  830. # to the minimal dependency of the package
  831. # Append automatically discovered dependencies .
  832. if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "")
  833. if (CPACK_DEBIAN_PACKAGE_DEPENDS)
  834. set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
  835. else ()
  836. set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
  837. endif ()
  838. endif()
  839. if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
  840. message(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
  841. endif()
  842. # Maintainer: (mandatory)
  843. if(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
  844. if(NOT CPACK_PACKAGE_CONTACT)
  845. message(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
  846. endif()
  847. set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
  848. endif()
  849. # Description: (mandatory)
  850. if(NOT CPACK_DEB_PACKAGE_COMPONENT)
  851. if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
  852. if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
  853. message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
  854. endif()
  855. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  856. endif()
  857. else()
  858. set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION)
  859. # component description overrides package description
  860. if(${component_description_var})
  861. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${${component_description_var}})
  862. elseif(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
  863. if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
  864. message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION or ${component_description_var}")
  865. endif()
  866. set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
  867. endif()
  868. endif()
  869. # Section: (recommended)
  870. if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
  871. set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
  872. endif()
  873. # Priority: (recommended)
  874. if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
  875. set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
  876. endif()
  877. if(CPACK_DEBIAN_ARCHIVE_TYPE)
  878. set(archive_types_ "paxr;gnutar")
  879. if(NOT CPACK_DEBIAN_ARCHIVE_TYPE IN_LIST archive_types_)
  880. message(FATAL_ERROR "CPACK_DEBIAN_ARCHIVE_TYPE set to unsupported"
  881. "type ${CPACK_DEBIAN_ARCHIVE_TYPE}")
  882. endif()
  883. else()
  884. set(CPACK_DEBIAN_ARCHIVE_TYPE "paxr")
  885. endif()
  886. # Compression: (recommended)
  887. if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
  888. set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
  889. endif()
  890. # Recommends:
  891. # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
  892. # Suggests:
  893. # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
  894. # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  895. # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
  896. # Typical examples are:
  897. # - conffiles
  898. # - postinst
  899. # - postrm
  900. # - prerm
  901. # Usage:
  902. # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  903. # "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
  904. # Are we packaging components ?
  905. if(CPACK_DEB_PACKAGE_COMPONENT)
  906. # override values with per component version if set
  907. foreach(VAR_NAME_ "PACKAGE_CONTROL_EXTRA" "PACKAGE_CONTROL_STRICT_PERMISSION")
  908. if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_})
  909. set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
  910. endif()
  911. endforeach()
  912. get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
  913. endif()
  914. set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
  915. if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
  916. set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
  917. endif()
  918. find_program(READELF_EXECUTABLE NAMES readelf)
  919. if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
  920. if(READELF_EXECUTABLE)
  921. foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
  922. extract_so_info("${_FILE}" libname soversion)
  923. if(libname AND DEFINED soversion)
  924. list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST
  925. "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_DEBIAN_PACKAGE_VERSION})")
  926. else()
  927. message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
  928. endif()
  929. endforeach()
  930. if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
  931. string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}")
  932. endif()
  933. else()
  934. message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
  935. endif()
  936. endif()
  937. # add ldconfig call in default postrm and postint
  938. set(CPACK_ADD_LDCONFIG_CALL 0)
  939. foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
  940. get_filename_component(_DIR ${_FILE} DIRECTORY)
  941. # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
  942. if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
  943. set(CPACK_ADD_LDCONFIG_CALL 1)
  944. endif()
  945. endforeach()
  946. if(CPACK_ADD_LDCONFIG_CALL)
  947. set(CPACK_DEBIAN_GENERATE_POSTINST 1)
  948. set(CPACK_DEBIAN_GENERATE_POSTRM 1)
  949. foreach(f ${PACKAGE_CONTROL_EXTRA})
  950. get_filename_component(n "${f}" NAME)
  951. if("${n}" STREQUAL "postinst")
  952. set(CPACK_DEBIAN_GENERATE_POSTINST 0)
  953. endif()
  954. if("${n}" STREQUAL "postrm")
  955. set(CPACK_DEBIAN_GENERATE_POSTRM 0)
  956. endif()
  957. endforeach()
  958. else()
  959. set(CPACK_DEBIAN_GENERATE_POSTINST 0)
  960. set(CPACK_DEBIAN_GENERATE_POSTRM 0)
  961. endif()
  962. cpack_deb_variable_fallback("CPACK_DEBIAN_FILE_NAME"
  963. "CPACK_DEBIAN_${_local_component_name}_FILE_NAME"
  964. "CPACK_DEBIAN_FILE_NAME")
  965. if(CPACK_DEBIAN_FILE_NAME)
  966. if(CPACK_DEBIAN_FILE_NAME STREQUAL "DEB-DEFAULT")
  967. # Patch package file name to be in corrent debian format:
  968. # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
  969. set(CPACK_OUTPUT_FILE_NAME
  970. "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
  971. else()
  972. if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.(deb|ipk)")
  973. message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb' or '.ipk'!")
  974. endif()
  975. set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")
  976. endif()
  977. set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
  978. get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
  979. set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
  980. endif() # else() back compatibility - don't change the name
  981. # Print out some debug information if we were asked for that
  982. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  983. message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")
  984. message("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = '${CPACK_TOPLEVEL_TAG}'")
  985. message("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = '${CPACK_TEMPORARY_DIRECTORY}'")
  986. message("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = '${CPACK_OUTPUT_FILE_NAME}'")
  987. message("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = '${CPACK_OUTPUT_FILE_PATH}'")
  988. message("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = '${CPACK_PACKAGE_FILE_NAME}'")
  989. message("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = '${CPACK_PACKAGE_INSTALL_DIRECTORY}'")
  990. message("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = '${CPACK_TEMPORARY_PACKAGE_FILE_NAME}'")
  991. message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION = '${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}'")
  992. message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_SOURCE = '${CPACK_DEBIAN_PACKAGE_SOURCE}'")
  993. endif()
  994. # For debian source packages:
  995. # debian/control
  996. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
  997. # .dsc
  998. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
  999. # Builds-Depends:
  1000. #if(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
  1001. # set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
  1002. # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
  1003. # )
  1004. #endif()
  1005. # move variables to parent scope so that they may be used to create debian package
  1006. set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE)
  1007. set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE)
  1008. set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
  1009. set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE)
  1010. set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE)
  1011. set(GEN_CPACK_DEBIAN_PACKAGE_PRIORITY "${CPACK_DEBIAN_PACKAGE_PRIORITY}" PARENT_SCOPE)
  1012. set(GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" PARENT_SCOPE)
  1013. set(GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_DEBIAN_PACKAGE_MAINTAINER}" PARENT_SCOPE)
  1014. set(GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}" PARENT_SCOPE)
  1015. set(GEN_CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
  1016. set(GEN_CPACK_DEBIAN_ARCHIVE_TYPE "${CPACK_DEBIAN_ARCHIVE_TYPE}" PARENT_SCOPE)
  1017. set(GEN_CPACK_DEBIAN_COMPRESSION_TYPE "${CPACK_DEBIAN_COMPRESSION_TYPE}" PARENT_SCOPE)
  1018. set(GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS "${CPACK_DEBIAN_PACKAGE_RECOMMENDS}" PARENT_SCOPE)
  1019. set(GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}" PARENT_SCOPE)
  1020. set(GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_DEBIAN_PACKAGE_HOMEPAGE}" PARENT_SCOPE)
  1021. set(GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS "${CPACK_DEBIAN_PACKAGE_PREDEPENDS}" PARENT_SCOPE)
  1022. set(GEN_CPACK_DEBIAN_PACKAGE_ENHANCES "${CPACK_DEBIAN_PACKAGE_ENHANCES}" PARENT_SCOPE)
  1023. set(GEN_CPACK_DEBIAN_PACKAGE_BREAKS "${CPACK_DEBIAN_PACKAGE_BREAKS}" PARENT_SCOPE)
  1024. set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
  1025. set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE)
  1026. set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE)
  1027. set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE)
  1028. set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE)
  1029. set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
  1030. "${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
  1031. set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
  1032. "${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
  1033. set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
  1034. set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
  1035. set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
  1036. endfunction()
  1037. cpack_deb_prepare_package_vars()