├── AddQtWindowsExe.cmake ├── CMakeLists.txt ├── LICENCE.md └── README.md /AddQtWindowsExe.cmake: -------------------------------------------------------------------------------- 1 | # find the Qt root directory 2 | if(NOT Qt5Core_DIR AND NOT Qt6Core_DIR) 3 | if(NOT DEFINED QT_VERSION_MAJOR) 4 | find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) 5 | endif() 6 | elseif(Qt5Core_DIR) 7 | set(QT_VERSION_MAJOR 5) 8 | elseif(Qt6Core_DIR) 9 | set(QT_VERSION_MAJOR 6) 10 | endif() 11 | get_filename_component(QT_WINDOWS_QT_ROOT "${Qt${QT_VERSION_MAJOR}Core_DIR}/../../.." ABSOLUTE) 12 | message(STATUS "Found Qt for Windows: ${QT_WINDOWS_QT_ROOT} using Qt${QT_VERSION_MAJOR}") 13 | 14 | set(QT_WINDOWS_QT_ROOT ${QT_WINDOWS_QT_ROOT}) 15 | set(QT_WINDOWS_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) 16 | 17 | set(QBC_REPOSITORY "https://github.com/OlivierLDff/QbcInstaller.git" CACHE STRING "Repository of Qbc") 18 | set(QBC_TAG "master" CACHE STRING "Git Tag of Qbc") 19 | 20 | if(NOT COMMAND add_qt_binary_creator) 21 | include(FetchContent) 22 | 23 | # Qbc 24 | FetchContent_Declare( 25 | Qbc 26 | GIT_REPOSITORY ${QBC_REPOSITORY} 27 | GIT_TAG ${QBC_TAG} 28 | GIT_SHALLOW 1 29 | ) 30 | FetchContent_MakeAvailable(Qbc) 31 | endif() 32 | 33 | include(CMakeParseArguments) 34 | 35 | # define a function to create a Windows Exe target 36 | # 37 | # example: 38 | # add_qt_windows_exe(my_app 39 | # NAME "My App" 40 | # VERSION "1.2.3" 41 | # PUBLISHER "My Company" 42 | # PRODUCT_URL "www.myapp.com" 43 | # PACKAGE "org.mycompany.myapp" 44 | # FILE_EXTENSION "appExtension" 45 | # ICON "path/to.icon.ico" 46 | # ICON_RC "path/to.icon.rc" 47 | # QML_DIR "path/to/qmldir" 48 | # NO_TRANSLATIONS 49 | # NO_WEBENGINE 50 | # NO_OPENGL_SW 51 | # NO_ANGLE 52 | # VERBOSE 53 | # ALL 54 | #) 55 | 56 | function(add_qt_windows_exe TARGET) 57 | 58 | set(QT_WINDOWS_OPTIONS ALL 59 | NO_DEPLOY 60 | NO_INSTALLER 61 | NO_TRANSLATIONS 62 | NO_PLUGINS 63 | NO_VIRTUALKEYBOARD 64 | NO_WEBENGINE 65 | NO_ANGLE 66 | NO_OPENGL_SW 67 | VERBOSE_INSTALLER 68 | NO_QT_CONF 69 | NO_QMLTOOLING 70 | ) 71 | set(QT_WINDOWS_ONE_VALUE_ARG NAME 72 | DEPLOY_NAME 73 | INSTALLER_NAME 74 | VERSION 75 | PUBLISHER 76 | PRODUCT_URL 77 | PACKAGE 78 | RUN_PROGRAM 79 | FILE_EXTENSION 80 | ICON 81 | ICON_RC 82 | DEPENDS 83 | QML_DIR 84 | OUTPUT_TARGET 85 | OUTPUT_INSTALLER_TARGET 86 | VERBOSE_LEVEL_DEPLOY 87 | ) 88 | set(QT_WINDOWS_MULTI_VALUE_ARG) 89 | # parse the function arguments 90 | cmake_parse_arguments(ARGWIN "${QT_WINDOWS_OPTIONS}" "${QT_WINDOWS_ONE_VALUE_ARG}" "${QT_WINDOWS_MULTI_VALUE_ARG}" ${ARGN}) 91 | 92 | if(ARGWIN_VERBOSE_LEVEL_DEPLOY) 93 | message(STATUS "---- QtWindowsCMake Configuration ----") 94 | message(STATUS "TARGET : ${TARGET}") 95 | message(STATUS "APP_NAME : ${ARGWIN_NAME}") 96 | message(STATUS "DEPLOY_NAME : ${ARGWIN_DEPLOY_NAME}") 97 | message(STATUS "INSTALLER_NAME : ${ARGWIN_INSTALLER_NAME}") 98 | message(STATUS "VERSION : ${ARGWIN_VERSION}") 99 | message(STATUS "PUBLISHER : ${ARGWIN_PUBLISHER}") 100 | message(STATUS "PRODUCT_URL : ${ARGWIN_PRODUCT_URL}") 101 | message(STATUS "PACKAGE : ${ARGWIN_PACKAGE}") 102 | message(STATUS "RUN_PROGRAM : ${ARGWIN_RUN_PROGRAM}") 103 | message(STATUS "FILE_EXTENSION : ${ARGWIN_FILE_EXTENSION}") 104 | message(STATUS "ICON : ${ARGWIN_ICON}") 105 | message(STATUS "ICON_RC : ${ARGWIN_ICON_RC}") 106 | message(STATUS "DEPENDS : ${ARGWIN_DEPENDS}") 107 | message(STATUS "QML_DIR : ${ARGWIN_QML_DIR}") 108 | message(STATUS "ALL : ${ARGWIN_ALL}") 109 | message(STATUS "NO_DEPLOY : ${ARGWIN_NO_DEPLOY}") 110 | message(STATUS "NO_INSTALLER : ${ARGWIN_NO_INSTALLER}") 111 | message(STATUS "NO_TRANSLATIONS : ${ARGWIN_NO_TRANSLATIONS}") 112 | message(STATUS "NO_VIRTUALKEYBOARD : ${ARGWIN_NO_VIRTUALKEYBOARD}") 113 | message(STATUS "NO_WEBENGINE : ${ARGWIN_NO_WEBENGINE}") 114 | message(STATUS "VERBOSE_LEVEL_DEPLOY : ${ARGWIN_VERBOSE_LEVEL_DEPLOY}") 115 | message(STATUS "VERBOSE_INSTALLER : ${ARGWIN_VERBOSE_INSTALLER}") 116 | message(STATUS "NO_PLUGINS : ${ARGWIN_NO_PLUGINS}") 117 | message(STATUS "NO_QT_CONF : ${ARGWIN_NO_QT_CONF}") 118 | if(QT_VERSION_MAJOR LESS_EQUAL 5) 119 | message(STATUS "NO_ANGLE : ${ARGWIN_NO_ANGLE}") 120 | endif() 121 | message(STATUS "NO_OPENGL_SW : ${ARGWIN_NO_OPENGL_SW}") 122 | message(STATUS "NO_QMLTOOLING : ${ARGWIN_NO_QMLTOOLING}") 123 | message(STATUS "---- End QtWindowsCMake Configuration ----") 124 | endif() # ARGWIN_VERBOSE_LEVEL_DEPLOY 125 | 126 | set_target_properties(${TARGET} PROPERTIES WIN32_EXECUTABLE 1) 127 | if(ARGWIN_ICON_RC) 128 | target_sources(${TARGET} PUBLIC ${ARGWIN_ICON_RC}) 129 | else(ARGWIN_ICON_RC) 130 | message(WARNING "No icon rc file specified") 131 | endif(ARGWIN_ICON_RC) 132 | 133 | # define the application name 134 | if(ARGWIN_NAME) 135 | set(QT_WINDOWS_APP_NAME ${ARGWIN_NAME}) 136 | else() 137 | set(QT_WINDOWS_APP_NAME ${TARGET}) 138 | endif() 139 | 140 | # define the application version 141 | if(ARGWIN_VERSION) 142 | set(QT_WINDOWS_APP_VERSION ${ARGWIN_VERSION}) 143 | else() 144 | if(PROJECT_VERSION) 145 | set(QT_WINDOWS_APP_VERSION ${PROJECT_VERSION}) 146 | else() 147 | set(QT_WINDOWS_APP_VERSION "1.0.0") 148 | endif() 149 | endif() 150 | 151 | # define the application package name 152 | if(ARGWIN_PACKAGE) 153 | set(QT_WINDOWS_APP_PACKAGE ${ARGWIN_PACKAGE}) 154 | else() 155 | set(QT_WINDOWS_APP_PACKAGE org.qtproject.${SOURCE_TARGET}) 156 | endif() 157 | 158 | # define the application deploy target name 159 | if(ARGWIN_DEPLOY_NAME) 160 | set(QT_WINDOWS_APP_DEPLOY_NAME ${ARGWIN_DEPLOY_NAME}) 161 | else() 162 | set(QT_WINDOWS_APP_DEPLOY_NAME ${TARGET}Deploy) 163 | endif() 164 | 165 | # ────────── DEPLOY ───────────────────────── 166 | 167 | if(NOT ARGWIN_NO_DEPLOY) 168 | 169 | # define the application qml dirs 170 | if(ARGWIN_QML_DIR) 171 | set(QT_WINDOWS_APP_QML_DIR --qmldir ${ARGWIN_QML_DIR}) 172 | endif() 173 | 174 | if(ARGWIN_NO_TRANSLATIONS) 175 | set(QT_WINDOWS_APP_NO_TRANSLATIONS --no-translations) 176 | endif() 177 | 178 | if(ARGWIN_NO_PLUGINS) 179 | set(QT_WINDOWS_APP_NO_PLUGINS --no-plugins) 180 | endif() 181 | 182 | if(ARGWIN_NO_VIRTUALKEYBOARD) 183 | set(QT_WINDOWS_APP_NO_VIRTUALKEYBOARD --no-virtualkeyboard) 184 | endif() 185 | 186 | if(ARGWIN_NO_WEBENGINE) 187 | set(QT_WINDOWS_APP_NO_WEBENGINE --no-webenginecore --no-webengine --no-webenginewidgets) 188 | endif() 189 | 190 | if(ARGWIN_NO_ANGLE AND QT_VERSION_MAJOR LESS_EQUAL 5) 191 | set(QT_WINDOWS_APP_NO_ANGLE --no-angle) 192 | endif() 193 | 194 | if(ARGWIN_NO_OPENGL_SW) 195 | set(QT_WINDOWS_APP_NO_OPENGL_SW --no-opengl-sw) 196 | endif() 197 | 198 | if(ARGWIN_ALL) 199 | set(QT_WINDOWS_ALL ALL) 200 | endif() 201 | 202 | if(ARGWIN_OUTPUT_TARGET) 203 | set(${ARGWIN_OUTPUT_TARGET} ${QT_WINDOWS_APP_DEPLOY_NAME} PARENT_SCOPE) 204 | endif() 205 | 206 | if(NOT ARGWIN_NO_QT_CONF) 207 | set(QT_WINDOWS_QT_CONF ${CMAKE_CURRENT_BINARY_DIR}/qt.conf) 208 | # windeployqt used to deploy qml files in the same folder as the executable 209 | # But with Qt6, qml files are deployed in a qml folder 210 | # Only tested with Qt5.15.2 and Qt6.6.2 211 | # Anyway with Qt6 you shouldn't use this script anymore and use the official install way 212 | if(QT_VERSION_MAJOR LESS_EQUAL 5) 213 | set(qml_import_path ".") 214 | else() 215 | set(qml_import_path "./qml") 216 | endif() 217 | file(WRITE ${QT_WINDOWS_QT_CONF} 218 | "[Paths]\n" 219 | "Plugins = .\n" 220 | "Imports = .\n" 221 | "Qml2Imports = ${qml_import_path}\n" 222 | ) 223 | endif() 224 | 225 | # Create Custom Target 226 | add_custom_target(${QT_WINDOWS_APP_DEPLOY_NAME} 227 | ${QT_WINDOWS_ALL} 228 | DEPENDS ${TARGET} ${ARGWIN_DEPENDS} 229 | COMMAND ${QT_WINDOWS_QT_ROOT}/bin/windeployqt 230 | ${QT_WINDOWS_APP_QML_DIR} 231 | ${QT_WINDOWS_APP_NO_TRANSLATIONS} 232 | ${QT_WINDOWS_APP_NO_PLUGINS} 233 | ${QT_WINDOWS_APP_NO_VIRTUALKEYBOARD} 234 | ${QT_WINDOWS_APP_NO_WEBENGINE} 235 | ${QT_WINDOWS_APP_NO_ANGLE} 236 | ${QT_WINDOWS_APP_NO_OPENGL_SW} 237 | --$<$:debug>$<$>:release> 238 | $ 239 | COMMENT "call ${QT_WINDOWS_QT_ROOT}/bin/windeployqt in folder $" 240 | ) 241 | 242 | if(NOT ARGWIN_NO_QT_CONF) 243 | add_custom_command( 244 | TARGET ${QT_WINDOWS_APP_DEPLOY_NAME} POST_BUILD 245 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_WINDOWS_QT_CONF} $/qt.conf 246 | COMMENT "Copy qt.conf to $\n" 247 | ) 248 | endif() 249 | 250 | if(ARGWIN_NO_QMLTOOLING) 251 | # Delete the qmltooling folder created by windeployqt 252 | # --no-qmltooling isn't working, even though it's in the help 253 | add_custom_command( 254 | TARGET ${QT_WINDOWS_APP_DEPLOY_NAME} POST_BUILD 255 | COMMAND ${CMAKE_COMMAND} -E remove_directory $/qmltooling 256 | COMMENT "Remove qmltooling folder in $\n" 257 | ) 258 | endif() 259 | 260 | # DEPLOY MSVC RUNTIME 261 | if(MSVC) 262 | include(InstallRequiredSystemLibraries) 263 | if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) 264 | add_custom_command(TARGET ${QT_WINDOWS_APP_DEPLOY_NAME} POST_BUILD 265 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} $ 266 | COMMENT "Deploy msvc runtime libraries : ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}\n" 267 | ) 268 | else() 269 | message(WARNING "Can't find any msvc runtime library to deploy with ${QT_WINDOWS_APP_DEPLOY_NAME}") 270 | endif() 271 | else() # MINGW 272 | 273 | add_custom_command(TARGET ${QT_WINDOWS_APP_DEPLOY_NAME} POST_BUILD 274 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_WINDOWS_QT_ROOT}/bin/libgcc_s_dw2-1.dll $ 275 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_WINDOWS_QT_ROOT}/bin/libstdc++-6.dll $ 276 | COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_WINDOWS_QT_ROOT}/bin/libwinpthread-1.dll $ 277 | COMMENT "Deploy mingw runtime libraries from ${QT_WINDOWS_QT_ROOT}/bin" 278 | ) 279 | 280 | endif() 281 | 282 | endif() 283 | 284 | # ────────── QBC INSTALLER ───────────────────────── 285 | 286 | if(NOT ARGWIN_NO_INSTALLER) 287 | 288 | if(ARGWIN_INSTALLER_NAME) 289 | set(QT_WINDOWS_INSTALLER_NAME INSTALLER_NAME ${ARGWIN_INSTALLER_NAME}) 290 | endif() 291 | 292 | if(NOT ARGWIN_NO_DEPLOY) 293 | set( QT_WINDOWS_INSTALLER_ADD_DEPLOY ${QT_WINDOWS_APP_DEPLOY_NAME}) 294 | endif() 295 | 296 | if(ARGWIN_VERBOSE_INSTALLER) 297 | set( QT_WINDOWS_VERBOSE_INSTALLER VERBOSE_INSTALLER) 298 | endif() 299 | 300 | if(ARGWIN_RUN_PROGRAM) 301 | set( QT_WINDOWS_RUN_PROGRAM RUN_PROGRAM ${ARGWIN_RUN_PROGRAM}) 302 | endif() 303 | 304 | message(STATUS "Add Qt Binary Creator Target for ${TARGET}") 305 | add_qt_binary_creator( ${TARGET} 306 | ${QT_WINDOWS_ALL} 307 | DEPENDS ${QT_WINDOWS_INSTALLER_ADD_DEPLOY} ${ARGWIN_DEPENDS} 308 | NAME ${QT_WINDOWS_APP_NAME} 309 | VERSION ${QT_WINDOWS_APP_VERSION} 310 | PRODUCT_URL ${ARGWIN_PRODUCT_URL} 311 | ${QT_WINDOWS_INSTALLER_NAME} 312 | PUBLISHER ${ARGWIN_PUBLISHER} 313 | ${QT_WINDOWS_RUN_PROGRAM} 314 | ICON ${ARGWIN_ICON} 315 | PACKAGE ${ARGWIN_PACKAGE} 316 | ${QT_WINDOWS_VERBOSE_INSTALLER} 317 | FILE_EXTENSION ${ARGWIN_FILE_EXTENSION} 318 | OUTPUT_TARGET OUTPUT_INSTALLER_TARGET 319 | ) 320 | 321 | if(ARGWIN_OUTPUT_INSTALLER_TARGET) 322 | set(${ARGWIN_OUTPUT_INSTALLER_TARGET} ${OUTPUT_INSTALLER_TARGET} PARENT_SCOPE) 323 | endif() 324 | 325 | endif() 326 | endfunction() 327 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.11) 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/AddQtWindowsExe.cmake) 4 | 5 | set(QT_WINDOWS_QT_ROOT ${QT_WINDOWS_QT_ROOT} CACHE STRING "qt sdk root folder") 6 | set(QT_WINDOWS_SOURCE_DIR ${QT_WINDOWS_SOURCE_DIR} CACHE STRING "add_qt_windows_exe CMakeLists.txt folder") 7 | 8 | set(QT_WINDOWS_CMAKE_FOUND ON CACHE BOOL "QtWindowsCMake have been found" FORCE) 9 | set(QT_WINDOWS_CMAKE_VERSION "1.5.0" CACHE STRING "QtWindowsCMake version" FORCE) 10 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | ## MIT License 2 | 3 | *Copyright (c) 2019 Olivier Le Doeuff* 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | **THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE.** -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Qt Windows CMake 2 | 3 | ## What it is 4 | 5 | This project provide a CMake macro to help you deploy Qt application on windows. It will generate a deploy target that: 6 | 7 | * Deploy dynamic Qt library near your executable file to create a self-contain application folder. 8 | * Deploy msvc or mingw c++ runtime library. 9 | 10 | It will also generate an installer project that will: 11 | 12 | * Create a win32 installer to install your application and share your application easily. 13 | 14 | The macro will call program for the qt framework. 15 | 16 | * `windeployqt` to deploy dynamic library and qml. Documentation is available [here](https://doc.qt.io/qt-5/windows-deployment.html). 17 | * `qtinstallerframework` to create installer. Documentation is available [here](https://doc.qt.io/qtinstallerframework/ifw-tools.html). 18 | * Behind the scene, the macro will call QtBinaryCreatorCMake project. 19 | 20 | This utility has been developed for my own needs. Don't hesitate to use / share / fork / modify / improve it freely :) 21 | 22 | This project is conceptually based on the great [QtAndroidCMake of Laurent Gomila](https://github.com/LaurentGomila/qt-android-cmake). 23 | 24 | ## How to use it 25 | 26 | ### How to integrate it to your CMake configuration 27 | 28 | All you have to do is to call the ```add_qt_windows_exe``` macro to create a new target that will create the Windows Deployment Targets. 29 | 30 | ```cmake 31 | if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 32 | FetchContent_Declare( 33 | QtWindowsCMake 34 | GIT_REPOSITORY "https://github.com/OlivierLDff/QtWindowsCMake" 35 | GIT_TAG master 36 | ) 37 | FetchContent_MakeAvailable(QtWindowsCMake) 38 | add_qt_windows_exe(MyApp) 39 | endif() 40 | ``` 41 | 42 | The you can simply run 43 | 44 | ```bash 45 | make MyAppDeploy 46 | make MyAppInstaller 47 | ``` 48 | 49 | Of course, ```add_qt_windows_exe``` accepts more options, see below for the detail. 50 | 51 | ### How to run CMake 52 | 53 | To build the application for windows it is required to already be on a windows machine. It is recommended to export the path as global variable. 54 | 55 | ```bash 56 | export QT_WIN_VERSION=5.12.0 57 | export QT_DIR_MINGW32=C:/Qt/$QT_WIN_VERSION/mingw53_32 58 | export QT_DIR_MINGW64=C:/Qt/$QT_WIN_VERSION/mingw53_64 59 | export QT_DIR_MSVC32=C:/Qt/$QT_WIN_VERSION1/msvc2017_32 60 | export QT_DIR_MSVC64=C:/Qt/$QT_WIN_VERSION/msvc2017_64 61 | export QT_BUILD_TYPE=Release # or export QT_BUILD_TYPE=Debug 62 | ``` 63 | 64 | **MinGw 32 bits - Make** 65 | 66 | ```bash 67 | cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MINGW32 \ 68 | -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$QT_BUILD_TYPE path/to/CMakeLists/ 69 | ``` 70 | 71 | **MinGw 64 bits - Ninja** 72 | 73 | ```bash 74 | cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MINGW64 \ 75 | -G "Ninja" -DCMAKE_BUILD_TYPE=$QT_BUILD_TYPE path/to/CMakeLists/ 76 | ``` 77 | 78 | **Msvc 32 bits *(Default)*** 79 | 80 | ```bash 81 | cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MSVC32 \ 82 | -G "Visual Studio 15 2017" path/to/CMakeLists/ 83 | ``` 84 | 85 | **Msvc 64 bits** 86 | 87 | ```bash 88 | cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MSVC64 \ 89 | -G "Visual Studio 15 2017 Win64" path/to/CMakeLists/ 90 | ``` 91 | 92 | ## Options of the ```add_qt_windows_exe``` macro 93 | 94 | The first argument is the target the macro should deploy an app for. It will automatically generate 2 targets: 95 | 96 | * `${MY_TARGET}Deploy` that deploy dynamic library and qmldir. 97 | * `${MY_TARGET}Installer` that pack and generate an installer. 98 | 99 | The macro also accepts optional named arguments. Any combination of these arguments is valid. Example: 100 | 101 | ```cmake 102 | add_qt_windows_exe(my_app 103 | NAME "My App" 104 | VERSION "1.2.3" 105 | PUBLISHER "My Company" 106 | PRODUCT_URL "www.myapp.com" 107 | PACKAGE "org.mycompany.myapp" 108 | FILE_EXTENSION "appExtension" 109 | ICON "path/to.icon.rc" 110 | ICON_RC "path/to.icon.rc" 111 | QML_DIR "path/to/qmldir" 112 | NO_TRANSLATION 113 | NO_PLUGINS 114 | NO_OPENGL_SW 115 | NO_ANGLE 116 | VERBOSE_LEVEL_DEPLOY 1 117 | VERBOSE_INSTALLER 118 | ALL 119 | ) 120 | ``` 121 | 122 | Here is the full list of possible arguments: 123 | 124 | **NAME** 125 | 126 | The name of the application. If not given, the name of the source target is taken. The default is `${TARGET}`. 127 | 128 | *Example:* 129 | 130 | ```cmake 131 | add_qt_windows_exe(MyApp 132 | NAME "My App" 133 | ) 134 | ``` 135 | 136 | **DEPLOY_NAME** 137 | 138 | Name of the deploy target. The default is `${TARGET}Deploy`. 139 | 140 | *Example:* 141 | 142 | ```cmake 143 | add_qt_windows_exe(MyApp 144 | DEPLOY_NAME "MyAppDeployName" 145 | ) 146 | ``` 147 | 148 | You can then run this target with `make MyAppDeployName` . 149 | 150 | **INSTALLER_NAME** 151 | 152 | Name of the installer target. The default is `${TARGET}InstallerX64` or `${TARGET}InstallerX32` depending is 32 bits or 64 bits is selected. 153 | 154 | *Example:* 155 | 156 | ```cmake 157 | add_qt_windows_exe(MyApp 158 | INSTALLER_NAME "MyAppInstallerName" 159 | ) 160 | ``` 161 | 162 | You can then run this target with `make MyAppInstallerName` . 163 | 164 | **VERSION** 165 | 166 | Literal version that will be displayed with the application. The default is `1.0.0`. 167 | 168 | *Example:* 169 | 170 | ```cmake 171 | add_qt_windows_exe(MyApp 172 | VERSION "1.2.3" 173 | ) 174 | ``` 175 | 176 | **PUBLISHER** 177 | 178 | Literal version that will be displayed with the application. 179 | 180 | *Example:* 181 | 182 | ```cmake 183 | add_qt_windows_exe(MyApp 184 | PUBLISHER "My Company" 185 | ) 186 | ``` 187 | 188 | **PRODUCT_URL** 189 | 190 | Literal version that will be displayed with the application. 191 | 192 | *Example:* 193 | 194 | ```cmake 195 | add_qt_windows_exe(MyApp 196 | PRODUCT_URL "www.myapp.com" 197 | ) 198 | ``` 199 | 200 | **PACKAGE** 201 | 202 | The name of the application package. If not given, `org.qtproject.${TARGET}` , where source_target is the name of the source target, is taken. 203 | 204 | *Example:* 205 | 206 | ```cmake 207 | add_qt_windows_exe(MyApp 208 | PACKAGE "org.mycompany.myapp" 209 | ) 210 | ``` 211 | 212 | **RUN_PROGRAM** 213 | 214 | The program to run with the generated shortcut on install. By default it is set to `${NAME}`. 215 | 216 | *Example:* 217 | 218 | ```cmake 219 | add_qt_windows_exe(MyApp 220 | RUN_PROGRAM "MyApp" 221 | ) 222 | ``` 223 | 224 | **FILE_EXTENSION** 225 | 226 | You can specify extension that will be associate with you app. 227 | 228 | *Example:* 229 | 230 | ```cmake 231 | add_qt_windows_exe(MyApp 232 | FILE_EXTENSION "appExtension" 233 | ) 234 | ``` 235 | 236 | **ICON** 237 | 238 | The icon that will be used for the generated installer executable 239 | 240 | *Example:* 241 | 242 | ```cmake 243 | add_qt_windows_exe(MyApp 244 | ICON "path/to/icon.ico" 245 | ) 246 | ``` 247 | 248 | **ICON_RC** 249 | 250 | The icon rc file for the application. `icon.rc` might look like this *(More info about ressources files [here](https://docs.microsoft.com/en-us/cpp/ide/resource-files-cpp?view=vs-2017))*: 251 | 252 | ``` 253 | IDI_ICON1 ICON DISCARDABLE "icon.ico" 254 | ``` 255 | 256 | And the file structure: 257 | 258 | ``` 259 | windows 260 | │ icon.rc 261 | │ icon.ico 262 | ``` 263 | 264 | *Example:* 265 | 266 | ```cmake 267 | add_qt_windows_exe(MyApp 268 | ICON_RC "path/to/icon.rc" 269 | ) 270 | ``` 271 | 272 | **QML_DIR** 273 | 274 | Literal version that will be displayed with the application. 275 | 276 | *Example:* 277 | 278 | ```cmake 279 | add_qt_windows_exe(MyApp 280 | QML_DIR "path/to/qml/to/deploy" 281 | ) 282 | ``` 283 | 284 | **DEPENDS** 285 | 286 | Additional targets to depend on. 287 | 288 | *Example:* 289 | 290 | ```cmake 291 | add_qt_windows_exe(MyApp 292 | DEPENDS additional_target 293 | ) 294 | ``` 295 | 296 | **ALL** 297 | 298 | If the deploy and installer is run when typing `make all` 299 | 300 | *Example:* 301 | 302 | ```cmake 303 | add_qt_windows_exe(MyApp 304 | ALL 305 | ) 306 | ``` 307 | 308 | **NO_DEPLOY** 309 | 310 | Don't create the deploy target. 311 | 312 | *Example:* 313 | 314 | ```cmake 315 | add_qt_windows_exe(MyApp 316 | NO_DEPLOY 317 | ) 318 | ``` 319 | 320 | **NO_INSTALLER** 321 | 322 | Don't create the installer target. 323 | 324 | *Example:* 325 | 326 | ```cmake 327 | add_qt_windows_exe(MyApp 328 | NO_INSTALLER 329 | ) 330 | ``` 331 | 332 | **NO_TRANSLATION** 333 | 334 | Skip deployment of translations. 335 | 336 | *Example:* 337 | 338 | ```cmake 339 | add_qt_windows_exe(MyApp 340 | NO_TRANSLATION 341 | ) 342 | ``` 343 | 344 | **NO_WEBENGINE** 345 | 346 | Skip deployment of WebEngine (embedded Chromium). 347 | 348 | *Example:* 349 | 350 | ```cmake 351 | add_qt_windows_exe(MyApp 352 | NO_WEBENGINE 353 | ) 354 | ``` 355 | 356 | **NO_VIRTUALKEYBOARD** 357 | 358 | Skip deployment of virtual keyboard (useful if you're building only desktop apps). 359 | 360 | *Example:* 361 | 362 | ```cmake 363 | add_qt_windows_exe(MyApp 364 | NO_VIRTUALKEYBOARD 365 | ) 366 | ``` 367 | 368 | **NO_OPENGL_SW** 369 | 370 | Do not deploy the software rasterizer library. 371 | Disable deployment of `opengl32sw.dll` (20Mo). 372 | 373 | **NO_ANGLE** 374 | 375 | Disable deployment of ANGLE. (`libEGL.dll` & `libGLESv2.dll`) 376 | 377 | **NO_PLUGINS** 378 | 379 | Skip plugin deployment. 380 | 381 | **VERBOSE_LEVEL_DEPLOY** 382 | 383 | If you want to see all of the output of `qtwindeploy`. This can be really useful when debugging. The default is 1. 384 | 385 | *Example:* 386 | 387 | ```cmake 388 | add_qt_windows_exe(MyApp 389 | VERBOSE_LEVEL_DEPLOY 1 390 | ) 391 | ``` 392 | 393 | **VERBOSE_INSTALLER** 394 | 395 | If you want to see all of the output of `binarycreator`. This can be really useful when debugging. 396 | 397 | *Example:* 398 | 399 | ```cmake 400 | add_qt_windows_exe(MyApp 401 | VERBOSE_INSTALLER 402 | ) 403 | ``` 404 | 405 | ## Contact 406 | 407 | * Olivier Le Doeuff: olivier.ldff@gmail.com 408 | --------------------------------------------------------------------------------