CPackIFW.cmake 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856
  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. # CPackIFW
  5. # --------
  6. #
  7. # .. _QtIFW: http://doc.qt.io/qtinstallerframework/index.html
  8. #
  9. # This module looks for the location of the command line utilities supplied
  10. # with the Qt Installer Framework (QtIFW_).
  11. #
  12. # The module also defines several commands to control the behavior of the
  13. # CPack ``IFW`` generator.
  14. #
  15. #
  16. # Overview
  17. # ^^^^^^^^
  18. #
  19. # CPack ``IFW`` generator helps you to create online and offline
  20. # binary cross-platform installers with a graphical user interface.
  21. #
  22. # CPack IFW generator prepares project installation and generates configuration
  23. # and meta information for QtIFW_ tools.
  24. #
  25. # The QtIFW_ provides a set of tools and utilities to create
  26. # installers for the supported desktop Qt platforms: Linux, Microsoft Windows,
  27. # and Mac OS X.
  28. #
  29. # You should also install QtIFW_ to use CPack ``IFW`` generator.
  30. # If you don't use a default path for the installation, please set
  31. # the used path in the variable ``QTIFWDIR``.
  32. #
  33. # Variables
  34. # ^^^^^^^^^
  35. #
  36. # You can use the following variables to change behavior of CPack ``IFW``
  37. # generator.
  38. #
  39. # Debug
  40. # """"""
  41. #
  42. # .. variable:: CPACK_IFW_VERBOSE
  43. #
  44. # Set to ``ON`` to enable addition debug output.
  45. # By default is ``OFF``.
  46. #
  47. # Package
  48. # """""""
  49. #
  50. # .. variable:: CPACK_IFW_PACKAGE_TITLE
  51. #
  52. # Name of the installer as displayed on the title bar.
  53. # By default used :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`.
  54. #
  55. # .. variable:: CPACK_IFW_PACKAGE_PUBLISHER
  56. #
  57. # Publisher of the software (as shown in the Windows Control Panel).
  58. # By default used :variable:`CPACK_PACKAGE_VENDOR`.
  59. #
  60. # .. variable:: CPACK_IFW_PRODUCT_URL
  61. #
  62. # URL to a page that contains product information on your web site.
  63. #
  64. # .. variable:: CPACK_IFW_PACKAGE_ICON
  65. #
  66. # Filename for a custom installer icon. The actual file is '.icns' (Mac OS X),
  67. # '.ico' (Windows). No functionality on Unix.
  68. #
  69. # .. variable:: CPACK_IFW_PACKAGE_WINDOW_ICON
  70. #
  71. # Filename for a custom window icon in PNG format for the Installer
  72. # application.
  73. #
  74. # .. variable:: CPACK_IFW_PACKAGE_LOGO
  75. #
  76. # Filename for a logo is used as QWizard::LogoPixmap.
  77. #
  78. # .. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY
  79. #
  80. # Name of the default program group for the product in the Windows Start menu.
  81. #
  82. # By default used :variable:`CPACK_IFW_PACKAGE_NAME`.
  83. #
  84. # .. variable:: CPACK_IFW_TARGET_DIRECTORY
  85. #
  86. # Default target directory for installation.
  87. # By default used
  88. # "@ApplicationsDir@/:variable:`CPACK_PACKAGE_INSTALL_DIRECTORY`"
  89. #
  90. # You can use predefined variables.
  91. #
  92. # .. variable:: CPACK_IFW_ADMIN_TARGET_DIRECTORY
  93. #
  94. # Default target directory for installation with administrator rights.
  95. #
  96. # You can use predefined variables.
  97. #
  98. # .. variable:: CPACK_IFW_PACKAGE_GROUP
  99. #
  100. # The group, which will be used to configure the root package
  101. #
  102. # .. variable:: CPACK_IFW_PACKAGE_NAME
  103. #
  104. # The root package name, which will be used if configuration group is not
  105. # specified
  106. #
  107. # .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME
  108. #
  109. # Filename of the generated maintenance tool.
  110. # The platform-specific executable file extension is appended.
  111. #
  112. # By default used QtIFW_ defaults (``maintenancetool``).
  113. #
  114. # .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE
  115. #
  116. # Filename for the configuration of the generated maintenance tool.
  117. #
  118. # By default used QtIFW_ defaults (``maintenancetool.ini``).
  119. #
  120. # .. variable:: CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS
  121. #
  122. # Set to ``ON`` if the installation path can contain non-ASCII characters.
  123. #
  124. # Is ``ON`` for QtIFW_ less 2.0 tools.
  125. #
  126. # .. variable:: CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH
  127. #
  128. # Set to ``OFF`` if the installation path cannot contain space characters.
  129. #
  130. # Is ``ON`` for QtIFW_ less 2.0 tools.
  131. #
  132. # .. variable:: CPACK_IFW_PACKAGE_CONTROL_SCRIPT
  133. #
  134. # Filename for a custom installer control script.
  135. #
  136. # .. variable:: CPACK_IFW_PACKAGE_RESOURCES
  137. #
  138. # List of additional resources ('.qrc' files) to include in the installer
  139. # binary.
  140. #
  141. # You can use :command:`cpack_ifw_add_package_resources` command to resolve
  142. # relative paths.
  143. #
  144. # .. variable:: CPACK_IFW_REPOSITORIES_ALL
  145. #
  146. # The list of remote repositories.
  147. #
  148. # The default value of this variable is computed by CPack and contains
  149. # all repositories added with command :command:`cpack_ifw_add_repository`
  150. # or updated with command :command:`cpack_ifw_update_repository`.
  151. #
  152. # .. variable:: CPACK_IFW_DOWNLOAD_ALL
  153. #
  154. # If this is ``ON`` all components will be downloaded.
  155. # By default is ``OFF`` or used value
  156. # from ``CPACK_DOWNLOAD_ALL`` if set
  157. #
  158. # Components
  159. # """"""""""
  160. #
  161. # .. variable:: CPACK_IFW_RESOLVE_DUPLICATE_NAMES
  162. #
  163. # Resolve duplicate names when installing components with groups.
  164. #
  165. # .. variable:: CPACK_IFW_PACKAGES_DIRECTORIES
  166. #
  167. # Additional prepared packages dirs that will be used to resolve
  168. # dependent components.
  169. #
  170. # Tools
  171. # """"""""
  172. #
  173. # .. variable:: CPACK_IFW_FRAMEWORK_VERSION
  174. #
  175. # The version of used QtIFW_ tools.
  176. #
  177. # .. variable:: CPACK_IFW_BINARYCREATOR_EXECUTABLE
  178. #
  179. # The path to "binarycreator" command line client.
  180. #
  181. # This variable is cached and can be configured user if need.
  182. #
  183. # .. variable:: CPACK_IFW_REPOGEN_EXECUTABLE
  184. #
  185. # The path to "repogen" command line client.
  186. #
  187. # This variable is cached and can be configured user if need.
  188. #
  189. # Commands
  190. # ^^^^^^^^^
  191. #
  192. # The module defines the following commands:
  193. #
  194. # .. command:: cpack_ifw_configure_component
  195. #
  196. # Sets the arguments specific to the CPack IFW generator.
  197. #
  198. # ::
  199. #
  200. # cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL]
  201. # [FORCED_INSTALLATION]
  202. # [NAME <name>]
  203. # [DISPLAY_NAME <display_name>]
  204. # [DESCRIPTION <description>]
  205. # [VERSION <version>]
  206. # [RELEASE_DATE <release_date>]
  207. # [SCRIPT <script>]
  208. # [PRIORITY <priority>]
  209. # [DEPENDS <com_id> ...]
  210. # [LICENSES <display_name> <file_path> ...]
  211. # [DEFAULT <value>]
  212. # [USER_INTERFACES <file_path> <file_path> ...])
  213. #
  214. # This command should be called after :command:`cpack_add_component` command.
  215. #
  216. # ``COMMON``
  217. # if set, then the component will be packaged and installed as part
  218. # of a group to which it belongs.
  219. #
  220. # ``ESSENTIAL``
  221. # if set, then the package manager stays disabled until that
  222. # component is updated.
  223. #
  224. # ``VIRTUAL``
  225. # if set, then the component will be hidden from the installer.
  226. # It is a equivalent of the ``HIDDEN`` option from the
  227. # :command:`cpack_add_component` command.
  228. #
  229. # ``FORCED_INSTALLATION``
  230. # if set, then the component must always be installed.
  231. # It is a equivalent of the ``REQUARED`` option from the
  232. # :command:`cpack_add_component` command.
  233. #
  234. # ``NAME``
  235. # is used to create domain-like identification for this component.
  236. # By default used origin component name.
  237. #
  238. # ``DISPLAY_NAME``
  239. # set to rewrite original name configured by
  240. # :command:`cpack_add_component` command.
  241. #
  242. # ``DESCRIPTION``
  243. # set to rewrite original description configured by
  244. # :command:`cpack_add_component` command.
  245. #
  246. # ``VERSION``
  247. # is version of component.
  248. # By default used :variable:`CPACK_PACKAGE_VERSION`.
  249. #
  250. # ``RELEASE_DATE``
  251. # keep empty to auto generate.
  252. #
  253. # ``SCRIPT``
  254. # is a relative or absolute path to operations script
  255. # for this component.
  256. #
  257. # ``PRIORITY``
  258. # is priority of the component in the tree.
  259. #
  260. # ``DEPENDS``
  261. # list of dependency component identifiers in QtIFW_ style.
  262. #
  263. # ``LICENSES``
  264. # pair of <display_name> and <file_path> of license text for this
  265. # component. You can specify more then one license.
  266. #
  267. # ``DEFAULT``
  268. # Possible values are: TRUE, FALSE, and SCRIPT.
  269. # Set to FALSE to disable the component in the installer or to SCRIPT
  270. # to resolved during runtime (don't forget add the file of the script
  271. # as a value of the ``SCRIPT`` option).
  272. #
  273. # ``USER_INTERFACES``
  274. # a list of <file_path> representing pages to load
  275. #
  276. #
  277. # .. command:: cpack_ifw_configure_component_group
  278. #
  279. # Sets the arguments specific to the CPack IFW generator.
  280. #
  281. # ::
  282. #
  283. # cpack_ifw_configure_component_group(<groupname> [VIRTUAL]
  284. # [FORCED_INSTALLATION]
  285. # [NAME <name>]
  286. # [DISPLAY_NAME <display_name>]
  287. # [DESCRIPTION <description>]
  288. # [VERSION <version>]
  289. # [RELEASE_DATE <release_date>]
  290. # [SCRIPT <script>]
  291. # [PRIORITY <priority>]
  292. # [LICENSES <display_name> <file_path> ...]
  293. # [DEFAULT <value>]
  294. # [USER_INTERFACES <file_path> <file_path> ...])
  295. #
  296. # This command should be called after :command:`cpack_add_component_group`
  297. # command.
  298. #
  299. # ``VIRTUAL``
  300. # if set, then the group will be hidden from the installer.
  301. # Note that setting this on a root component does not work.
  302. #
  303. # ``FORCED_INSTALLATION``
  304. # if set, then the group must always be installed.
  305. #
  306. # ``NAME``
  307. # is used to create domain-like identification for this component group.
  308. # By default used origin component group name.
  309. #
  310. # ``DISPLAY_NAME``
  311. # set to rewrite original name configured by
  312. # :command:`cpack_add_component_group` command.
  313. #
  314. # ``DESCRIPTION``
  315. # set to rewrite original description configured by
  316. # :command:`cpack_add_component_group` command.
  317. #
  318. # ``VERSION``
  319. # is version of component group.
  320. # By default used :variable:`CPACK_PACKAGE_VERSION`.
  321. #
  322. # ``RELEASE_DATE``
  323. # keep empty to auto generate.
  324. #
  325. # ``SCRIPT``
  326. # is a relative or absolute path to operations script
  327. # for this component group.
  328. #
  329. # ``PRIORITY``
  330. # is priority of the component group in the tree.
  331. #
  332. # ``LICENSES``
  333. # pair of <display_name> and <file_path> of license text for this
  334. # component group. You can specify more then one license.
  335. #
  336. # ``DEFAULT``
  337. # Possible values are: TRUE, FALSE, and SCRIPT.
  338. # Set to TRUE to preselect the group in the installer
  339. # (this takes effect only on groups that have no visible child components)
  340. # or to SCRIPT to resolved during runtime (don't forget add the file of
  341. # the script as a value of the ``SCRIPT`` option).
  342. #
  343. # ``USER_INTERFACES``
  344. # a list of <file_path> representing pages to load
  345. #
  346. #
  347. # .. command:: cpack_ifw_add_repository
  348. #
  349. # Add QtIFW_ specific remote repository to binary installer.
  350. #
  351. # ::
  352. #
  353. # cpack_ifw_add_repository(<reponame> [DISABLED]
  354. # URL <url>
  355. # [USERNAME <username>]
  356. # [PASSWORD <password>]
  357. # [DISPLAY_NAME <display_name>])
  358. #
  359. # This command will also add the <reponame> repository
  360. # to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
  361. #
  362. # ``DISABLED``
  363. # if set, then the repository will be disabled by default.
  364. #
  365. # ``URL``
  366. # is points to a list of available components.
  367. #
  368. # ``USERNAME``
  369. # is used as user on a protected repository.
  370. #
  371. # ``PASSWORD``
  372. # is password to use on a protected repository.
  373. #
  374. # ``DISPLAY_NAME``
  375. # is string to display instead of the URL.
  376. #
  377. #
  378. # .. command:: cpack_ifw_update_repository
  379. #
  380. # Update QtIFW_ specific repository from remote repository.
  381. #
  382. # ::
  383. #
  384. # cpack_ifw_update_repository(<reponame>
  385. # [[ADD|REMOVE] URL <url>]|
  386. # [REPLACE OLD_URL <old_url> NEW_URL <new_url>]]
  387. # [USERNAME <username>]
  388. # [PASSWORD <password>]
  389. # [DISPLAY_NAME <display_name>])
  390. #
  391. # This command will also add the <reponame> repository
  392. # to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
  393. #
  394. # ``URL``
  395. # is points to a list of available components.
  396. #
  397. # ``OLD_URL``
  398. # is points to a list that will replaced.
  399. #
  400. # ``NEW_URL``
  401. # is points to a list that will replace to.
  402. #
  403. # ``USERNAME``
  404. # is used as user on a protected repository.
  405. #
  406. # ``PASSWORD``
  407. # is password to use on a protected repository.
  408. #
  409. # ``DISPLAY_NAME``
  410. # is string to display instead of the URL.
  411. #
  412. #
  413. # .. command:: cpack_ifw_add_package_resources
  414. #
  415. # Add additional resources in the installer binary.
  416. #
  417. # ::
  418. #
  419. # cpack_ifw_add_package_resources(<file_path> <file_path> ...)
  420. #
  421. # This command will also add the specified files
  422. # to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`.
  423. #
  424. #
  425. # Example usage
  426. # ^^^^^^^^^^^^^
  427. #
  428. # .. code-block:: cmake
  429. #
  430. # set(CPACK_PACKAGE_NAME "MyPackage")
  431. # set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyPackage Installation Example")
  432. # set(CPACK_PACKAGE_VERSION "1.0.0") # Version of installer
  433. #
  434. # include(CPack)
  435. # include(CPackIFW)
  436. #
  437. # cpack_add_component(myapp
  438. # DISPLAY_NAME "MyApp"
  439. # DESCRIPTION "My Application")
  440. # cpack_ifw_configure_component(myapp
  441. # VERSION "1.2.3" # Version of component
  442. # SCRIPT "operations.qs")
  443. # cpack_add_component(mybigplugin
  444. # DISPLAY_NAME "MyBigPlugin"
  445. # DESCRIPTION "My Big Downloadable Plugin"
  446. # DOWNLOADED)
  447. # cpack_ifw_add_repository(myrepo
  448. # URL "http://example.com/ifw/repo/myapp"
  449. # DISPLAY_NAME "My Application Repository")
  450. #
  451. #
  452. # Online installer
  453. # ^^^^^^^^^^^^^^^^
  454. #
  455. # By default CPack IFW generator makes offline installer. This means that all
  456. # components will be packaged into a binary file.
  457. #
  458. # To make a component downloaded, you must set the ``DOWNLOADED`` option in
  459. # :command:`cpack_add_component`.
  460. #
  461. # Then you would use the command :command:`cpack_configure_downloads`.
  462. # If you set ``ALL`` option all components will be downloaded.
  463. #
  464. # You also can use command :command:`cpack_ifw_add_repository` and
  465. # variable :variable:`CPACK_IFW_DOWNLOAD_ALL` for more specific configuration.
  466. #
  467. # CPack IFW generator creates "repository" dir in current binary dir. You
  468. # would copy content of this dir to specified ``site`` (``url``).
  469. #
  470. # See Also
  471. # ^^^^^^^^
  472. #
  473. # Qt Installer Framework Manual:
  474. #
  475. # * Index page:
  476. # http://doc.qt.io/qtinstallerframework/index.html
  477. #
  478. # * Component Scripting:
  479. # http://doc.qt.io/qtinstallerframework/scripting.html
  480. #
  481. # * Predefined Variables:
  482. # http://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables
  483. #
  484. # * Promoting Updates:
  485. # http://doc.qt.io/qtinstallerframework/ifw-updates.html
  486. #
  487. # Download Qt Installer Framework for you platform from Qt site:
  488. # http://download.qt.io/official_releases/qt-installer-framework
  489. #
  490. #=============================================================================
  491. # Search Qt Installer Framework tools
  492. #=============================================================================
  493. # Default path
  494. foreach(_CPACK_IFW_PATH_VAR "QTIFWDIR" "QTDIR")
  495. if(DEFINED ${_CPACK_IFW_PATH_VAR}
  496. AND NOT "${${_CPACK_IFW_PATH_VAR}}" STREQUAL "")
  497. list(APPEND _CPACK_IFW_PATHS "${${_CPACK_IFW_PATH_VAR}}")
  498. endif()
  499. if(NOT "$ENV{${_CPACK_IFW_PATH_VAR}}" STREQUAL "")
  500. list(APPEND _CPACK_IFW_PATHS "$ENV{${_CPACK_IFW_PATH_VAR}}")
  501. endif()
  502. endforeach()
  503. if(WIN32)
  504. list(APPEND _CPACK_IFW_PATHS
  505. "$ENV{HOMEDRIVE}/Qt"
  506. "C:/Qt")
  507. else()
  508. list(APPEND _CPACK_IFW_PATHS
  509. "$ENV{HOME}/Qt"
  510. "/opt/Qt")
  511. endif()
  512. list(REMOVE_DUPLICATES _CPACK_IFW_PATHS)
  513. set(_CPACK_IFW_PREFIXES
  514. # QtSDK
  515. "Tools/QtInstallerFramework/"
  516. # Second branch
  517. "QtIFW"
  518. # First branch
  519. "QtIFW-")
  520. set(_CPACK_IFW_VERSIONS
  521. "2.3"
  522. "2.3.0"
  523. "2.2"
  524. "2.2.0"
  525. "2.1"
  526. "2.1.0"
  527. "2.0"
  528. "2.0.3"
  529. "2.0.2"
  530. "2.0.1"
  531. "2.0.0"
  532. "1.6"
  533. "1.6.0"
  534. "1.5"
  535. "1.5.0"
  536. "1.4"
  537. "1.4.0"
  538. "1.3"
  539. "1.3.0")
  540. set(_CPACK_IFW_SUFFIXES "bin")
  541. foreach(_CPACK_IFW_PREFIX ${_CPACK_IFW_PREFIXES})
  542. foreach(_CPACK_IFW_VERSION ${_CPACK_IFW_VERSIONS})
  543. list(APPEND
  544. _CPACK_IFW_SUFFIXES "${_CPACK_IFW_PREFIX}${_CPACK_IFW_VERSION}/bin")
  545. endforeach()
  546. endforeach()
  547. # Look for 'binarycreator'
  548. find_program(CPACK_IFW_BINARYCREATOR_EXECUTABLE
  549. NAMES binarycreator
  550. PATHS ${_CPACK_IFW_PATHS}
  551. PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
  552. DOC "QtIFW binarycreator command line client")
  553. mark_as_advanced(CPACK_IFW_BINARYCREATOR_EXECUTABLE)
  554. # Look for 'repogen'
  555. find_program(CPACK_IFW_REPOGEN_EXECUTABLE
  556. NAMES repogen
  557. PATHS ${_CPACK_IFW_PATHS}
  558. PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
  559. DOC "QtIFW repogen command line client"
  560. )
  561. mark_as_advanced(CPACK_IFW_REPOGEN_EXECUTABLE)
  562. # Look for 'installerbase'
  563. find_program(CPACK_IFW_INSTALLERBASE_EXECUTABLE
  564. NAMES installerbase
  565. PATHS ${_CPACK_IFW_PATHS}
  566. PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
  567. DOC "QtIFW installer executable base"
  568. )
  569. mark_as_advanced(CPACK_IFW_INSTALLERBASE_EXECUTABLE)
  570. # Look for 'devtool' (appeared in the second branch)
  571. find_program(CPACK_IFW_DEVTOOL_EXECUTABLE
  572. NAMES devtool
  573. PATHS ${_CPACK_IFW_PATHS}
  574. PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
  575. DOC "QtIFW devtool command line client"
  576. )
  577. mark_as_advanced(CPACK_IFW_DEVTOOL_EXECUTABLE)
  578. #
  579. ## Next code is included only once
  580. #
  581. if(NOT CPackIFW_CMake_INCLUDED)
  582. set(CPackIFW_CMake_INCLUDED 1)
  583. #=============================================================================
  584. # Framework version
  585. #=============================================================================
  586. if(CPACK_IFW_INSTALLERBASE_EXECUTABLE AND CPACK_IFW_DEVTOOL_EXECUTABLE)
  587. execute_process(COMMAND
  588. "${CPACK_IFW_INSTALLERBASE_EXECUTABLE}" --framework-version
  589. OUTPUT_VARIABLE CPACK_IFW_FRAMEWORK_VERSION)
  590. if(CPACK_IFW_FRAMEWORK_VERSION)
  591. string(REPLACE " " ""
  592. CPACK_IFW_FRAMEWORK_VERSION "${CPACK_IFW_FRAMEWORK_VERSION}")
  593. string(REPLACE "\t" ""
  594. CPACK_IFW_FRAMEWORK_VERSION "${CPACK_IFW_FRAMEWORK_VERSION}")
  595. string(REPLACE "\n" ""
  596. CPACK_IFW_FRAMEWORK_VERSION "${CPACK_IFW_FRAMEWORK_VERSION}")
  597. if(CPACK_IFW_VERBOSE)
  598. message(STATUS "Found QtIFW ${CPACK_IFW_FRAMEWORK_VERSION} version")
  599. endif()
  600. endif()
  601. endif()
  602. #=============================================================================
  603. # Macro definition
  604. #=============================================================================
  605. # Macro definition based on CPackComponent
  606. if(NOT CPackComponent_CMake_INCLUDED)
  607. include(CPackComponent)
  608. endif()
  609. if(NOT __CMAKE_PARSE_ARGUMENTS_INCLUDED)
  610. include(CMakeParseArguments)
  611. endif()
  612. # Resolve full filename for script file
  613. macro(_cpack_ifw_resolve_script _variable)
  614. set(_ifw_script_macro ${_variable})
  615. set(_ifw_script_file ${${_ifw_script_macro}})
  616. if(DEFINED ${_ifw_script_macro})
  617. get_filename_component(${_ifw_script_macro} ${_ifw_script_file} ABSOLUTE)
  618. set(_ifw_script_file ${${_ifw_script_macro}})
  619. if(NOT EXISTS ${_ifw_script_file})
  620. message(WARNING "CPack IFW: script file \"${_ifw_script_file}\" is not exists")
  621. set(${_ifw_script_macro})
  622. endif()
  623. endif()
  624. endmacro()
  625. # Resolve full path to lisense file
  626. macro(_cpack_ifw_resolve_lisenses _variable)
  627. if(${_variable})
  628. set(_ifw_license_file FALSE)
  629. set(_ifw_licenses_fix)
  630. foreach(_ifw_licenses_arg ${${_variable}})
  631. if(_ifw_license_file)
  632. get_filename_component(_ifw_licenses_arg "${_ifw_licenses_arg}" ABSOLUTE)
  633. set(_ifw_license_file FALSE)
  634. else()
  635. set(_ifw_license_file TRUE)
  636. endif()
  637. list(APPEND _ifw_licenses_fix "${_ifw_licenses_arg}")
  638. endforeach(_ifw_licenses_arg)
  639. set(${_variable} "${_ifw_licenses_fix}")
  640. endif()
  641. endmacro()
  642. # Resolve full path to a list of provided files
  643. macro(_cpack_ifw_resolve_file_list _variable)
  644. if(${_variable})
  645. set(_ifw_list_fix)
  646. foreach(_ifw_file_arg ${${_variable}})
  647. get_filename_component(_ifw_file_arg "${_ifw_file_arg}" ABSOLUTE)
  648. if(EXISTS ${_ifw_file_arg})
  649. list(APPEND _ifw_list_fix "${_ifw_file_arg}")
  650. else()
  651. message(WARNING "CPack IFW: page file \"${_ifw_file_arg}\" does not exist. Skipping")
  652. endif()
  653. endforeach(_ifw_file_arg)
  654. set(${_variable} "${_ifw_list_fix}")
  655. endif()
  656. endmacro()
  657. # Macro for configure component
  658. macro(cpack_ifw_configure_component compname)
  659. string(TOUPPER ${compname} _CPACK_IFWCOMP_UNAME)
  660. set(_IFW_OPT COMMON ESSENTIAL VIRTUAL FORCED_INSTALLATION)
  661. set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY DEFAULT)
  662. set(_IFW_MULTI_ARGS DEPENDS LICENSES USER_INTERFACES)
  663. cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
  664. _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT)
  665. _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_LICENSES)
  666. _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_USER_INTERFACES)
  667. set(_CPACK_IFWCOMP_STR "\n# Configuration for IFW component \"${compname}\"\n")
  668. foreach(_IFW_ARG_NAME ${_IFW_OPT})
  669. cpack_append_option_set_command(
  670. CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_${_IFW_ARG_NAME}
  671. _CPACK_IFWCOMP_STR)
  672. endforeach()
  673. foreach(_IFW_ARG_NAME ${_IFW_ARGS})
  674. cpack_append_string_variable_set_command(
  675. CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_${_IFW_ARG_NAME}
  676. _CPACK_IFWCOMP_STR)
  677. endforeach()
  678. foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
  679. cpack_append_list_variable_set_command(
  680. CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_${_IFW_ARG_NAME}
  681. _CPACK_IFWCOMP_STR)
  682. endforeach()
  683. if(CPack_CMake_INCLUDED)
  684. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWCOMP_STR}")
  685. endif()
  686. endmacro()
  687. # Macro for configure group
  688. macro(cpack_ifw_configure_component_group grpname)
  689. string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME)
  690. set(_IFW_OPT VIRTUAL FORCED_INSTALLATION)
  691. set(_IFW_ARGS NAME DISPLAY_NAME DESCRIPTION VERSION RELEASE_DATE SCRIPT PRIORITY DEFAULT)
  692. set(_IFW_MULTI_ARGS LICENSES USER_INTERFACES)
  693. cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
  694. _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_SCRIPT)
  695. _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_LICENSES)
  696. _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_USER_INTERFACES)
  697. set(_CPACK_IFWGRP_STR "\n# Configuration for IFW component group \"${grpname}\"\n")
  698. foreach(_IFW_ARG_NAME ${_IFW_ARGS})
  699. cpack_append_string_variable_set_command(
  700. CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME}
  701. _CPACK_IFWGRP_STR)
  702. endforeach()
  703. foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
  704. cpack_append_list_variable_set_command(
  705. CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME}
  706. _CPACK_IFWGRP_STR)
  707. endforeach()
  708. if(CPack_CMake_INCLUDED)
  709. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWGRP_STR}")
  710. endif()
  711. endmacro()
  712. # Macro for adding repository
  713. macro(cpack_ifw_add_repository reponame)
  714. string(TOUPPER ${reponame} _CPACK_IFWREPO_UNAME)
  715. set(_IFW_OPT DISABLED)
  716. set(_IFW_ARGS URL USERNAME PASSWORD DISPLAY_NAME)
  717. set(_IFW_MULTI_ARGS)
  718. cmake_parse_arguments(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
  719. set(_CPACK_IFWREPO_STR "\n# Configuration for IFW repository \"${reponame}\"\n")
  720. foreach(_IFW_ARG_NAME ${_IFW_OPT})
  721. cpack_append_option_set_command(
  722. CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
  723. _CPACK_IFWREPO_STR)
  724. endforeach()
  725. foreach(_IFW_ARG_NAME ${_IFW_ARGS})
  726. cpack_append_string_variable_set_command(
  727. CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
  728. _CPACK_IFWREPO_STR)
  729. endforeach()
  730. foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
  731. cpack_append_variable_set_command(
  732. CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
  733. _CPACK_IFWREPO_STR)
  734. endforeach()
  735. list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})
  736. string(APPEND _CPACK_IFWREPO_STR "list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n")
  737. if(CPack_CMake_INCLUDED)
  738. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWREPO_STR}")
  739. endif()
  740. endmacro()
  741. # Macro for updating repository
  742. macro(cpack_ifw_update_repository reponame)
  743. string(TOUPPER ${reponame} _CPACK_IFWREPO_UNAME)
  744. set(_IFW_OPT ADD REMOVE REPLACE DISABLED)
  745. set(_IFW_ARGS URL OLD_URL NEW_URL USERNAME PASSWORD DISPLAY_NAME)
  746. set(_IFW_MULTI_ARGS)
  747. cmake_parse_arguments(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
  748. set(_CPACK_IFWREPO_STR "\n# Configuration for IFW repository \"${reponame}\" update\n")
  749. foreach(_IFW_ARG_NAME ${_IFW_OPT})
  750. cpack_append_option_set_command(
  751. CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
  752. _CPACK_IFWREPO_STR)
  753. endforeach()
  754. foreach(_IFW_ARG_NAME ${_IFW_ARGS})
  755. cpack_append_string_variable_set_command(
  756. CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
  757. _CPACK_IFWREPO_STR)
  758. endforeach()
  759. foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
  760. cpack_append_variable_set_command(
  761. CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
  762. _CPACK_IFWREPO_STR)
  763. endforeach()
  764. if(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_ADD
  765. OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REMOVE
  766. OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REPLACE)
  767. list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})
  768. string(APPEND _CPACK_IFWREPO_STR "list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n")
  769. else()
  770. set(_CPACK_IFWREPO_STR)
  771. endif()
  772. if(CPack_CMake_INCLUDED AND _CPACK_IFWREPO_STR)
  773. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWREPO_STR}")
  774. endif()
  775. endmacro()
  776. # Macro for adding resources
  777. macro(cpack_ifw_add_package_resources)
  778. set(_CPACK_IFW_PACKAGE_RESOURCES ${ARGV})
  779. _cpack_ifw_resolve_file_list(_CPACK_IFW_PACKAGE_RESOURCES)
  780. list(APPEND CPACK_IFW_PACKAGE_RESOURCES ${_CPACK_IFW_PACKAGE_RESOURCES})
  781. set(_CPACK_IFWQRC_STR "list(APPEND CPACK_IFW_PACKAGE_RESOURCES \"${_CPACK_IFW_PACKAGE_RESOURCES}\")\n")
  782. if(CPack_CMake_INCLUDED)
  783. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWQRC_STR}")
  784. endif()
  785. endmacro()
  786. # Resolve package control script
  787. _cpack_ifw_resolve_script(CPACK_IFW_PACKAGE_CONTROL_SCRIPT)
  788. endif() # NOT CPackIFW_CMake_INCLUDED