innosetup.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. CPack Inno Setup Generator
  2. --------------------------
  3. .. versionadded:: 3.27
  4. Inno Setup is a free installer for Windows programs by Jordan Russell and
  5. Martijn Laan (https://jrsoftware.org/isinfo.php).
  6. This documentation explains Inno Setup generator specific options.
  7. The generator provides a lot of options like components. Unfortunately, not
  8. all features (e.g. component dependencies) are currently supported by
  9. Inno Setup and they're ignored by the generator for now.
  10. CPack requires Inno Setup 6 or greater.
  11. .. versionadded:: 3.30
  12. The generator is now available on non-Windows hosts,
  13. but requires Wine to run the Inno Setup tools.
  14. Variables specific to CPack Inno Setup generator
  15. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  16. You can use the following variables to change the behavior of the CPack
  17. ``INNOSETUP`` generator:
  18. General
  19. """""""
  20. None of the following variables is required to be set for the Inno Setup
  21. generator to work. If a variable is marked as mandatory below but not set,
  22. its default value is taken.
  23. The variables can also contain Inno Setup constants like ``{app}``. Please
  24. refer to the documentation of Inno Setup for more information.
  25. If you're asked to provide the path to any file, you can always give an
  26. absolute path or in most cases the relative path from the top-level directory
  27. where all files being installed by an :command:`install` instruction reside.
  28. CPack tries to escape quotes and other special characters for you. However,
  29. using special characters could cause problems.
  30. The following variable simplifies the usage of Inno Setup in CMake:
  31. .. variable:: CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT
  32. Inno Setup only uses ``yes`` or ``no`` as boolean formats meanwhile CMake
  33. uses a lot of alternative formats like ``ON`` or ``OFF``. Having this option
  34. turned on enables an automatic conversion.
  35. Consider the following example:
  36. .. code-block:: cmake
  37. set(CMAKE_INNOSETUP_SETUP_AllowNoIcons OFF)
  38. If this option is turned on, the following line will be created in the output
  39. script: ``AllowNoIcons=no``.
  40. Else, the following erroneous line will be created: ``AllowNoIcons=OFF``
  41. The conversion is enabled in every Inno Setup specific variable.
  42. :Mandatory: Yes
  43. :Default: ``ON``
  44. Setup Specific Variables
  45. """"""""""""""""""""""""
  46. .. variable:: CPACK_INNOSETUP_ARCHITECTURE
  47. One of ``x86``, ``x64``, ``arm64`` or ``ia64``. This variable specifies the
  48. target architecture of the installer. This also affects the Program Files
  49. folder or registry keys being used.
  50. CPack tries to determine the correct value with a try compile (see
  51. :variable:`CMAKE_SIZEOF_VOID_P`), but this option can be manually specified
  52. too (especially when using ``ia64`` or cross-platform compilation).
  53. :Mandatory: Yes
  54. :Default: Either ``x86`` or ``x64`` depending on the results of the try-compile
  55. .. variable:: CPACK_INNOSETUP_INSTALL_ROOT
  56. If you don't want the installer to create the installation directory under
  57. Program Files, you've to specify the installation root here.
  58. The full directory of the installation will be:
  59. ``${CPACK_INNOSETUP_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY}``.
  60. :Mandatory: Yes
  61. :Default: ``{autopf}``
  62. .. variable:: CPACK_INNOSETUP_ALLOW_CUSTOM_DIRECTORY
  63. If turned on, the installer allows the user to change the installation
  64. directory providing an extra wizard page.
  65. :Mandatory: Yes
  66. :Default: ``ON``
  67. .. variable:: CPACK_INNOSETUP_PROGRAM_MENU_FOLDER
  68. The initial name of the start menu folder being created.
  69. If this variable is set to ``.``, then no separate folder is created,
  70. application shortcuts will appear in the top-level start menu folder.
  71. :Mandatory: Yes
  72. :Default: The value of :variable:`CPACK_PACKAGE_NAME`
  73. .. variable:: CPACK_INNOSETUP_LANGUAGES
  74. A :ref:`semicolon-separated list <CMake Language Lists>` of languages you want
  75. Inno Setup to include.
  76. Currently available: ``armenian``, ``brazilianPortuguese``, ``bulgarian``,
  77. ``catalan``, ``corsican``, ``czech``, ``danish``, ``dutch``, ``english``,
  78. ``finnish``, ``french``, ``german``, ``hebrew``, ``icelandic``, ``italian``,
  79. ``japanese``, ``norwegian``, ``polish``, ``portuguese``, ``russian``,
  80. ``slovak``, ``slovenian``, ``spanish``, ``turkish`` and ``ukrainian``.
  81. This list might differ depending on the version of Inno Setup.
  82. :Mandatory: Yes
  83. :Default: ``english``
  84. .. variable:: CPACK_INNOSETUP_IGNORE_LICENSE_PAGE
  85. If you don't specify a license file using
  86. :variable:`CPACK_RESOURCE_FILE_LICENSE`, CPack uses a file for demonstration
  87. purposes. If you want the installer to ignore license files at all, you can
  88. enable this option.
  89. :Mandatory: Yes
  90. :Default: ``OFF``
  91. .. variable:: CPACK_INNOSETUP_IGNORE_README_PAGE
  92. If you don't specify a readme file using
  93. :variable:`CPACK_RESOURCE_FILE_README`, CPack uses a file for demonstration
  94. purposes. If you want the installer to ignore readme files at all, you can
  95. enable this option. Make sure the option is disabled when using
  96. a custom readme file.
  97. :Mandatory: Yes
  98. :Default: ``ON``
  99. .. variable:: CPACK_INNOSETUP_PASSWORD
  100. Enables password protection and file encryption with the given password.
  101. :Mandatory: No
  102. .. variable:: CPACK_INNOSETUP_USE_MODERN_WIZARD
  103. Enables the modern look and feel provided by Inno Setup. If this option is
  104. turned off, the classic style is used instead. Images and icon files are
  105. also affected.
  106. :Mandatory: Yes
  107. :Default: ``OFF`` because of compatibility reasons
  108. .. variable:: CPACK_INNOSETUP_ICON_FILE
  109. The path to a custom installer ``.ico`` file.
  110. Use :variable:`CPACK_PACKAGE_ICON` to customize the bitmap file being shown
  111. in the wizard.
  112. :Mandatory: No
  113. .. variable:: CPACK_INNOSETUP_SETUP_<directive>
  114. This group allows adapting any of the ``[Setup]`` section directives provided
  115. by Inno Setup where ``directive`` is its name.
  116. Here are some examples:
  117. .. code-block:: cmake
  118. set(CPACK_INNOSETUP_SETUP_WizardSmallImageFile "my_bitmap.bmp")
  119. set(CPACK_INNOSETUP_SETUP_AllowNoIcons OFF) # This requires CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT to be on
  120. All of these variables have higher priority than the others.
  121. Consider the following example:
  122. .. code-block:: cmake
  123. set(CPACK_INNOSETUP_SETUP_Password "admin")
  124. set(CPACK_INNOSETUP_PASSWORD "secret")
  125. The password will be ``admin`` at the end because ``CPACK_INNOSETUP_PASSWORD``
  126. has less priority than ``CPACK_INNOSETUP_SETUP_Password``.
  127. :Mandatory: No
  128. File Specific Variables
  129. """""""""""""""""""""""
  130. Although all files being installed by an :command:`install` instruction are
  131. automatically processed and added to the installer, there are some variables
  132. to customize the installation process.
  133. Before using executables (only ``.exe`` or ``.com``) in shortcuts
  134. (e.g. :variable:`CPACK_CREATE_DESKTOP_LINKS`) or ``[Run]`` entries, you've to
  135. add the raw file name (without path and extension) to
  136. :variable:`CPACK_PACKAGE_EXECUTABLES` and create a start menu shortcut
  137. for them.
  138. If you have two files with the same raw name (e.g. ``a/executable.exe`` and
  139. ``b/executable.com``), an entry in the section is created twice. This will
  140. result in undefined behavior and is not recommended.
  141. .. variable:: CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS
  142. This variable should contain a
  143. :ref:`semicolon-separated list <CMake Language Lists>` of pairs ``path``,
  144. ``instruction`` and can be used to customize the install command being
  145. automatically created for each file or directory.
  146. CPack creates the following Inno Setup instruction for every file...
  147. .. code-block::
  148. Source: "absolute\path\to\my_file.txt"; DestDir: "{app}"; Flags: ignoreversion
  149. ...and the following line for every directory:
  150. .. code-block::
  151. Name: "{app}\my_folder"
  152. You might want to change the destination directory or the flags of
  153. ``my_file.txt``. Since we can also provide a relative path, the line you'd
  154. like to have, is the following:
  155. .. code-block::
  156. Source: "my_file.txt"; DestDir: "{userdocs}"; Flags: ignoreversion uninsneveruninstall
  157. You would do this by using ``my_file.txt`` as ``path`` and
  158. ``Source: "my_file.txt"; DestDir: "{userdocs}"; Flags: ignoreversion uninsneveruninstall``
  159. as ``instruction``.
  160. You've to take care of the `escaping problem <https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html#adding-custom-cpack-options>`_.
  161. So the CMake command would be:
  162. .. code-block:: cmake
  163. set(CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS "my_file.txt;Source: \\\"my_file.txt\\\"\\; DestDir: \\\"{userdocs}\\\"\\; Flags: ignoreversion uninsneveruninstall")
  164. To improve readability, you should go around the escaping problem by using
  165. :variable:`CPACK_VERBATIM_VARIABLES` or by placing the instruction into a
  166. separate CPack project config file.
  167. If you customize the install instruction of a specific file, you lose the
  168. connection to its component. To go around, manually add
  169. ``Components: <component>``. You also need to add its shortcuts and ``[Run]``
  170. entries by yourself in a custom section, since the executable won't be found
  171. anymore by :variable:`CPACK_PACKAGE_EXECUTABLES`.
  172. Here's another example (Note: You've to go around the escaping problem for
  173. the example to work):
  174. .. code-block:: cmake
  175. set(CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS
  176. "component1/my_folder" "Name: \"{userdocs}\\my_folder\"\; Components: component1"
  177. "component2/my_folder2/my_file.txt" "Source: \"component2\\my_folder2\\my_file.txt\"\; DestDir: \"{app}\\my_folder2\\my_file.txt\"\; Flags: ignoreversion uninsneveruninstall\; Components: component2")
  178. :Mandatory: No
  179. .. variable:: CPACK_INNOSETUP_MENU_LINKS
  180. This variable should contain a
  181. :ref:`semicolon-separated list <CMake Language Lists>` of pairs ``link``,
  182. ``link name`` and can be used to add shortcuts into the start menu folder
  183. beside those of the executables (see :variable:`CPACK_PACKAGE_EXECUTABLES`).
  184. While ``link name`` is the label, ``link`` can be a URL or a path relative to
  185. the installation directory.
  186. Here's an example:
  187. .. code-block:: cmake
  188. set(CPACK_INNOSETUP_MENU_LINKS
  189. "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html"
  190. "CMake Help" "https://cmake.org" "CMake Web Site")
  191. :Mandatory: No
  192. .. variable:: CPACK_INNOSETUP_CREATE_UNINSTALL_LINK
  193. If this option is turned on, a shortcut to the application's uninstaller is
  194. automatically added to the start menu folder.
  195. :Mandatory: Yes
  196. :Default: ``OFF``
  197. .. variable:: CPACK_INNOSETUP_RUN_EXECUTABLES
  198. A :ref:`semicolon-separated list <CMake Language Lists>` of executables being
  199. specified in :variable:`CPACK_PACKAGE_EXECUTABLES` which the user can run
  200. when the installer finishes.
  201. They're internally added to the ``[Run]`` section.
  202. :Mandatory: No
  203. Components Specific Variables
  204. """""""""""""""""""""""""""""
  205. The generator supports components and also downloaded components. However,
  206. there are some features of components that aren't supported yet (especially
  207. component dependencies). These variables are ignored for now.
  208. CPack will change a component's name in Inno Setup if it has a parent group
  209. for technical reasons. Consider using ``group\component`` as component name in
  210. Inno Setup scripts if you have the component ``component`` and its parent
  211. group ``group``.
  212. Here are some additional variables for components:
  213. .. variable:: CPACK_INNOSETUP_<compName>_INSTALL_DIRECTORY
  214. If you don't want the component ``compName`` to be installed under ``{app}``,
  215. you've to specify its installation directory here.
  216. :Mandatory: No
  217. .. variable:: CPACK_INNOSETUP_VERIFY_DOWNLOADS
  218. This option only affects downloaded components.
  219. If this option is turned on, the hashes of the downloaded archives are
  220. calculated during compile and
  221. download time. The installer will only proceed if they match.
  222. :Mandatory: Yes
  223. :Default: ``ON``
  224. Compilation and Scripting Specific Variables
  225. """"""""""""""""""""""""""""""""""""""""""""
  226. .. variable:: CPACK_INNOSETUP_EXECUTABLE
  227. The filename of the Inno Setup Script Compiler command.
  228. :Mandatory: Yes
  229. :Default: ``ISCC``
  230. .. variable:: CPACK_INNOSETUP_EXECUTABLE_ARGUMENTS
  231. A :ref:`semicolon-separated list <CMake Language Lists>` of extra
  232. command-line options for the Inno Setup Script Compiler command.
  233. For example: ``/Qp;/Smysigntool=$p``
  234. Take care of the `escaping problem <https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html#adding-custom-cpack-options>`_.
  235. :Mandatory: No
  236. .. variable:: CPACK_INNOSETUP_DEFINE_<macro>
  237. This group allows to add custom define directives as command-line options to
  238. the Inno Setup Preprocessor command. Each entry emulates a
  239. ``#define public <macro>`` directive. Its macro is accessible from anywhere
  240. (``public``), so it can also be used in extra script files.
  241. Macro names must not contain any special characters. Refer to the Inno Setup
  242. Preprocessor documentation for the detailed rules.
  243. Consider the following example:
  244. .. code-block:: cmake
  245. # The following line emulates: #define public MyMacro "Hello, World!"
  246. set(CPACK_INNOSETUP_DEFINE_MyMacro "Hello, World!")
  247. At this point, you can use ``MyMacro`` anywhere. For example in the following
  248. extra script:
  249. .. code-block::
  250. AppComments={#emit "'My Macro' has the value: " + MyMacro}
  251. Take care of the `escaping problem <https://cmake.org/cmake/help/book/mastering-cmake/chapter/Packaging%20With%20CPack.html#adding-custom-cpack-options>`_.
  252. :Mandatory: No
  253. .. variable:: CPACK_INNOSETUP_EXTRA_SCRIPTS
  254. A :ref:`semicolon-separated list <CMake Language Lists>` of paths to
  255. additional ``.iss`` script files to be processed.
  256. They're internally included at the top of the output script file using a
  257. ``#include`` directive.
  258. You can add any section in your file to extend the installer (e.g. adding
  259. additional tasks or registry keys). Prefer using
  260. :variable:`CPACK_INNOSETUP_SETUP_<directive>` when extending the
  261. ``[Setup]`` section.
  262. :Mandatory: No
  263. .. variable:: CPACK_INNOSETUP_CODE_FILES
  264. A :ref:`semicolon-separated list <CMake Language Lists>` of paths to
  265. additional Pascal files to be processed.
  266. This variable is actually the same as
  267. :variable:`CPACK_INNOSETUP_EXTRA_SCRIPTS`, except you don't have to
  268. add ``[Code]`` at the top of your file. Never change the current section in
  269. a code file. This will result in undefined behavior! Treat them as normal
  270. Pascal scripts instead.
  271. Code files are included at the very bottom of the output script.
  272. :Mandatory: No