CPackDeb.cmake 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  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 : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
  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. # Homepage: (optional)
  870. if(NOT CPACK_DEBIAN_PACKAGE_HOMEPAGE AND CMAKE_PROJECT_HOMEPAGE_URL)
  871. set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CMAKE_PROJECT_HOMEPAGE_URL}")
  872. endif()
  873. # Section: (recommended)
  874. if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
  875. set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
  876. endif()
  877. # Priority: (recommended)
  878. if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
  879. set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
  880. endif()
  881. if(CPACK_DEBIAN_ARCHIVE_TYPE)
  882. set(archive_types_ "paxr;gnutar")
  883. if(NOT CPACK_DEBIAN_ARCHIVE_TYPE IN_LIST archive_types_)
  884. message(FATAL_ERROR "CPACK_DEBIAN_ARCHIVE_TYPE set to unsupported"
  885. "type ${CPACK_DEBIAN_ARCHIVE_TYPE}")
  886. endif()
  887. else()
  888. set(CPACK_DEBIAN_ARCHIVE_TYPE "paxr")
  889. endif()
  890. # Compression: (recommended)
  891. if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
  892. set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
  893. endif()
  894. # Recommends:
  895. # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
  896. # Suggests:
  897. # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
  898. # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  899. # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
  900. # Typical examples are:
  901. # - conffiles
  902. # - postinst
  903. # - postrm
  904. # - prerm
  905. # Usage:
  906. # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
  907. # "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
  908. # Are we packaging components ?
  909. if(CPACK_DEB_PACKAGE_COMPONENT)
  910. # override values with per component version if set
  911. foreach(VAR_NAME_ "PACKAGE_CONTROL_EXTRA" "PACKAGE_CONTROL_STRICT_PERMISSION")
  912. if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_})
  913. set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
  914. endif()
  915. endforeach()
  916. get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
  917. endif()
  918. set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
  919. if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
  920. set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
  921. endif()
  922. find_program(READELF_EXECUTABLE NAMES readelf)
  923. if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
  924. if(READELF_EXECUTABLE)
  925. foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
  926. extract_so_info("${_FILE}" libname soversion)
  927. if(libname AND DEFINED soversion)
  928. list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST
  929. "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_DEBIAN_PACKAGE_VERSION})")
  930. else()
  931. message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
  932. endif()
  933. endforeach()
  934. if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
  935. string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}")
  936. endif()
  937. else()
  938. message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
  939. endif()
  940. endif()
  941. # add ldconfig call in default postrm and postint
  942. set(CPACK_ADD_LDCONFIG_CALL 0)
  943. foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
  944. get_filename_component(_DIR ${_FILE} DIRECTORY)
  945. # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
  946. if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
  947. set(CPACK_ADD_LDCONFIG_CALL 1)
  948. endif()
  949. endforeach()
  950. if(CPACK_ADD_LDCONFIG_CALL)
  951. set(CPACK_DEBIAN_GENERATE_POSTINST 1)
  952. set(CPACK_DEBIAN_GENERATE_POSTRM 1)
  953. foreach(f ${PACKAGE_CONTROL_EXTRA})
  954. get_filename_component(n "${f}" NAME)
  955. if("${n}" STREQUAL "postinst")
  956. set(CPACK_DEBIAN_GENERATE_POSTINST 0)
  957. endif()
  958. if("${n}" STREQUAL "postrm")
  959. set(CPACK_DEBIAN_GENERATE_POSTRM 0)
  960. endif()
  961. endforeach()
  962. else()
  963. set(CPACK_DEBIAN_GENERATE_POSTINST 0)
  964. set(CPACK_DEBIAN_GENERATE_POSTRM 0)
  965. endif()
  966. cpack_deb_variable_fallback("CPACK_DEBIAN_FILE_NAME"
  967. "CPACK_DEBIAN_${_local_component_name}_FILE_NAME"
  968. "CPACK_DEBIAN_FILE_NAME")
  969. if(CPACK_DEBIAN_FILE_NAME)
  970. if(CPACK_DEBIAN_FILE_NAME STREQUAL "DEB-DEFAULT")
  971. # Patch package file name to be in corrent debian format:
  972. # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
  973. set(CPACK_OUTPUT_FILE_NAME
  974. "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
  975. else()
  976. if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.(deb|ipk)")
  977. message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb' or '.ipk'!")
  978. endif()
  979. set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")
  980. endif()
  981. set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
  982. get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
  983. set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
  984. endif() # else() back compatibility - don't change the name
  985. # Print out some debug information if we were asked for that
  986. if(CPACK_DEBIAN_PACKAGE_DEBUG)
  987. message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")
  988. message("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = '${CPACK_TOPLEVEL_TAG}'")
  989. message("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = '${CPACK_TEMPORARY_DIRECTORY}'")
  990. message("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = '${CPACK_OUTPUT_FILE_NAME}'")
  991. message("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = '${CPACK_OUTPUT_FILE_PATH}'")
  992. message("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = '${CPACK_PACKAGE_FILE_NAME}'")
  993. message("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = '${CPACK_PACKAGE_INSTALL_DIRECTORY}'")
  994. message("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = '${CPACK_TEMPORARY_PACKAGE_FILE_NAME}'")
  995. message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION = '${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}'")
  996. message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_SOURCE = '${CPACK_DEBIAN_PACKAGE_SOURCE}'")
  997. endif()
  998. # For debian source packages:
  999. # debian/control
  1000. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
  1001. # .dsc
  1002. # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
  1003. # Builds-Depends:
  1004. #if(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
  1005. # set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
  1006. # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
  1007. # )
  1008. #endif()
  1009. # move variables to parent scope so that they may be used to create debian package
  1010. set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE)
  1011. set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE)
  1012. set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
  1013. set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE)
  1014. set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE)
  1015. set(GEN_CPACK_DEBIAN_PACKAGE_PRIORITY "${CPACK_DEBIAN_PACKAGE_PRIORITY}" PARENT_SCOPE)
  1016. set(GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" PARENT_SCOPE)
  1017. set(GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_DEBIAN_PACKAGE_MAINTAINER}" PARENT_SCOPE)
  1018. set(GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}" PARENT_SCOPE)
  1019. set(GEN_CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
  1020. set(GEN_CPACK_DEBIAN_ARCHIVE_TYPE "${CPACK_DEBIAN_ARCHIVE_TYPE}" PARENT_SCOPE)
  1021. set(GEN_CPACK_DEBIAN_COMPRESSION_TYPE "${CPACK_DEBIAN_COMPRESSION_TYPE}" PARENT_SCOPE)
  1022. set(GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS "${CPACK_DEBIAN_PACKAGE_RECOMMENDS}" PARENT_SCOPE)
  1023. set(GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}" PARENT_SCOPE)
  1024. set(GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_DEBIAN_PACKAGE_HOMEPAGE}" PARENT_SCOPE)
  1025. set(GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS "${CPACK_DEBIAN_PACKAGE_PREDEPENDS}" PARENT_SCOPE)
  1026. set(GEN_CPACK_DEBIAN_PACKAGE_ENHANCES "${CPACK_DEBIAN_PACKAGE_ENHANCES}" PARENT_SCOPE)
  1027. set(GEN_CPACK_DEBIAN_PACKAGE_BREAKS "${CPACK_DEBIAN_PACKAGE_BREAKS}" PARENT_SCOPE)
  1028. set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
  1029. set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE)
  1030. set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE)
  1031. set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE)
  1032. set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE)
  1033. set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
  1034. "${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
  1035. set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
  1036. "${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
  1037. set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
  1038. set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
  1039. set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
  1040. endfunction()
  1041. cpack_deb_prepare_package_vars()