Coder Social home page Coder Social logo

joypoint / qtwindowscmake Goto Github PK

View Code? Open in Web Editor NEW

This project forked from olivierldff/qtwindowscmake

0.0 0.0 0.0 69 KB

๐Ÿ’ป CMake macro to deploy and create installer for Qt application on windows.

License: MIT License

CMake 100.00%

qtwindowscmake's Introduction

Qt Windows CMake

What it is

This project provide a CMake macro to help you deploy Qt application on windows. It will generate a deploy target that:

  • Deploy dynamic Qt library near your executable file to create a self-contain application folder.
  • Deploy msvc or mingw c++ runtime library.

It will also generate an installer project that will:

  • Create a win32 installer to install your application and share your application easily.

The macro will call program for the qt framework.

  • windeployqt to deploy dynamic library and qml. Documentation is available here.
  • qtinstallerframework to create installer. Documentation is available here.
    • Behind the scene, the macro will call QtBinaryCreatorCMake project.

This utility has been developed for my own needs. Don't hesitate to use / share / fork / modify / improve it freely :)

This project is conceptually based on the great QtAndroidCMake of Laurent Gomila.

How to use it

How to integrate it to your CMake configuration

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.

if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
    FetchContent_Declare(
            QtWindowsCMake
            GIT_REPOSITORY "https://github.com/OlivierLDff/QtWindowsCMake"
            GIT_TAG        master
        )
    FetchContent_MakeAvailable(QtWindowsCMake)
    add_qt_windows_exe(MyApp)
endif()

The you can simply run

make MyAppDeploy
make MyAppInstaller

Of course, add_qt_windows_exe accepts more options, see below for the detail.

How to run CMake

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.

export QT_WIN_VERSION=5.12.0
export QT_DIR_MINGW32=C:/Qt/$QT_WIN_VERSION/mingw53_32
export QT_DIR_MINGW64=C:/Qt/$QT_WIN_VERSION/mingw53_64
export QT_DIR_MSVC32=C:/Qt/$QT_WIN_VERSION1/msvc2017_32
export QT_DIR_MSVC64=C:/Qt/$QT_WIN_VERSION/msvc2017_64
export QT_BUILD_TYPE=Release #  or export QT_BUILD_TYPE=Debug

MinGw 32 bits - Make

cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MINGW32 \
-G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$QT_BUILD_TYPE path/to/CMakeLists/

MinGw 64 bits - Ninja

cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MINGW64 \
-G "Ninja" -DCMAKE_BUILD_TYPE=$QT_BUILD_TYPE path/to/CMakeLists/

Msvc 32 bits (Default)

cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MSVC32 \
-G "Visual Studio 15 2017" path/to/CMakeLists/

Msvc 64 bits

cmake -DCMAKE_PREFIX_PATH=$QT_DIR_MSVC64 \
-G "Visual Studio 15 2017 Win64" path/to/CMakeLists/

Options of the add_qt_windows_exe macro

The first argument is the target the macro should deploy an app for. It will automatically generate 2 targets:

  • ${MY_TARGET}Deploy that deploy dynamic library and qmldir.
  • ${MY_TARGET}Installer that pack and generate an installer.

The macro also accepts optional named arguments. Any combination of these arguments is valid. Example:

add_qt_windows_exe(my_app
    NAME "My App"
    VERSION "1.2.3"
    PUBLISHER "My Company"
    PRODUCT_URL "www.myapp.com"
    PACKAGE "org.mycompany.myapp"
    FILE_EXTENSION "appExtension"
    ICON "path/to.icon.rc"
    ICON_RC "path/to.icon.rc"
    QML_DIR "path/to/qmldir"
    NO_TRANSLATION
    NO_PLUGINS
    NO_OPENGL_SW
    NO_ANGLE
    VERBOSE_LEVEL_DEPLOY 1
    VERBOSE_INSTALLER
    ALL
 )

Here is the full list of possible arguments:

NAME

The name of the application. If not given, the name of the source target is taken. The default is ${TARGET}.

Example:

add_qt_windows_exe(MyApp
    NAME "My App"
)

DEPLOY_NAME

Name of the deploy target. The default is ${TARGET}Deploy.

Example:

add_qt_windows_exe(MyApp
    DEPLOY_NAME "MyAppDeployName"
)

You can then run this target with make MyAppDeployName .

INSTALLER_NAME

Name of the installer target. The default is ${TARGET}InstallerX64 or ${TARGET}InstallerX32 depending is 32 bits or 64 bits is selected.

Example:

add_qt_windows_exe(MyApp
    INSTALLER_NAME "MyAppInstallerName"
)

You can then run this target with make MyAppInstallerName .

VERSION

Literal version that will be displayed with the application. The default is 1.0.0.

Example:

add_qt_windows_exe(MyApp
    VERSION "1.2.3"
)

PUBLISHER

Literal version that will be displayed with the application.

Example:

add_qt_windows_exe(MyApp
    PUBLISHER "My Company"
)

PRODUCT_URL

Literal version that will be displayed with the application.

Example:

add_qt_windows_exe(MyApp
    PRODUCT_URL "www.myapp.com"
)

PACKAGE

The name of the application package. If not given, org.qtproject.${TARGET} , where source_target is the name of the source target, is taken.

Example:

add_qt_windows_exe(MyApp
    PACKAGE "org.mycompany.myapp"
)

RUN_PROGRAM

The program to run with the generated shortcut on install. By default it is set to ${NAME}.

Example:

add_qt_windows_exe(MyApp
    RUN_PROGRAM "MyApp"
)

FILE_EXTENSION

You can specify extension that will be associate with you app.

Example:

add_qt_windows_exe(MyApp
    FILE_EXTENSION "appExtension"
)

ICON

The icon that will be used for the generated installer executable

Example:

add_qt_windows_exe(MyApp
    ICON "path/to/icon.ico"
)

ICON_RC

The icon rc file for the application. icon.rc might look like this (More info about ressources files here):

IDI_ICON1               ICON    DISCARDABLE     "icon.ico"

And the file structure:

windows
โ”‚ icon.rc
โ”‚ icon.ico

Example:

add_qt_windows_exe(MyApp
    ICON_RC "path/to/icon.rc"
)

QML_DIR

Literal version that will be displayed with the application.

Example:

add_qt_windows_exe(MyApp
    QML_DIR "path/to/qml/to/deploy"
)

DEPENDS

Additional targets to depend on.

Example:

add_qt_windows_exe(MyApp
    DEPENDS additional_target
)

ALL

If the deploy and installer is run when typing make all

Example:

add_qt_windows_exe(MyApp
    ALL
)

NO_DEPLOY

Don't create the deploy target.

Example:

add_qt_windows_exe(MyApp
    NO_DEPLOY
)

NO_INSTALLER

Don't create the installer target.

Example:

add_qt_windows_exe(MyApp
    NO_INSTALLER
)

NO_TRANSLATION

Skip deployment of translations.

Example:

add_qt_windows_exe(MyApp
    NO_TRANSLATION
)

NO_WEBENGINE

Skip deployment of WebEngine (embedded Chromium).

Example:

add_qt_windows_exe(MyApp
    NO_WEBENGINE
)

NO_VIRTUALKEYBOARD

Skip deployment of virtual keyboard (useful if you're building only desktop apps).

Example:

add_qt_windows_exe(MyApp
    NO_VIRTUALKEYBOARD
)

NO_OPENGL_SW

Do not deploy the software rasterizer library. Disable deployment of opengl32sw.dll (20Mo).

NO_ANGLE

Disable deployment of ANGLE. (libEGL.dll & libGLESv2.dll)

NO_PLUGINS

Skip plugin deployment.

VERBOSE_LEVEL_DEPLOY

If you want to see all of the output of qtwindeploy. This can be really useful when debugging. The default is 1.

Example:

add_qt_windows_exe(MyApp
    VERBOSE_LEVEL_DEPLOY 1
)

VERBOSE_INSTALLER

If you want to see all of the output of binarycreator. This can be really useful when debugging.

Example:

add_qt_windows_exe(MyApp
    VERBOSE_INSTALLER
)

Contact

qtwindowscmake's People

Contributors

b0bben avatar olivierldff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.