CPackComponent.cmake 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. # CPackComponent
  5. # --------------
  6. #
  7. # Build binary and source package installers
  8. #
  9. # Variables concerning CPack Components
  10. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  11. #
  12. # The CPackComponent module is the module which handles the component
  13. # part of CPack. See CPack module for general information about CPack.
  14. #
  15. # For certain kinds of binary installers (including the graphical
  16. # installers on Mac OS X and Windows), CPack generates installers that
  17. # allow users to select individual application components to install.
  18. # The contents of each of the components are identified by the COMPONENT
  19. # argument of CMake's INSTALL command. These components can be
  20. # annotated with user-friendly names and descriptions, inter-component
  21. # dependencies, etc., and grouped in various ways to customize the
  22. # resulting installer. See the cpack_add_* commands, described below,
  23. # for more information about component-specific installations.
  24. #
  25. # Component-specific installation allows users to select specific sets
  26. # of components to install during the install process. Installation
  27. # components are identified by the COMPONENT argument of CMake's INSTALL
  28. # commands, and should be further described by the following CPack
  29. # commands:
  30. #
  31. # .. variable:: CPACK_COMPONENTS_ALL
  32. #
  33. # The list of component to install.
  34. #
  35. # The default value of this variable is computed by CPack and contains all
  36. # components defined by the project. The user may set it to only include the
  37. # specified components.
  38. #
  39. # .. variable:: CPACK_<GENNAME>_COMPONENT_INSTALL
  40. #
  41. # Enable/Disable component install for CPack generator <GENNAME>.
  42. #
  43. # Each CPack Generator (RPM, DEB, ARCHIVE, NSIS, DMG, etc...) has a legacy
  44. # default behavior. e.g. RPM builds monolithic whereas NSIS builds
  45. # component. One can change the default behavior by setting this variable to
  46. # 0/1 or OFF/ON.
  47. #
  48. # .. variable:: CPACK_COMPONENTS_GROUPING
  49. #
  50. # Specify how components are grouped for multi-package component-aware CPack
  51. # generators.
  52. #
  53. # Some generators like RPM or ARCHIVE family (TGZ, ZIP, ...) generates
  54. # several packages files when asked for component packaging. They group
  55. # the component differently depending on the value of this variable:
  56. #
  57. # * ONE_PER_GROUP (default): creates one package file per component group
  58. # * ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) component
  59. # * IGNORE : creates one package per component, i.e. IGNORE component group
  60. #
  61. # One can specify different grouping for different CPack generator by
  62. # using a CPACK_PROJECT_CONFIG_FILE.
  63. #
  64. # .. variable:: CPACK_COMPONENT_<compName>_DISPLAY_NAME
  65. #
  66. # The name to be displayed for a component.
  67. #
  68. # .. variable:: CPACK_COMPONENT_<compName>_DESCRIPTION
  69. #
  70. # The description of a component.
  71. #
  72. # .. variable:: CPACK_COMPONENT_<compName>_GROUP
  73. #
  74. # The group of a component.
  75. #
  76. # .. variable:: CPACK_COMPONENT_<compName>_DEPENDS
  77. #
  78. # The dependencies (list of components) on which this component depends.
  79. #
  80. # .. variable:: CPACK_COMPONENT_<compName>_HIDDEN
  81. #
  82. # True if this component is hidden from the user.
  83. #
  84. # .. variable:: CPACK_COMPONENT_<compName>_REQUIRED
  85. #
  86. # True if this component is required.
  87. #
  88. # .. variable:: CPACK_COMPONENT_<compName>_DISABLED
  89. #
  90. # True if this component is not selected to be installed by default.
  91. #
  92. # .. command:: cpack_add_component
  93. #
  94. # Describes a CPack installation
  95. # component named by the COMPONENT argument to a CMake INSTALL command.
  96. #
  97. # ::
  98. #
  99. # cpack_add_component(compname
  100. # [DISPLAY_NAME name]
  101. # [DESCRIPTION description]
  102. # [HIDDEN | REQUIRED | DISABLED ]
  103. # [GROUP group]
  104. # [DEPENDS comp1 comp2 ... ]
  105. # [INSTALL_TYPES type1 type2 ... ]
  106. # [DOWNLOADED]
  107. # [ARCHIVE_FILE filename])
  108. #
  109. #
  110. #
  111. # The cmake_add_component command describes an installation component,
  112. # which the user can opt to install or remove as part of the graphical
  113. # installation process. compname is the name of the component, as
  114. # provided to the COMPONENT argument of one or more CMake INSTALL
  115. # commands.
  116. #
  117. # DISPLAY_NAME is the displayed name of the component, used in graphical
  118. # installers to display the component name. This value can be any
  119. # string.
  120. #
  121. # DESCRIPTION is an extended description of the component, used in
  122. # graphical installers to give the user additional information about the
  123. # component. Descriptions can span multiple lines using ``\n`` as the
  124. # line separator. Typically, these descriptions should be no more than
  125. # a few lines long.
  126. #
  127. # HIDDEN indicates that this component will be hidden in the graphical
  128. # installer, so that the user cannot directly change whether it is
  129. # installed or not.
  130. #
  131. # REQUIRED indicates that this component is required, and therefore will
  132. # always be installed. It will be visible in the graphical installer,
  133. # but it cannot be unselected. (Typically, required components are
  134. # shown greyed out).
  135. #
  136. # DISABLED indicates that this component should be disabled (unselected)
  137. # by default. The user is free to select this component for
  138. # installation, unless it is also HIDDEN.
  139. #
  140. # DEPENDS lists the components on which this component depends. If this
  141. # component is selected, then each of the components listed must also be
  142. # selected. The dependency information is encoded within the installer
  143. # itself, so that users cannot install inconsistent sets of components.
  144. #
  145. # GROUP names the component group of which this component is a part. If
  146. # not provided, the component will be a standalone component, not part
  147. # of any component group. Component groups are described with the
  148. # cpack_add_component_group command, detailed below.
  149. #
  150. # INSTALL_TYPES lists the installation types of which this component is
  151. # a part. When one of these installations types is selected, this
  152. # component will automatically be selected. Installation types are
  153. # described with the cpack_add_install_type command, detailed below.
  154. #
  155. # DOWNLOADED indicates that this component should be downloaded
  156. # on-the-fly by the installer, rather than packaged in with the
  157. # installer itself. For more information, see the
  158. # cpack_configure_downloads command.
  159. #
  160. # ARCHIVE_FILE provides a name for the archive file created by CPack to
  161. # be used for downloaded components. If not supplied, CPack will create
  162. # a file with some name based on CPACK_PACKAGE_FILE_NAME and the name of
  163. # the component. See cpack_configure_downloads for more information.
  164. #
  165. # .. command:: cpack_add_component_group
  166. #
  167. # Describes a group of related CPack installation components.
  168. #
  169. # ::
  170. #
  171. # cpack_add_component_group(groupname
  172. # [DISPLAY_NAME name]
  173. # [DESCRIPTION description]
  174. # [PARENT_GROUP parent]
  175. # [EXPANDED]
  176. # [BOLD_TITLE])
  177. #
  178. #
  179. #
  180. # The cpack_add_component_group describes a group of installation
  181. # components, which will be placed together within the listing of
  182. # options. Typically, component groups allow the user to
  183. # select/deselect all of the components within a single group via a
  184. # single group-level option. Use component groups to reduce the
  185. # complexity of installers with many options. groupname is an arbitrary
  186. # name used to identify the group in the GROUP argument of the
  187. # cpack_add_component command, which is used to place a component in a
  188. # group. The name of the group must not conflict with the name of any
  189. # component.
  190. #
  191. # DISPLAY_NAME is the displayed name of the component group, used in
  192. # graphical installers to display the component group name. This value
  193. # can be any string.
  194. #
  195. # DESCRIPTION is an extended description of the component group, used in
  196. # graphical installers to give the user additional information about the
  197. # components within that group. Descriptions can span multiple lines
  198. # using ``\n`` as the line separator. Typically, these descriptions
  199. # should be no more than a few lines long.
  200. #
  201. # PARENT_GROUP, if supplied, names the parent group of this group.
  202. # Parent groups are used to establish a hierarchy of groups, providing
  203. # an arbitrary hierarchy of groups.
  204. #
  205. # EXPANDED indicates that, by default, the group should show up as
  206. # "expanded", so that the user immediately sees all of the components
  207. # within the group. Otherwise, the group will initially show up as a
  208. # single entry.
  209. #
  210. # BOLD_TITLE indicates that the group title should appear in bold, to
  211. # call the user's attention to the group.
  212. #
  213. # .. command:: cpack_add_install_type
  214. #
  215. # Add a new installation type containing
  216. # a set of predefined component selections to the graphical installer.
  217. #
  218. # ::
  219. #
  220. # cpack_add_install_type(typename
  221. # [DISPLAY_NAME name])
  222. #
  223. #
  224. #
  225. # The cpack_add_install_type command identifies a set of preselected
  226. # components that represents a common use case for an application. For
  227. # example, a "Developer" install type might include an application along
  228. # with its header and library files, while an "End user" install type
  229. # might just include the application's executable. Each component
  230. # identifies itself with one or more install types via the INSTALL_TYPES
  231. # argument to cpack_add_component.
  232. #
  233. # DISPLAY_NAME is the displayed name of the install type, which will
  234. # typically show up in a drop-down box within a graphical installer.
  235. # This value can be any string.
  236. #
  237. # .. command:: cpack_configure_downloads
  238. #
  239. # Configure CPack to download
  240. # selected components on-the-fly as part of the installation process.
  241. #
  242. # ::
  243. #
  244. # cpack_configure_downloads(site
  245. # [UPLOAD_DIRECTORY dirname]
  246. # [ALL]
  247. # [ADD_REMOVE|NO_ADD_REMOVE])
  248. #
  249. #
  250. #
  251. # The cpack_configure_downloads command configures installation-time
  252. # downloads of selected components. For each downloadable component,
  253. # CPack will create an archive containing the contents of that
  254. # component, which should be uploaded to the given site. When the user
  255. # selects that component for installation, the installer will download
  256. # and extract the component in place. This feature is useful for
  257. # creating small installers that only download the requested components,
  258. # saving bandwidth. Additionally, the installers are small enough that
  259. # they will be installed as part of the normal installation process, and
  260. # the "Change" button in Windows Add/Remove Programs control panel will
  261. # allow one to add or remove parts of the application after the original
  262. # installation. On Windows, the downloaded-components functionality
  263. # requires the ZipDLL plug-in for NSIS, available at:
  264. #
  265. # ::
  266. #
  267. # http://nsis.sourceforge.net/ZipDLL_plug-in
  268. #
  269. #
  270. #
  271. # On Mac OS X, installers that download components on-the-fly can only
  272. # be built and installed on system using Mac OS X 10.5 or later.
  273. #
  274. # The site argument is a URL where the archives for downloadable
  275. # components will reside, e.g.,
  276. # https://cmake.org/files/2.6.1/installer/ All of the archives
  277. # produced by CPack should be uploaded to that location.
  278. #
  279. # UPLOAD_DIRECTORY is the local directory where CPack will create the
  280. # various archives for each of the components. The contents of this
  281. # directory should be uploaded to a location accessible by the URL given
  282. # in the site argument. If omitted, CPack will use the directory
  283. # CPackUploads inside the CMake binary directory to store the generated
  284. # archives.
  285. #
  286. # The ALL flag indicates that all components be downloaded. Otherwise,
  287. # only those components explicitly marked as DOWNLOADED or that have a
  288. # specified ARCHIVE_FILE will be downloaded. Additionally, the ALL
  289. # option implies ADD_REMOVE (unless NO_ADD_REMOVE is specified).
  290. #
  291. # ADD_REMOVE indicates that CPack should install a copy of the installer
  292. # that can be called from Windows' Add/Remove Programs dialog (via the
  293. # "Modify" button) to change the set of installed components.
  294. # NO_ADD_REMOVE turns off this behavior. This option is ignored on Mac
  295. # OS X.
  296. # Define var in order to avoid multiple inclusion
  297. if(NOT CPackComponent_CMake_INCLUDED)
  298. set(CPackComponent_CMake_INCLUDED 1)
  299. # Argument-parsing macro from https://cmake.org/Wiki/CMakeMacroParseArguments
  300. macro(cpack_parse_arguments prefix arg_names option_names)
  301. set(${prefix}_DEFAULT_ARGS)
  302. foreach(arg_name ${arg_names})
  303. set(${prefix}_${arg_name})
  304. endforeach()
  305. foreach(option ${option_names})
  306. set(${prefix}_${option} FALSE)
  307. endforeach()
  308. set(current_arg_name DEFAULT_ARGS)
  309. set(current_arg_list)
  310. foreach(arg ${ARGN})
  311. set(larg_names ${arg_names})
  312. list(FIND larg_names "${arg}" is_arg_name)
  313. if (is_arg_name GREATER -1)
  314. set(${prefix}_${current_arg_name} ${current_arg_list})
  315. set(current_arg_name ${arg})
  316. set(current_arg_list)
  317. else ()
  318. set(loption_names ${option_names})
  319. list(FIND loption_names "${arg}" is_option)
  320. if (is_option GREATER -1)
  321. set(${prefix}_${arg} TRUE)
  322. else ()
  323. set(current_arg_list ${current_arg_list} ${arg})
  324. endif ()
  325. endif ()
  326. endforeach()
  327. set(${prefix}_${current_arg_name} ${current_arg_list})
  328. endmacro()
  329. # Macro that appends a SET command for the given variable name (var)
  330. # to the macro named strvar, but only if the variable named "var"
  331. # has been defined. The string will eventually be appended to a CPack
  332. # configuration file.
  333. macro(cpack_append_variable_set_command var strvar)
  334. if (DEFINED ${var})
  335. set(${strvar} "${${strvar}}set(${var}")
  336. foreach(APPENDVAL ${${var}})
  337. set(${strvar} "${${strvar}} ${APPENDVAL}")
  338. endforeach()
  339. set(${strvar} "${${strvar}})\n")
  340. endif ()
  341. endmacro()
  342. # Macro that appends a SET command for the given variable name (var)
  343. # to the macro named strvar, but only if the variable named "var"
  344. # has been defined and is a string. The string will eventually be
  345. # appended to a CPack configuration file.
  346. macro(cpack_append_string_variable_set_command var strvar)
  347. if (DEFINED ${var})
  348. list(LENGTH ${var} CPACK_APP_VALUE_LEN)
  349. if(${CPACK_APP_VALUE_LEN} EQUAL 1)
  350. set(${strvar} "${${strvar}}set(${var} \"${${var}}\")\n")
  351. endif()
  352. endif ()
  353. endmacro()
  354. # Macro that appends a SET command for the given list variable name (var)
  355. # to the macro named strvar, but only if the variable named "var"
  356. # has been defined. It's like add variable, but wrap each item to quotes.
  357. # The string will eventually be appended to a CPack configuration file.
  358. macro(cpack_append_list_variable_set_command var strvar)
  359. if (DEFINED ${var})
  360. string(APPEND ${strvar} "set(${var}")
  361. foreach(_val IN LISTS ${var})
  362. string(APPEND ${strvar} "\n \"${_val}\"")
  363. endforeach()
  364. string(APPEND ${strvar} ")\n")
  365. endif ()
  366. endmacro()
  367. # Macro that appends a SET command for the given variable name (var)
  368. # to the macro named strvar, but only if the variable named "var"
  369. # has been set to true. The string will eventually be
  370. # appended to a CPack configuration file.
  371. macro(cpack_append_option_set_command var strvar)
  372. if (${var})
  373. list(LENGTH ${var} CPACK_APP_VALUE_LEN)
  374. if(${CPACK_APP_VALUE_LEN} EQUAL 1)
  375. set(${strvar} "${${strvar}}set(${var} TRUE)\n")
  376. endif()
  377. endif ()
  378. endmacro()
  379. # Macro that adds a component to the CPack installer
  380. macro(cpack_add_component compname)
  381. string(TOUPPER ${compname} _CPACK_ADDCOMP_UNAME)
  382. cpack_parse_arguments(CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}
  383. "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE"
  384. "HIDDEN;REQUIRED;DISABLED;DOWNLOADED"
  385. ${ARGN}
  386. )
  387. if (CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DOWNLOADED)
  388. set(_CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n")
  389. else ()
  390. set(_CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n")
  391. endif ()
  392. if(NOT CPACK_MONOLITHIC_INSTALL)
  393. # If the user didn't set CPACK_COMPONENTS_ALL explicitly, update the
  394. # value of CPACK_COMPONENTS_ALL in the configuration file. This will
  395. # take care of any components that have been added after the CPack
  396. # moduled was included.
  397. if(NOT CPACK_COMPONENTS_ALL_SET_BY_USER)
  398. get_cmake_property(_CPACK_ADDCOMP_COMPONENTS COMPONENTS)
  399. string(APPEND _CPACK_ADDCOMP_STR "\nSET(CPACK_COMPONENTS_ALL")
  400. foreach(COMP ${_CPACK_ADDCOMP_COMPONENTS})
  401. string(APPEND _CPACK_ADDCOMP_STR " ${COMP}")
  402. endforeach()
  403. string(APPEND _CPACK_ADDCOMP_STR ")\n")
  404. endif()
  405. endif()
  406. cpack_append_string_variable_set_command(
  407. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DISPLAY_NAME
  408. _CPACK_ADDCOMP_STR)
  409. cpack_append_string_variable_set_command(
  410. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DESCRIPTION
  411. _CPACK_ADDCOMP_STR)
  412. cpack_append_variable_set_command(
  413. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_GROUP
  414. _CPACK_ADDCOMP_STR)
  415. cpack_append_variable_set_command(
  416. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DEPENDS
  417. _CPACK_ADDCOMP_STR)
  418. cpack_append_variable_set_command(
  419. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_INSTALL_TYPES
  420. _CPACK_ADDCOMP_STR)
  421. cpack_append_string_variable_set_command(
  422. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE
  423. _CPACK_ADDCOMP_STR)
  424. cpack_append_option_set_command(
  425. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_HIDDEN
  426. _CPACK_ADDCOMP_STR)
  427. cpack_append_option_set_command(
  428. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_REQUIRED
  429. _CPACK_ADDCOMP_STR)
  430. cpack_append_option_set_command(
  431. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DISABLED
  432. _CPACK_ADDCOMP_STR)
  433. cpack_append_option_set_command(
  434. CPACK_COMPONENT_${_CPACK_ADDCOMP_UNAME}_DOWNLOADED
  435. _CPACK_ADDCOMP_STR)
  436. # Backward compatibility issue.
  437. # Write to config iff the macros is used after CPack.cmake has been
  438. # included, other it's not necessary because the variables
  439. # will be encoded by cpack_encode_variables.
  440. if(CPack_CMake_INCLUDED)
  441. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_ADDCOMP_STR}")
  442. endif()
  443. endmacro()
  444. # Macro that adds a component group to the CPack installer
  445. macro(cpack_add_component_group grpname)
  446. string(TOUPPER ${grpname} _CPACK_ADDGRP_UNAME)
  447. cpack_parse_arguments(CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}
  448. "DISPLAY_NAME;DESCRIPTION;PARENT_GROUP"
  449. "EXPANDED;BOLD_TITLE"
  450. ${ARGN}
  451. )
  452. set(_CPACK_ADDGRP_STR "\n# Configuration for component group \"${grpname}\"\n")
  453. cpack_append_string_variable_set_command(
  454. CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_DISPLAY_NAME
  455. _CPACK_ADDGRP_STR)
  456. cpack_append_string_variable_set_command(
  457. CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_DESCRIPTION
  458. _CPACK_ADDGRP_STR)
  459. cpack_append_string_variable_set_command(
  460. CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_PARENT_GROUP
  461. _CPACK_ADDGRP_STR)
  462. cpack_append_option_set_command(
  463. CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_EXPANDED
  464. _CPACK_ADDGRP_STR)
  465. cpack_append_option_set_command(
  466. CPACK_COMPONENT_GROUP_${_CPACK_ADDGRP_UNAME}_BOLD_TITLE
  467. _CPACK_ADDGRP_STR)
  468. # Backward compatibility issue.
  469. # Write to config iff the macros is used after CPack.cmake has been
  470. # included, other it's not necessary because the variables
  471. # will be encoded by cpack_encode_variables.
  472. if(CPack_CMake_INCLUDED)
  473. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_ADDGRP_STR}")
  474. endif()
  475. endmacro()
  476. # Macro that adds an installation type to the CPack installer
  477. macro(cpack_add_install_type insttype)
  478. string(TOUPPER ${insttype} _CPACK_INSTTYPE_UNAME)
  479. cpack_parse_arguments(CPACK_INSTALL_TYPE_${_CPACK_INSTTYPE_UNAME}
  480. "DISPLAY_NAME"
  481. ""
  482. ${ARGN}
  483. )
  484. set(_CPACK_INSTTYPE_STR
  485. "\n# Configuration for installation type \"${insttype}\"\n")
  486. string(APPEND _CPACK_INSTTYPE_STR
  487. "list(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n")
  488. cpack_append_string_variable_set_command(
  489. CPACK_INSTALL_TYPE_${_CPACK_INSTTYPE_UNAME}_DISPLAY_NAME
  490. _CPACK_INSTTYPE_STR)
  491. # Backward compatibility issue.
  492. # Write to config iff the macros is used after CPack.cmake has been
  493. # included, other it's not necessary because the variables
  494. # will be encoded by cpack_encode_variables.
  495. if(CPack_CMake_INCLUDED)
  496. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_INSTTYPE_STR}")
  497. endif()
  498. endmacro()
  499. macro(cpack_configure_downloads site)
  500. cpack_parse_arguments(CPACK_DOWNLOAD
  501. "UPLOAD_DIRECTORY"
  502. "ALL;ADD_REMOVE;NO_ADD_REMOVE"
  503. ${ARGN}
  504. )
  505. set(CPACK_CONFIG_DL_STR
  506. "\n# Downloaded components configuration\n")
  507. set(CPACK_UPLOAD_DIRECTORY ${CPACK_DOWNLOAD_UPLOAD_DIRECTORY})
  508. set(CPACK_DOWNLOAD_SITE ${site})
  509. cpack_append_string_variable_set_command(
  510. CPACK_DOWNLOAD_SITE
  511. CPACK_CONFIG_DL_STR)
  512. cpack_append_string_variable_set_command(
  513. CPACK_UPLOAD_DIRECTORY
  514. CPACK_CONFIG_DL_STR)
  515. cpack_append_option_set_command(
  516. CPACK_DOWNLOAD_ALL
  517. CPACK_CONFIG_DL_STR)
  518. if (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE})
  519. set(CPACK_DOWNLOAD_ADD_REMOVE ON)
  520. endif ()
  521. set(CPACK_ADD_REMOVE ${CPACK_DOWNLOAD_ADD_REMOVE})
  522. cpack_append_option_set_command(
  523. CPACK_ADD_REMOVE
  524. CPACK_CONFIG_DL_STR)
  525. # Backward compatibility issue.
  526. # Write to config iff the macros is used after CPack.cmake has been
  527. # included, other it's not necessary because the variables
  528. # will be encoded by cpack_encode_variables.
  529. if(CPack_CMake_INCLUDED)
  530. file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_CONFIG_DL_STR}")
  531. endif()
  532. endmacro()
  533. endif()