wix.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. CPack WIX Generator
  2. -------------------
  3. Use the `WiX Toolset`_ to produce a Windows Installer ``.msi`` database.
  4. .. _`WiX Toolset`: https://www.firegiant.com/wixtoolset/
  5. .. versionadded:: 3.7
  6. The :variable:`CPACK_COMPONENT_<compName>_DISABLED` variable is now
  7. supported.
  8. WiX Toolsets
  9. ^^^^^^^^^^^^
  10. CPack selects one of the following variants of the WiX Toolset
  11. based on the :variable:`CPACK_WIX_VERSION` variable:
  12. * `WiX .NET Tools`_
  13. * `WiX Toolset v3`_
  14. WiX .NET Tools
  15. """"""""""""""
  16. Packaging is performed using the following tools:
  17. ``wix build``
  18. Build WiX source files directly into a Windows Installer ``.msi`` database.
  19. Invocations may be customized using tool-specific variables:
  20. * :variable:`CPACK_WIX_BUILD_EXTENSIONS <CPACK_WIX_<TOOL>_EXTENSIONS>`
  21. * :variable:`CPACK_WIX_BUILD_EXTRA_FLAGS <CPACK_WIX_<TOOL>_EXTRA_FLAGS>`
  22. WiX extensions must be named with the form ``WixToolset.<Name>.wixext``.
  23. CPack expects the ``wix`` .NET tool to be available for command-line use
  24. with any required WiX extensions already installed. Be sure the ``wix``
  25. version is compatible with :variable:`CPACK_WIX_VERSION`, and that WiX
  26. extension versions match the ``wix`` tool version. For example:
  27. 1. Install the ``wix`` command-line tool using ``dotnet``.
  28. To install ``wix`` globally for the current user:
  29. .. code-block:: bat
  30. dotnet tool install --global wix --version 4.0.4
  31. This places ``wix.exe`` in ``%USERPROFILE%\.dotnet\tools`` and adds
  32. the directory to the current user's ``PATH`` environment variable.
  33. Or, to install ``wix`` in a specific path, e.g., in ``c:\WiX``:
  34. .. code-block:: bat
  35. dotnet tool install --tool-path c:\WiX wix --version 4.0.4
  36. This places ``wix.exe`` in ``c:\WiX``, but does *not* add it to the
  37. current user's ``PATH`` environment variable. The ``WIX`` environment
  38. variable may be set to tell CPack where to find the tool,
  39. e.g., ``set WIX=c:\WiX``.
  40. 2. Add the WiX ``UI`` extension, needed by CPack's default WiX template:
  41. .. code-block:: bat
  42. wix extension add --global WixToolset.UI.wixext/4.0.4
  43. Extensions added globally are stored in ``%USERPROFILE%\.wix``, or if the
  44. ``WIX_EXTENSIONS`` environment variable is set, in ``%WIX_EXTENSIONS%\.wix``.
  45. WiX Toolset v3
  46. """"""""""""""
  47. Packaging is performed using the following tools:
  48. ``candle``
  49. Compiles WiX source files into ``.wixobj`` files.
  50. Invocations may be customized using tool-specific variables:
  51. * :variable:`CPACK_WIX_CANDLE_EXTENSIONS <CPACK_WIX_<TOOL>_EXTENSIONS>`
  52. * :variable:`CPACK_WIX_CANDLE_EXTRA_FLAGS <CPACK_WIX_<TOOL>_EXTRA_FLAGS>`
  53. ``light``
  54. Links ``.wixobj`` files into a Windows Installer ``.msi`` database.
  55. Invocations may be customized using tool-specific variables:
  56. * :variable:`CPACK_WIX_LIGHT_EXTENSIONS <CPACK_WIX_<TOOL>_EXTENSIONS>`
  57. * :variable:`CPACK_WIX_LIGHT_EXTRA_FLAGS <CPACK_WIX_<TOOL>_EXTRA_FLAGS>`
  58. CPack invokes both tools as needed. Intermediate ``.wixobj`` files
  59. are considered implementation details.
  60. WiX extensions must be named with the form ``Wix<Name>Extension``.
  61. CPack expects the above tools to be available for command-line
  62. use via the ``PATH``. Or, if the ``WIX`` environment variable is set,
  63. CPack looks for the tools in ``%WIX%`` and ``%WIX%\bin``.
  64. Variables specific to CPack WIX generator
  65. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  66. The following variables are specific to the installers built on
  67. Windows using WiX.
  68. .. variable:: CPACK_WIX_VERSION
  69. .. versionadded:: 3.30
  70. Specify the version of WiX Toolset for which the configuration
  71. is written. The value must be one of
  72. ``4``
  73. Package using `WiX .NET Tools`_.
  74. ``3``
  75. Package using `WiX Toolset v3`_. This is the default.
  76. .. variable:: CPACK_WIX_UPGRADE_GUID
  77. Upgrade GUID (``Product/@UpgradeCode``)
  78. Will be automatically generated unless explicitly provided.
  79. It should be explicitly set to a constant generated globally unique
  80. identifier (GUID) to allow your installers to replace existing
  81. installations that use the same GUID.
  82. You may for example explicitly set this variable in your
  83. CMakeLists.txt to the value that has been generated per default. You
  84. should not use GUIDs that you did not generate yourself or which may
  85. belong to other projects.
  86. A GUID shall have the following fixed length syntax::
  87. XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  88. (each X represents an uppercase hexadecimal digit)
  89. .. variable:: CPACK_WIX_PRODUCT_GUID
  90. Product GUID (``Product/@Id``)
  91. Will be automatically generated unless explicitly provided.
  92. If explicitly provided this will set the Product Id of your installer.
  93. The installer will abort if it detects a pre-existing installation that
  94. uses the same GUID.
  95. The GUID shall use the syntax described for CPACK_WIX_UPGRADE_GUID.
  96. .. variable:: CPACK_WIX_LICENSE_RTF
  97. RTF License File
  98. If CPACK_RESOURCE_FILE_LICENSE has an .rtf extension it is used as-is.
  99. If CPACK_RESOURCE_FILE_LICENSE has an .txt extension it is implicitly
  100. converted to RTF by the WIX Generator.
  101. The expected encoding of the .txt file is UTF-8.
  102. With CPACK_WIX_LICENSE_RTF you can override the license file used by the
  103. WIX Generator in case CPACK_RESOURCE_FILE_LICENSE is in an unsupported
  104. format or the .txt -> .rtf conversion does not work as expected.
  105. .. variable:: CPACK_WIX_PRODUCT_ICON
  106. The Icon shown next to the program name in Add/Remove programs.
  107. If set, this icon is used in place of the default icon.
  108. .. variable:: CPACK_WIX_UI_REF
  109. Specify the WiX ``UI`` extension's dialog set:
  110. * With `WiX .NET Tools`_, this is the Id of the
  111. ``<ui:WixUI>`` element in the default WiX template.
  112. * With `WiX Toolset v3`_, this is the Id of the
  113. ``<UIRef>`` element in the default WiX template.
  114. The default is ``WixUI_InstallDir`` in case no CPack components have
  115. been defined and ``WixUI_FeatureTree`` otherwise.
  116. .. variable:: CPACK_WIX_UI_BANNER
  117. The bitmap will appear at the top of all installer pages other than the
  118. welcome and completion dialogs.
  119. If set, this image will replace the default banner image.
  120. This image must be 493 by 58 pixels.
  121. .. variable:: CPACK_WIX_UI_DIALOG
  122. Background bitmap used on the welcome and completion dialogs.
  123. If this variable is set, the installer will replace the default dialog
  124. image.
  125. This image must be 493 by 312 pixels.
  126. .. variable:: CPACK_WIX_PROGRAM_MENU_FOLDER
  127. Start menu folder name for launcher.
  128. If this variable is not set, it will be initialized with CPACK_PACKAGE_NAME
  129. .. versionadded:: 3.16
  130. If this variable is set to ``.``, then application shortcuts will be
  131. created directly in the start menu and the uninstaller shortcut will be
  132. omitted.
  133. .. variable:: CPACK_WIX_CULTURES
  134. Language(s) of the installer
  135. Languages are compiled into the Wix ``UI`` extension library. To use them,
  136. simply provide the name of the culture. If you specify more than one
  137. culture identifier in a comma or semicolon delimited list, the first one
  138. that is found will be used. You can find a list of supported languages at:
  139. https://docs.firegiant.com/wix3/wixui/wixui_localization/
  140. .. variable:: CPACK_WIX_TEMPLATE
  141. Template file for WiX generation
  142. If this variable is set, the specified template will be used to generate
  143. the WiX wxs file. This should be used if further customization of the
  144. output is required. The template contents will override the effect of most
  145. ``CPACK_WIX_`` variables.
  146. If this variable is not set, the default MSI template included with CMake
  147. will be used.
  148. .. variable:: CPACK_WIX_PATCH_FILE
  149. Optional list of XML files with fragments to be inserted into
  150. generated WiX sources.
  151. .. versionadded:: 3.5
  152. Support listing multiple patch files.
  153. This optional variable can be used to specify an XML file that the
  154. WIX generator will use to inject fragments into its generated
  155. source files.
  156. Patch files understood by the CPack WIX generator
  157. roughly follow this RELAX NG compact schema:
  158. .. code-block:: none
  159. start = CPackWiXPatch
  160. CPackWiXPatch = element CPackWiXPatch { CPackWiXFragment* }
  161. CPackWiXFragment = element CPackWiXFragment
  162. {
  163. attribute Id { string },
  164. fragmentContent*
  165. }
  166. fragmentContent = element * - CPackWiXFragment
  167. {
  168. (attribute * { text } | text | fragmentContent)*
  169. }
  170. Currently fragments can be injected into most
  171. Component, File, Directory and Feature elements.
  172. .. versionadded:: 3.3
  173. The following additional special Ids can be used:
  174. * ``#PRODUCT`` for the ``<Product>`` element.
  175. * ``#PRODUCTFEATURE`` for the root ``<Feature>`` element.
  176. .. versionadded:: 3.7
  177. Support patching arbitrary ``<Feature>`` elements.
  178. .. versionadded:: 3.9
  179. Allow setting additional attributes.
  180. The following example illustrates how this works.
  181. Given that the WIX generator creates the following XML element:
  182. .. code-block:: xml
  183. <Component Id="CM_CP_applications.bin.my_libapp.exe" Guid="*"/>
  184. The following XML patch file may be used to inject an Environment element
  185. into it:
  186. .. code-block:: xml
  187. <CPackWiXPatch>
  188. <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe">
  189. <Environment Id="MyEnvironment" Action="set"
  190. Name="MyVariableName" Value="MyVariableValue"/>
  191. </CPackWiXFragment>
  192. </CPackWiXPatch>
  193. .. variable:: CPACK_WIX_EXTRA_SOURCES
  194. Extra WiX source files
  195. This variable provides an optional list of extra WiX source files (``.wxs``)
  196. that should be compiled and linked. The paths must be absolute.
  197. .. variable:: CPACK_WIX_EXTRA_OBJECTS
  198. Extra WiX object files or libraries to use with `WiX Toolset v3`_.
  199. This variable provides an optional list of extra WiX object (``.wixobj``)
  200. and/or WiX library (``.wixlib``) files. The paths must be absolute.
  201. .. variable:: CPACK_WIX_EXTENSIONS
  202. Specify a list of additional extensions for WiX tools.
  203. See `WiX Toolsets`_ for extension naming patterns.
  204. .. variable:: CPACK_WIX_<TOOL>_EXTENSIONS
  205. Specify a list of additional extensions for a specific WiX tool.
  206. See `WiX Toolsets`_ for possible ``<TOOL>`` names.
  207. .. variable:: CPACK_WIX_<TOOL>_EXTRA_FLAGS
  208. Specify a list of additional command-line flags for a specific WiX tool.
  209. See `WiX Toolsets`_ for possible ``<TOOL>`` names.
  210. Use it at your own risk.
  211. Future versions of CPack may generate flags which may be in conflict
  212. with your own flags.
  213. .. variable:: CPACK_WIX_CMAKE_PACKAGE_REGISTRY
  214. If this variable is set the generated installer will create
  215. an entry in the windows registry key
  216. ``HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\<PackageName>``
  217. The value for ``<PackageName>`` is provided by this variable.
  218. Assuming you also install a CMake configuration file this will
  219. allow other CMake projects to find your package with
  220. the :command:`find_package` command.
  221. .. variable:: CPACK_WIX_PROPERTY_<PROPERTY>
  222. .. versionadded:: 3.1
  223. This variable can be used to provide a value for
  224. the Windows Installer property ``<PROPERTY>``
  225. The following list contains some example properties that can be used to
  226. customize information under
  227. "Programs and Features" (also known as "Add or Remove Programs")
  228. * ARPCOMMENTS - Comments
  229. * ARPHELPLINK - Help and support information URL
  230. * ARPURLINFOABOUT - General information URL
  231. * ARPURLUPDATEINFO - Update information URL
  232. * ARPHELPTELEPHONE - Help and support telephone number
  233. * ARPSIZE - Size (in kilobytes) of the application
  234. .. variable:: CPACK_WIX_ROOT_FEATURE_TITLE
  235. .. versionadded:: 3.7
  236. Sets the name of the root install feature in the WIX installer. Same as
  237. CPACK_COMPONENT_<compName>_DISPLAY_NAME for components.
  238. .. variable:: CPACK_WIX_ROOT_FEATURE_DESCRIPTION
  239. .. versionadded:: 3.7
  240. Sets the description of the root install feature in the WIX installer. Same as
  241. CPACK_COMPONENT_<compName>_DESCRIPTION for components.
  242. .. variable:: CPACK_WIX_SKIP_PROGRAM_FOLDER
  243. .. versionadded:: 3.7
  244. If this variable is set to true, the default install location
  245. of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly.
  246. The install location will not be located relatively below
  247. ProgramFiles or ProgramFiles64.
  248. .. note::
  249. Installers created with this feature do not take differences
  250. between the system on which the installer is created
  251. and the system on which the installer might be used into account.
  252. It is therefore possible that the installer e.g. might try to install
  253. onto a drive that is unavailable or unintended or a path that does not
  254. follow the localization or convention of the system on which the
  255. installation is performed.
  256. .. variable:: CPACK_WIX_ROOT_FOLDER_ID
  257. .. versionadded:: 3.9
  258. This variable allows specification of a custom root folder ID.
  259. The generator specific ``<64>`` token can be used for
  260. folder IDs that come in 32-bit and 64-bit variants.
  261. In 32-bit builds the token will expand empty while in 64-bit builds
  262. it will expand to ``64``.
  263. When unset generated installers will default installing to
  264. ``ProgramFiles<64>Folder``.
  265. .. variable:: CPACK_WIX_ROOT
  266. This variable can optionally be set to the root directory
  267. of a custom WiX Toolset installation.
  268. When unspecified CPack will try to locate a WiX Toolset
  269. installation via the ``WIX`` environment variable instead.
  270. .. variable:: CPACK_WIX_CUSTOM_XMLNS
  271. .. versionadded:: 3.19
  272. This variable provides a list of custom namespace declarations that are necessary
  273. for using WiX extensions. Each declaration should be in the form name=url, where
  274. name is the plain namespace without the usual xmlns: prefix and url is an unquoted
  275. namespace url. A list of commonly known WiX schemata can be found here:
  276. https://docs.firegiant.com/wix3/xsd/
  277. .. variable:: CPACK_WIX_SKIP_WIX_UI_EXTENSION
  278. .. versionadded:: 3.23
  279. If this variable is set to true, the default inclusion of the WiX ``UI``
  280. extension is skipped, i.e., the ``-ext WixUIExtension`` or
  281. ``-ext WixToolset.UI.wixext`` flag is not passed to WiX tools.
  282. .. variable:: CPACK_WIX_ARCHITECTURE
  283. .. versionadded:: 3.24
  284. This variable can be optionally set to specify the target architecture
  285. of the installer. May for example be set to ``x64`` or ``arm64``.
  286. When unspecified, CPack will default to ``x64`` or ``x86``.
  287. .. variable:: CPACK_WIX_INSTALL_SCOPE
  288. .. versionadded:: 3.29
  289. This variable can be optionally set to specify the ``InstallScope``
  290. of the installer:
  291. ``perMachine``
  292. Create an installer that installs for all users and requires
  293. administrative privileges. Start menu entries created by the
  294. installer are visible to all users.
  295. This is the default. See policy :policy:`CMP0172`.
  296. ``perUser``
  297. Not yet supported. This is reserved for future use.
  298. ``NONE``
  299. Create an installer without any ``InstallScope`` attribute.
  300. This is supported only if :variable:`CPACK_WIX_VERSION` is not set,
  301. or is set to ``3``.
  302. .. deprecated:: 3.29
  303. This value is only for compatibility with the inconsistent behavior used
  304. by CPack 3.28 and older. The resulting installer requires administrative
  305. privileges and installs into the system-wide ``ProgramFiles`` directory,
  306. but the start menu entry and uninstaller registration are created only
  307. for the current user.
  308. .. warning::
  309. An installation performed by an installer created without any
  310. ``InstallScope`` cannot be cleanly updated or replaced by an
  311. installer with an ``InstallScope``. In order to transition
  312. a project's installers from ``NONE`` to ``perMachine``, the
  313. latter installer should be distributed with instructions to
  314. first manually uninstall any older version.
  315. See https://docs.firegiant.com/wix3/xsd/wix/package/
  316. .. variable:: CPACK_WIX_CAB_PER_COMPONENT
  317. .. versionadded:: 4.2
  318. If this variable is set to true one ``.cab`` file per component is created.
  319. The default is to create a single ``.cab`` file for all files in the installer.
  320. WiX creates ``.cab`` files in parallel so multiple ``.cab`` files may be
  321. desirable for faster packaging.