1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4#[=======================================================================[.rst:
5CPackIFW
6--------
7
8.. versionadded:: 3.1
9
10This module looks for the location of the command-line utilities supplied with the
11`Qt Installer Framework <http://doc.qt.io/qtinstallerframework/index.html>`_
12(QtIFW).
13
14The module also defines several commands to control the behavior of the
15:cpack_gen:`CPack IFW Generator`.
16
17Commands
18^^^^^^^^
19
20The module defines the following commands:
21
22.. command:: cpack_ifw_configure_component
23
24  Sets the arguments specific to the CPack IFW generator.
25
26  ::
27
28    cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL]
29                        [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS]
30                        [NAME <name>]
31                        [DISPLAY_NAME <display_name>] # Note: Internationalization supported
32                        [DESCRIPTION <description>] # Note: Internationalization supported
33                        [UPDATE_TEXT <update_text>]
34                        [VERSION <version>]
35                        [RELEASE_DATE <release_date>]
36                        [SCRIPT <script>]
37                        [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated
38                        [DEPENDS|DEPENDENCIES <com_id> ...]
39                        [AUTO_DEPEND_ON <comp_id> ...]
40                        [LICENSES <display_name> <file_path> ...]
41                        [DEFAULT <value>]
42                        [USER_INTERFACES <file_path> <file_path> ...]
43                        [TRANSLATIONS <file_path> <file_path> ...]
44                        [REPLACES <comp_id> ...]
45                        [CHECKABLE <value>])
46
47  This command should be called after :command:`cpack_add_component` command.
48
49  ``COMMON``
50    if set, then the component will be packaged and installed as part
51    of a group to which it belongs.
52
53  ``ESSENTIAL``
54    .. versionadded:: 3.6
55
56    if set, then the package manager stays disabled until that
57    component is updated.
58
59  ``VIRTUAL``
60    .. versionadded:: 3.8
61
62    if set, then the component will be hidden from the installer.
63    It is a equivalent of the ``HIDDEN`` option from the
64    :command:`cpack_add_component` command.
65
66  ``FORCED_INSTALLATION``
67    .. versionadded:: 3.8
68
69    if set, then the component must always be installed.
70    It is a equivalent of the ``REQUIRED`` option from the
71    :command:`cpack_add_component` command.
72
73  ``REQUIRES_ADMIN_RIGHTS``
74    .. versionadded:: 3.8
75
76    set it if the component needs to be installed with elevated permissions.
77
78  ``NAME``
79    is used to create domain-like identification for this component.
80    By default used origin component name.
81
82  ``DISPLAY_NAME``
83    .. versionadded:: 3.8
84
85    set to rewrite original name configured by
86    :command:`cpack_add_component` command.
87
88  ``DESCRIPTION``
89    .. versionadded:: 3.8
90
91    set to rewrite original description configured by
92    :command:`cpack_add_component` command.
93
94  ``UPDATE_TEXT``
95    .. versionadded:: 3.8
96
97    will be added to the component description if this is an update to
98    the component.
99
100  ``VERSION``
101    is version of component.
102    By default used :variable:`CPACK_PACKAGE_VERSION`.
103
104  ``RELEASE_DATE``
105    .. versionadded:: 3.8
106
107    keep empty to auto generate.
108
109  ``SCRIPT``
110    is a relative or absolute path to operations script
111    for this component.
112
113  ``SORTING_PRIORITY``
114    .. versionadded:: 3.8
115
116    is priority of the component in the tree.
117
118  ``PRIORITY``
119    .. deprecated:: 3.8
120      Old name for ``SORTING_PRIORITY``.
121
122  ``DEPENDS``, ``DEPENDENCIES``
123    .. versionadded:: 3.8
124
125    list of dependency component or component group identifiers in
126    QtIFW style.
127
128    .. versionadded:: 3.21
129
130    Component or group names listed as dependencies may contain hyphens.
131    This requires QtIFW 3.1 or later.
132
133  ``AUTO_DEPEND_ON``
134    .. versionadded:: 3.8
135
136    list of identifiers of component or component group in QtIFW style
137    that this component has an automatic dependency on.
138
139  ``LICENSES``
140    pair of <display_name> and <file_path> of license text for this
141    component. You can specify more then one license.
142
143  ``DEFAULT``
144    .. versionadded:: 3.8
145
146    Possible values are: TRUE, FALSE, and SCRIPT.
147    Set to FALSE to disable the component in the installer or to SCRIPT
148    to resolved during runtime (don't forget add the file of the script
149    as a value of the ``SCRIPT`` option).
150
151  ``USER_INTERFACES``
152    .. versionadded:: 3.7
153
154    is a list of <file_path> ('.ui' files) representing pages to load.
155
156  ``TRANSLATIONS``
157    .. versionadded:: 3.8
158
159    is a list of <file_path> ('.qm' files) representing translations to load.
160
161  ``REPLACES``
162    .. versionadded:: 3.10
163
164    list of identifiers of component or component group to replace.
165
166  ``CHECKABLE``
167    .. versionadded:: 3.10
168
169    Possible values are: TRUE, FALSE.
170    Set to FALSE if you want to hide the checkbox for an item.
171    This is useful when only a few subcomponents should be selected
172    instead of all.
173
174
175.. command:: cpack_ifw_configure_component_group
176
177  Sets the arguments specific to the CPack IFW generator.
178
179  ::
180
181    cpack_ifw_configure_component_group(<groupname> [VIRTUAL]
182                        [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS]
183                        [NAME <name>]
184                        [DISPLAY_NAME <display_name>] # Note: Internationalization supported
185                        [DESCRIPTION <description>] # Note: Internationalization supported
186                        [UPDATE_TEXT <update_text>]
187                        [VERSION <version>]
188                        [RELEASE_DATE <release_date>]
189                        [SCRIPT <script>]
190                        [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated
191                        [DEPENDS|DEPENDENCIES <com_id> ...]
192                        [AUTO_DEPEND_ON <comp_id> ...]
193                        [LICENSES <display_name> <file_path> ...]
194                        [DEFAULT <value>]
195                        [USER_INTERFACES <file_path> <file_path> ...]
196                        [TRANSLATIONS <file_path> <file_path> ...]
197                        [REPLACES <comp_id> ...]
198                        [CHECKABLE <value>])
199
200  This command should be called after :command:`cpack_add_component_group`
201  command.
202
203  ``VIRTUAL``
204    .. versionadded:: 3.8
205
206    if set, then the group will be hidden from the installer.
207    Note that setting this on a root component does not work.
208
209  ``FORCED_INSTALLATION``
210    .. versionadded:: 3.8
211
212    if set, then the group must always be installed.
213
214  ``REQUIRES_ADMIN_RIGHTS``
215    .. versionadded:: 3.8
216
217    set it if the component group needs to be installed with elevated
218    permissions.
219
220  ``NAME``
221    is used to create domain-like identification for this component group.
222    By default used origin component group name.
223
224  ``DISPLAY_NAME``
225    .. versionadded:: 3.8
226
227    set to rewrite original name configured by
228    :command:`cpack_add_component_group` command.
229
230  ``DESCRIPTION``
231    .. versionadded:: 3.8
232
233    set to rewrite original description configured by
234    :command:`cpack_add_component_group` command.
235
236  ``UPDATE_TEXT``
237    .. versionadded:: 3.8
238
239    will be added to the component group description if this is an update to
240    the component group.
241
242  ``VERSION``
243    is version of component group.
244    By default used :variable:`CPACK_PACKAGE_VERSION`.
245
246  ``RELEASE_DATE``
247    .. versionadded:: 3.8
248
249    keep empty to auto generate.
250
251  ``SCRIPT``
252    is a relative or absolute path to operations script
253    for this component group.
254
255  ``SORTING_PRIORITY``
256    is priority of the component group in the tree.
257
258  ``PRIORITY``
259    .. deprecated:: 3.8
260      Old name for ``SORTING_PRIORITY``.
261
262  ``DEPENDS``, ``DEPENDENCIES``
263    .. versionadded:: 3.8
264
265    list of dependency component or component group identifiers in
266    QtIFW style.
267
268    .. versionadded:: 3.21
269
270    Component or group names listed as dependencies may contain hyphens.
271    This requires QtIFW 3.1 or later.
272
273  ``AUTO_DEPEND_ON``
274    .. versionadded:: 3.8
275
276    list of identifiers of component or component group in QtIFW style
277    that this component group has an automatic dependency on.
278
279  ``LICENSES``
280    pair of <display_name> and <file_path> of license text for this
281    component group. You can specify more then one license.
282
283  ``DEFAULT``
284    .. versionadded:: 3.8
285
286    Possible values are: TRUE, FALSE, and SCRIPT.
287    Set to TRUE to preselect the group in the installer
288    (this takes effect only on groups that have no visible child components)
289    or to SCRIPT to resolved during runtime (don't forget add the file of
290    the script as a value of the ``SCRIPT`` option).
291
292  ``USER_INTERFACES``
293    .. versionadded:: 3.7
294
295    is a list of <file_path> ('.ui' files) representing pages to load.
296
297  ``TRANSLATIONS``
298    .. versionadded:: 3.8
299
300    is a list of <file_path> ('.qm' files) representing translations to load.
301
302  ``REPLACES``
303    .. versionadded:: 3.10
304
305    list of identifiers of component or component group to replace.
306
307  ``CHECKABLE``
308    .. versionadded:: 3.10
309
310    Possible values are: TRUE, FALSE.
311    Set to FALSE if you want to hide the checkbox for an item.
312    This is useful when only a few subcomponents should be selected
313    instead of all.
314
315
316.. command:: cpack_ifw_add_repository
317
318  Add QtIFW specific remote repository to binary installer.
319
320  ::
321
322    cpack_ifw_add_repository(<reponame> [DISABLED]
323                        URL <url>
324                        [USERNAME <username>]
325                        [PASSWORD <password>]
326                        [DISPLAY_NAME <display_name>])
327
328  This command will also add the <reponame> repository
329  to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
330
331  ``DISABLED``
332    if set, then the repository will be disabled by default.
333
334  ``URL``
335    is points to a list of available components.
336
337  ``USERNAME``
338    is used as user on a protected repository.
339
340  ``PASSWORD``
341    is password to use on a protected repository.
342
343  ``DISPLAY_NAME``
344    is string to display instead of the URL.
345
346
347.. command:: cpack_ifw_update_repository
348
349  .. versionadded:: 3.6
350
351  Update QtIFW specific repository from remote repository.
352
353  ::
354
355    cpack_ifw_update_repository(<reponame>
356                        [[ADD|REMOVE] URL <url>]|
357                         [REPLACE OLD_URL <old_url> NEW_URL <new_url>]]
358                        [USERNAME <username>]
359                        [PASSWORD <password>]
360                        [DISPLAY_NAME <display_name>])
361
362  This command will also add the <reponame> repository
363  to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
364
365  ``URL``
366    is points to a list of available components.
367
368  ``OLD_URL``
369    is points to a list that will replaced.
370
371  ``NEW_URL``
372    is points to a list that will replace to.
373
374  ``USERNAME``
375    is used as user on a protected repository.
376
377  ``PASSWORD``
378    is password to use on a protected repository.
379
380  ``DISPLAY_NAME``
381    is string to display instead of the URL.
382
383
384.. command:: cpack_ifw_add_package_resources
385
386  .. versionadded:: 3.7
387
388  Add additional resources in the installer binary.
389
390  ::
391
392    cpack_ifw_add_package_resources(<file_path> <file_path> ...)
393
394  This command will also add the specified files
395  to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`.
396
397#]=======================================================================]
398
399# TODO:
400# All of the internal implementation CMake modules for other CPack generators
401# have been moved into the Internal/CPack directory. This one has not, because
402# it contains user-facing macros which would be lost if it were moved. At some
403# point, this module should be split into user-facing macros (which would live
404# in this module) and internal implementation details (which would live in
405# Internal/CPack/CPackIFW.cmake).
406
407#=============================================================================
408# Search Qt Installer Framework tools
409#=============================================================================
410
411# Default path
412
413foreach(_CPACK_IFW_PATH_VAR "CPACK_IFW_ROOT" "QTIFWDIR" "QTDIR")
414  if(DEFINED ${_CPACK_IFW_PATH_VAR}
415    AND NOT "${${_CPACK_IFW_PATH_VAR}}" STREQUAL "")
416    list(APPEND _CPACK_IFW_PATHS "${${_CPACK_IFW_PATH_VAR}}")
417  endif()
418  if(NOT "$ENV{${_CPACK_IFW_PATH_VAR}}" STREQUAL "")
419    list(APPEND _CPACK_IFW_PATHS "$ENV{${_CPACK_IFW_PATH_VAR}}")
420  endif()
421endforeach()
422if(WIN32)
423  list(APPEND _CPACK_IFW_PATHS
424    "$ENV{HOMEDRIVE}/Qt"
425    "C:/Qt")
426else()
427  list(APPEND _CPACK_IFW_PATHS
428    "$ENV{HOME}/Qt"
429    "/opt/Qt")
430endif()
431list(REMOVE_DUPLICATES _CPACK_IFW_PATHS)
432
433set(_CPACK_IFW_PREFIXES
434  # QtSDK
435  "Tools/QtInstallerFramework/"
436  # Second branch
437  "QtIFW"
438  # First branch
439  "QtIFW-")
440
441set(_CPACK_IFW_VERSIONS
442  "4.2"
443  "4.1"
444  "4.0"
445  "3.2"
446  "3.2.0"
447  "3.1"
448  "3.1.0"
449  "3.0"
450  "3.0.0"
451  "2.3"
452  "2.3.0"
453  "2.2"
454  "2.2.0"
455  "2.1"
456  "2.1.0"
457  "2.0"
458  "2.0.5"
459  "2.0.3"
460  "2.0.2"
461  "2.0.1"
462  "2.0.0"
463  "1.6"
464  "1.6.0"
465  "1.5"
466  "1.5.0"
467  "1.4"
468  "1.4.0"
469  "1.3"
470  "1.3.0")
471
472set(_CPACK_IFW_SUFFIXES "bin")
473foreach(_CPACK_IFW_PREFIX ${_CPACK_IFW_PREFIXES})
474  foreach(_CPACK_IFW_VERSION ${_CPACK_IFW_VERSIONS})
475    list(APPEND
476      _CPACK_IFW_SUFFIXES "${_CPACK_IFW_PREFIX}${_CPACK_IFW_VERSION}/bin")
477  endforeach()
478endforeach()
479
480# Look for 'binarycreator'
481
482find_program(CPACK_IFW_BINARYCREATOR_EXECUTABLE
483  NAMES binarycreator
484  PATHS ${_CPACK_IFW_PATHS}
485  PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
486  DOC "QtIFW binarycreator command line client")
487
488mark_as_advanced(CPACK_IFW_BINARYCREATOR_EXECUTABLE)
489
490# Look for 'repogen'
491
492find_program(CPACK_IFW_REPOGEN_EXECUTABLE
493  NAMES repogen
494  PATHS ${_CPACK_IFW_PATHS}
495  PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
496  DOC "QtIFW repogen command line client"
497  )
498mark_as_advanced(CPACK_IFW_REPOGEN_EXECUTABLE)
499
500# Look for 'installerbase'
501
502find_program(CPACK_IFW_INSTALLERBASE_EXECUTABLE
503  NAMES installerbase
504  PATHS ${_CPACK_IFW_PATHS}
505  PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
506  DOC "QtIFW installer executable base"
507  )
508mark_as_advanced(CPACK_IFW_INSTALLERBASE_EXECUTABLE)
509
510# Look for 'devtool' (appeared in the second branch)
511
512find_program(CPACK_IFW_DEVTOOL_EXECUTABLE
513  NAMES devtool
514  PATHS ${_CPACK_IFW_PATHS}
515  PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
516  DOC "QtIFW devtool command line client"
517  )
518mark_as_advanced(CPACK_IFW_DEVTOOL_EXECUTABLE)
519
520# Look for 'archivegen'
521
522find_program(CPACK_IFW_ARCHIVEGEN_EXECUTABLE
523  NAMES archivegen
524  PATHS ${_CPACK_IFW_PATHS}
525  PATH_SUFFIXES ${_CPACK_IFW_SUFFIXES}
526  DOC "QtIFW archivegen command line client"
527  )
528mark_as_advanced(CPACK_IFW_ARCHIVEGEN_EXECUTABLE)
529
530#
531## Next code is included only once
532#
533
534if(NOT CPackIFW_CMake_INCLUDED)
535set(CPackIFW_CMake_INCLUDED 1)
536
537#=============================================================================
538# Framework version
539#=============================================================================
540
541set(CPACK_IFW_FRAMEWORK_VERSION_FORCED ""
542  CACHE STRING "The forced version of used QtIFW tools")
543mark_as_advanced(CPACK_IFW_FRAMEWORK_VERSION_FORCED)
544set(CPACK_IFW_FRAMEWORK_VERSION_TIMEOUT 1
545  CACHE STRING "The timeout to return QtIFW framework version string from \"installerbase\" executable")
546mark_as_advanced(CPACK_IFW_FRAMEWORK_VERSION_TIMEOUT)
547if(CPACK_IFW_INSTALLERBASE_EXECUTABLE AND NOT CPACK_IFW_FRAMEWORK_VERSION_FORCED)
548  set(CPACK_IFW_FRAMEWORK_VERSION)
549  # Invoke version from "installerbase" executable
550  foreach(_ifw_version_argument --version --framework-version)
551    if(NOT CPACK_IFW_FRAMEWORK_VERSION)
552      execute_process(COMMAND
553        "${CPACK_IFW_INSTALLERBASE_EXECUTABLE}" ${_ifw_version_argument}
554        TIMEOUT ${CPACK_IFW_FRAMEWORK_VERSION_TIMEOUT}
555        RESULT_VARIABLE CPACK_IFW_FRAMEWORK_VERSION_RESULT
556        OUTPUT_VARIABLE CPACK_IFW_FRAMEWORK_VERSION_OUTPUT
557        OUTPUT_STRIP_TRAILING_WHITESPACE
558        ENCODING UTF8)
559      if(NOT CPACK_IFW_FRAMEWORK_VERSION_RESULT AND CPACK_IFW_FRAMEWORK_VERSION_OUTPUT)
560        string(REGEX MATCH "[0-9]+(\\.[0-9]+)*"
561          CPACK_IFW_FRAMEWORK_VERSION "${CPACK_IFW_FRAMEWORK_VERSION_OUTPUT}")
562        if(CPACK_IFW_FRAMEWORK_VERSION)
563          if("${_ifw_version_argument}" STREQUAL "--framework-version")
564            set(CPACK_IFW_FRAMEWORK_VERSION_SOURCE "INSTALLERBASE_FRAMEWORK_VERSION")
565          elseif("${_ifw_version_argument}" STREQUAL "--version")
566            set(CPACK_IFW_FRAMEWORK_VERSION_SOURCE "INSTALLERBASE_FRAMEWORK_VERSION")
567          endif()
568        endif()
569      endif()
570    endif()
571  endforeach()
572  # Finally try to get version from executable path
573  if(NOT CPACK_IFW_FRAMEWORK_VERSION)
574    string(REGEX MATCH "[0-9]+(\\.[0-9]+)*"
575      CPACK_IFW_FRAMEWORK_VERSION "${CPACK_IFW_INSTALLERBASE_EXECUTABLE}")
576    if(CPACK_IFW_FRAMEWORK_VERSION)
577      set(CPACK_IFW_FRAMEWORK_VERSION_SOURCE "INSTALLERBASE_PATH")
578    endif()
579  endif()
580elseif(CPACK_IFW_FRAMEWORK_VERSION_FORCED)
581  set(CPACK_IFW_FRAMEWORK_VERSION ${CPACK_IFW_FRAMEWORK_VERSION_FORCED})
582  set(CPACK_IFW_FRAMEWORK_VERSION_SOURCE "FORCED")
583endif()
584if(CPACK_IFW_VERBOSE)
585  if(CPACK_IFW_FRAMEWORK_VERSION AND CPACK_IFW_FRAMEWORK_VERSION_FORCED)
586    message(STATUS "Found QtIFW ${CPACK_IFW_FRAMEWORK_VERSION} (forced) version")
587  elseif(CPACK_IFW_FRAMEWORK_VERSION)
588    message(STATUS "Found QtIFW ${CPACK_IFW_FRAMEWORK_VERSION} version")
589  endif()
590endif()
591if(CPACK_IFW_INSTALLERBASE_EXECUTABLE AND NOT CPACK_IFW_FRAMEWORK_VERSION)
592  message(WARNING "Could not detect QtIFW tools version. Set used version to variable \"CPACK_IFW_FRAMEWORK_VERSION_FORCED\" manually.")
593endif()
594
595#=============================================================================
596# Macro definition
597#=============================================================================
598
599# Macro definition based on CPackComponent
600
601if(NOT CPackComponent_CMake_INCLUDED)
602    include(CPackComponent)
603endif()
604
605# Resolve full filename for script file
606macro(_cpack_ifw_resolve_script _variable)
607  set(_ifw_script_macro ${_variable})
608  set(_ifw_script_file ${${_ifw_script_macro}})
609  if(DEFINED ${_ifw_script_macro})
610    get_filename_component(${_ifw_script_macro} ${_ifw_script_file} ABSOLUTE)
611    set(_ifw_script_file ${${_ifw_script_macro}})
612    if(NOT EXISTS ${_ifw_script_file})
613      message(WARNING "CPack IFW: script file \"${_ifw_script_file}\" does not exist")
614      set(${_ifw_script_macro})
615    endif()
616  endif()
617endmacro()
618
619# Resolve full path to license file
620macro(_cpack_ifw_resolve_lisenses _variable)
621  if(${_variable})
622    set(_ifw_license_file FALSE)
623    set(_ifw_licenses_fix)
624    foreach(_ifw_licenses_arg ${${_variable}})
625      if(_ifw_license_file)
626        get_filename_component(_ifw_licenses_arg "${_ifw_licenses_arg}" ABSOLUTE)
627        set(_ifw_license_file FALSE)
628      else()
629        set(_ifw_license_file TRUE)
630      endif()
631      list(APPEND _ifw_licenses_fix "${_ifw_licenses_arg}")
632    endforeach(_ifw_licenses_arg)
633    set(${_variable} "${_ifw_licenses_fix}")
634  endif()
635endmacro()
636
637# Resolve full path to a list of provided files
638macro(_cpack_ifw_resolve_file_list _variable)
639  if(${_variable})
640    set(_ifw_list_fix)
641    foreach(_ifw_file_arg ${${_variable}})
642      get_filename_component(_ifw_file_arg "${_ifw_file_arg}" ABSOLUTE)
643      if(EXISTS ${_ifw_file_arg})
644        list(APPEND _ifw_list_fix "${_ifw_file_arg}")
645      else()
646        message(WARNING "CPack IFW: page file \"${_ifw_file_arg}\" does not exist. Skipping")
647      endif()
648    endforeach(_ifw_file_arg)
649    set(${_variable} "${_ifw_list_fix}")
650  endif()
651endmacro()
652
653# Macro for configure component
654macro(cpack_ifw_configure_component compname)
655
656  string(TOUPPER ${compname} _CPACK_IFWCOMP_UNAME)
657
658  set(_IFW_OPT COMMON ESSENTIAL VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS)
659  set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT CHECKABLE)
660  set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS REPLACES)
661  cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
662
663  _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT)
664  _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_LICENSES)
665  _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_USER_INTERFACES)
666  _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_TRANSLATIONS)
667
668  set(_CPACK_IFWCOMP_STR "\n# Configuration for IFW component \"${compname}\"\n")
669
670  foreach(_IFW_ARG_NAME ${_IFW_OPT})
671  cpack_append_option_set_command(
672    CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_${_IFW_ARG_NAME}
673    _CPACK_IFWCOMP_STR)
674  endforeach()
675
676  foreach(_IFW_ARG_NAME ${_IFW_ARGS})
677  cpack_append_string_variable_set_command(
678    CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_${_IFW_ARG_NAME}
679    _CPACK_IFWCOMP_STR)
680  endforeach()
681
682  foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
683  cpack_append_list_variable_set_command(
684    CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_${_IFW_ARG_NAME}
685    _CPACK_IFWCOMP_STR)
686  endforeach()
687
688  if(CPack_CMake_INCLUDED)
689    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWCOMP_STR}")
690  endif()
691
692endmacro()
693
694# Macro for configure group
695macro(cpack_ifw_configure_component_group grpname)
696
697  string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME)
698
699  set(_IFW_OPT VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS)
700  set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT CHECKABLE)
701  set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS REPLACES)
702  cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
703
704  _cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_SCRIPT)
705  _cpack_ifw_resolve_lisenses(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_LICENSES)
706  _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_USER_INTERFACES)
707  _cpack_ifw_resolve_file_list(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_TRANSLATIONS)
708
709  set(_CPACK_IFWGRP_STR "\n# Configuration for IFW component group \"${grpname}\"\n")
710
711  foreach(_IFW_ARG_NAME ${_IFW_OPT})
712  cpack_append_option_set_command(
713    CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME}
714    _CPACK_IFWGRP_STR)
715  endforeach()
716
717  foreach(_IFW_ARG_NAME ${_IFW_ARGS})
718  cpack_append_string_variable_set_command(
719    CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME}
720    _CPACK_IFWGRP_STR)
721  endforeach()
722
723  foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
724  cpack_append_list_variable_set_command(
725    CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME}
726    _CPACK_IFWGRP_STR)
727  endforeach()
728
729  if(CPack_CMake_INCLUDED)
730    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWGRP_STR}")
731  endif()
732endmacro()
733
734# Macro for adding repository
735macro(cpack_ifw_add_repository reponame)
736
737  string(TOUPPER ${reponame} _CPACK_IFWREPO_UNAME)
738
739  set(_IFW_OPT DISABLED)
740  set(_IFW_ARGS URL USERNAME PASSWORD DISPLAY_NAME)
741  set(_IFW_MULTI_ARGS)
742  cmake_parse_arguments(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
743
744  set(_CPACK_IFWREPO_STR "\n# Configuration for IFW repository \"${reponame}\"\n")
745
746  foreach(_IFW_ARG_NAME ${_IFW_OPT})
747  cpack_append_option_set_command(
748    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
749    _CPACK_IFWREPO_STR)
750  endforeach()
751
752  foreach(_IFW_ARG_NAME ${_IFW_ARGS})
753  cpack_append_string_variable_set_command(
754    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
755    _CPACK_IFWREPO_STR)
756  endforeach()
757
758  foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
759  cpack_append_variable_set_command(
760    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
761    _CPACK_IFWREPO_STR)
762  endforeach()
763
764  list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})
765  string(APPEND _CPACK_IFWREPO_STR "list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n")
766
767  if(CPack_CMake_INCLUDED)
768    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWREPO_STR}")
769  endif()
770
771endmacro()
772
773# Macro for updating repository
774macro(cpack_ifw_update_repository reponame)
775
776  string(TOUPPER ${reponame} _CPACK_IFWREPO_UNAME)
777
778  set(_IFW_OPT ADD REMOVE REPLACE DISABLED)
779  set(_IFW_ARGS URL OLD_URL NEW_URL USERNAME PASSWORD DISPLAY_NAME)
780  set(_IFW_MULTI_ARGS)
781  cmake_parse_arguments(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
782
783  set(_CPACK_IFWREPO_STR "\n# Configuration for IFW repository \"${reponame}\" update\n")
784
785  foreach(_IFW_ARG_NAME ${_IFW_OPT})
786  cpack_append_option_set_command(
787    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
788    _CPACK_IFWREPO_STR)
789  endforeach()
790
791  foreach(_IFW_ARG_NAME ${_IFW_ARGS})
792  cpack_append_string_variable_set_command(
793    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
794    _CPACK_IFWREPO_STR)
795  endforeach()
796
797  foreach(_IFW_ARG_NAME ${_IFW_MULTI_ARGS})
798  cpack_append_variable_set_command(
799    CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_${_IFW_ARG_NAME}
800    _CPACK_IFWREPO_STR)
801  endforeach()
802
803  if(CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_ADD
804    OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REMOVE
805    OR CPACK_IFW_REPOSITORY_${_CPACK_IFWREPO_UNAME}_REPLACE)
806    list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})
807    string(APPEND _CPACK_IFWREPO_STR "list(APPEND CPACK_IFW_REPOSITORIES_ALL ${reponame})\n")
808  else()
809    set(_CPACK_IFWREPO_STR)
810  endif()
811
812  if(CPack_CMake_INCLUDED AND _CPACK_IFWREPO_STR)
813    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWREPO_STR}")
814  endif()
815
816endmacro()
817
818# Macro for adding resources
819macro(cpack_ifw_add_package_resources)
820  set(_CPACK_IFW_PACKAGE_RESOURCES ${ARGV})
821  _cpack_ifw_resolve_file_list(_CPACK_IFW_PACKAGE_RESOURCES)
822  list(APPEND CPACK_IFW_PACKAGE_RESOURCES ${_CPACK_IFW_PACKAGE_RESOURCES})
823  set(_CPACK_IFWQRC_STR "list(APPEND CPACK_IFW_PACKAGE_RESOURCES \"${_CPACK_IFW_PACKAGE_RESOURCES}\")\n")
824  if(CPack_CMake_INCLUDED)
825    file(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${_CPACK_IFWQRC_STR}")
826  endif()
827endmacro()
828
829# Resolve package control script
830_cpack_ifw_resolve_script(CPACK_IFW_PACKAGE_CONTROL_SCRIPT)
831
832endif() # NOT CPackIFW_CMake_INCLUDED
833