meta-qt6 is a meta layer for OpenEmbedded and Yocto that provides recipes for Qt modules and support for building your application using Qt. This topic provides common guidelines how you can use meta-qt6. For more detailed information about Yocto Project, see Yocto Project Documentation.
The meta-qt6 layer is available with MIT license and is under Qt Gerrit with git mirror available in code.qt.io. Contributions are welcome using the Qt Code Review in similar fashion as contributions to the Qt code. Qt Gerrit works nicely for code review and it also lets us utilize the Qt CI system for build verification before commits are merged. Bugs and other issues can be reported and discussed in Qt Bug Tracker using component Yocto: meta-qt6 layer
Firstly, you need to include the meta-qt6 layer into your Yocto build environment. Typically, this means editing the conf/bblayers.conf file in order to include a path for meta-qt6. Then you can include any Qt module into your image or toolchain.
meta-qt6 provides recipes for each Qt module. Most recipes support
PACKAGECONFIG options that you can use to modify features each Qt module is built with.
A reasonable default set of features is already enabled in meta-qt6 for each Qt module that has PACKAGECONFIG options, but depending on your feature needs, you can modify the configuration for each Qt module separately.
For example, if you want to enable all the examples in QtBase, you need to create a qtbase_git.bbappend file and add the
PACKAGECONFIG option as follows:
PACKAGECONFIG += "examples"
By default, the meta-qt6 recipes configure Qt using Open Source licensing. Users with valid commercial license can change this, so that Qt is configured with commercial licensing enabled. This can be done with QT_EDITION variable in conf/local.conf or similar global configuration file:
QT_EDITION = "commercial"
By default, meta-qt6 builds Qt as a set of dynamic libraries. If needed, you can change the Qt configuration so that static libraries are produced instead. Your application is then linked against the static libraries and you can produce a single binary without additional dependencies to Qt libraries. You can enable a static Qt build by adding it into the qtbase's PACKAGECONFIG.
PACKAGECONFIG += "static"
Because each Qt application includes all the required Qt libraries, builds can become overly large if you enable tests and examples for Qt modules. For this reason, you should disable the options
PACKAGECONFIG in Qt module recipes. This ensures that tests and examples are not built for the Qt modules.
For building your application statically, see Linking to Static Builds of Qt
You can build your own Qt application with meta-qt6 by inheriting the correct class to your application recipe. After setting the usual SRC_URI, DEPENDS and other common bitbake variables, use
qt6-qmake if you have a qmake project:
qt6-cmake if you have a CMake project using Qt:
In case you need to give qmake additional arguments, you can use the
EXTRA_QMAKEVARS_PRE += "CONFIG+=extra-args"
For CMake builds, you can use the
EXTRA_OECMAKE += "-DFEATURE_EXTRA=ON"
The meta-qt6 layer includes an example SDK recipe (
meta-toolchain-qt6) which contains all the available Qt 6 modules and tools needed for building Qt applications. For easier Qt Creator integration, we have included additional CMake toolchain file (
Qt6Toolchain.cmake) that can be used without sourcing the usual environment-setup script from the toolchain. Using qmake from the toolchain without sourcing the environment-setup file continues to be supported as it already is with meta-qt5.
Additionally, meta-mingw support is added to the meta-qt6 layer, which allows you to build toolchains that can be run natively on a Windows host. The Windows toolchain still has some limitations compared to native Linux development environment as not all the development tools can be currently built for MinGW.
To create your own toolchain recipe, you can use the
populate_sdk_qt6_base.bbclass to include the needed configutations.
Switching from meta-qt5 to meta-qt6 for building Qt or your own application should be quite straightforward. The recipes for Qt modules are using the same names in both layers, and starting with Qt 6.2, most of the modules from Qt5 are available in Qt6.
The two main bbclasses used in application recipes have changed:
|inherit qmake5||inherit qt6-qmake||for building qmake project|
|inherit cmake-qt5||inherit qt6-cmake||for building CMake project|
Qt 6 is now using CMake for building itself, but qmake remains supported for application development, so you can keep your application builds using qmake.
Available under certain Qt licenses.
Find out more.