wix.rst 12 KB

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