CPackDeb.cmake 36 KB

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