Qmake Cmake

Setting up QtCreator for cross-compilation with CMake took me 15-20 hours the first two or three times. The next half a dozen times took me 4 hours on average. The last two times took me 5 minutes – using the script presented in this post. I can cross-compile the Qt application for my embedded device and run the Qt application on the device with one button press in QtCreator.

  1. Qt Vscode Cmake
  2. Qmake Cmake Subproject
  3. Opening Projects
  4. Qmake Cmake Find Package
  5. Cmake - CMake Command-Line Reference - Man Page ManKier
  6. Specifying Build Settings

Users of the commercial Qt for Device Creation license have been enjoying this fast and proper QtCreator setup for several years now. The script in this post is the first time that (L)GPLv3 users of Qt can enjoy the same convenience.

Qmake will still be supported in Qt 6 for user apps. But in Qt 7 it is likely to be completely dropped. But cmake support is sure to get far more love now and int the future. So for long-term projects - better use cmake. For Qt users, qmake is currently the most widely used build system. CMake is a clear second and growing in popularity. The third place is Qbs, with significantly smaller adoption. When asked about their preferences, most of our customers said they plan to use either CMake or qmake in the future. CMake: Fix building debug apps with qmake on Windows Gerrit Review: CMake: Fix generated content of prl files (again) Gerrit Review: CMake: Don't generate prl libs.


You have built a Linux image and an SDK for an embedded device with Yocto. 5 paragraph essay outline. For this post, I built the SDK for the reference image tdx-reference-multimedia-image of the Verdin i.MX8M Mini board from Toradex. You can log into the board with SSH using a username and password.

You should use a QtCreator version not older than 4.11 and a CMake version not older than 3.14. Using the latest QtCreator and CMake versions has never caused me any problems. So, I suggest you do the same. In the unlikely event that you must use older versions, I explain a workaround in my post Deploying Qt Projects to Embedded Devices with CMake.

Download the script configure-qtcreator.sh, install it in a directory from $PATH and make it executable.

The script generates the Qt Creator configuration files, which QtCreator displays in the dialog Tools Options Kits. The script works for any SDK built with Yocto.

Setting Up QtCreator in 5 Minutes

You choose a name for the QtCreator kit. My kit name is

Qt Vscode Cmake

QtCreator uses this name to mark the compiler, Qt version, debugger, CMake version and device as belonging to this kit.


The Yocto SDK is installed in $SDK_DIR_PATH and contains the environment setup file, which sets Linux environment variables like OECORE_*, CXX and CXXFLAGS needed for cross-compilation against the SDK. My settings look as follows:

The QtCreator version, for which you generate the configuration files, is located in $QT_CREATOR_DIR_PATH, which contains the subdirectories bin and libexec. My settings are

$DEVICE (verdin-imx8mm.local for me) is the name or IP address of the device, on which the Qt application will be running. The call

should allow you to log in to the target device. Once set up, QtCreator will deploy the Qt application to $DEVICE and run it on the $DEVICE.

Close QtCreator and call the script configure-qtcreator.sh:

The script generates two CMake toolchain files – Goldfinger.cmake and OEQt5Toolchain.cmake – in the directory


Goldfinger.cmake is a normal CMake toolchain file and sets the variables for the C++ compiler, the linker and the system root among others. OEQt5Toolchain.cmake fixes a long-standing bug in the CMake files of the Qt libraries.

The script also generates a couple of QtCreator configuration files – profiles.xml, qtversion.xml, toolchain.xml, debuggers.xml, cmaketools.xml and devices.xml – in the directory

It is now time to restart QtCreator. When started, QtCreator merges these configuration files with their counterparts in $HOME/.config/QtProject/qtcreator. When you open the dialog Tools Options Kits Kits, you’ll see the new auto-detected kit Goldfinger.

QtCreator auto-detected the configurations for the Device Goldfinger, the sysroot, the C compiler GCC (Goldfinger), the C++ compiler (Goldfinger), the debugger GDB Goldfinger, the Qt version Goldfinger, the CMake tool CMake Goldfinger, the CMake generator and the CMake configuration. You can inspect these configurations by clicking through the tab pages. If you want to change the disabled configurations, you must clone them.

One manual post-processing step is required: creating and deploying a public key on the device. Go to Tools Options Devices, select the Device Goldfinger, press the Create New for Private key file and press the Deploy Public Key button. You can test your setup by pressing the Test button. I have described the setup of a device in detail in my post Docker Builds from QtCreator.

You are now able to cross-build your Qt application against the Yocto SDK. To run the Qt application on the device, you adapt the deployment and run settings as described in my post Cross-Compiling Qt Embedded Applications with QtCreator and CMake.

CMake Toolchain Files

The Yocto SDK comes with a CMake toolchain file $ORIG_TOOLCHAIN_FILE, where

You could source the environment setup file $ENV_SETUP_FILE_PATH of the Yocto SDK in a Linux terminal and start QtCreator from the same terminal. This approach has two problems.

  • It will only work, if you explicitly set the variable OE_QMAKE_PATH_EXTERNAL_HOST_BINS in the CMake toolchain file. This is a long-standing bug Qt’s CMake files from Yocto 2.x, which unfortunately made it into Yocto 3.x.
  • You cannot switch kits in QtCreator without restarting QtCreator in another terminal. The original toolchain file reads the environment variables (e.g., $ENV{CFLAGS}) set in the environment setup script.

The script configure-qtcreator.sh solves these two problems by generating a CMake toolchain file for each problem. It generates $QT5_TOOLCHAIN_FILE for the first problem and $KIT_TOOLCHAIN_FILE for the second problem, where


$ORIG_TOOLCHAIN_FILE includes all the *.cmake files from the subdirectory OEToolchainConfig.cmake.d at the end.

If you didn’t source the environment setup file, the command

from $ORIG_TOOLCHAIN_FILE will assign the empty string to CMAKE_C_FLAGS. The $KIT_TOOLCHAIN_FILE overwrites CMAKE_C_FLAGS with the command

$KIT_TOOLCHAIN_FILE replaces all the environment variables from $ORIG_TOOLCHAIN_FILE with the values of these environment variables. Otherwise, the toolchain files are the same.

$QT5_TOOLCHAIN_FILE sets the CMake variable OE_QMAKE_PATH_EXTERNAL_HOST_BINS to its correct value. If this variable is not set, the CMake files for the Qt modules will be skipped with the message “WARNING Skipping because OE_QMAKE_PATH_EXTERNAL_HOST_BINS is not defined”.

QtCreator Configuration Files

The options --name, --env-setup and --creator-base of the script configure-qtcreator.sh are mandatory. The example call included the option --device $DEVICE to generate a device configuration. If you already have a device configuration, you leave out the option.

Qmake Cmake Subproject

The default ABI flavour is arm-linux-poky-elf-64bit. If you had a 32-bit device, you’d pass the option --device arm-linux-poky-elf-32bit. The ABI flavour is shown in QtCreator’s compiler settings Tools Options Kits Compilers.

The script configure-qtcreator.sh first removes the configurations from the QtCreator configuration files and then adds the new configurations. If you pass the option --remove, the script will only remove configurations.

The script configure-qtcreator.sh uses the QtCreator utility sdktool to remove and add configurations. The utility is located in

Opening Projects

It reads the XML configuration files (e.g., toolchains.xml, profiles.xml) from the directory $QT_CREATOR_DIR_PATH/share/qtcreator/QtProject/qtcreator, removes or adds sections and writes the modified XML files. When restarted, QtCreator reads these XML files, adds a unique ID and merges the configurations with those from $HOME/.config/QtProject/qtcreator.

The command $SDKTOOL --help lists all the available add and remove operations. The command $SDKTOOL --help <operation> shows help for a specific operation like addTc and rmTC. You will not find sdktool mentioned even once in the Qt documentation. The source code provides the only other source of information. The rest is trial and error.

The script configure-qtcreator.sh needs two sdktool calls to remove any configuration.

The first call removes the Qt version from

Qmake Cmake Find Package

The second call removes the Qt version from

Qmake Cmake

Note that the option --sdkpath=<path> cannot be rewritten as --sdkpath <path> like all the other options. sdktool would fail with a meaningless message. All the other options must have the format --name <value>.

Adding a configuration requires only one sdktool call. For example, a new Qt version is added with this sdktool command:

This command adds the Qt version to the file

When restarted, QtCreator adds an ID to the Qt version and merges it into the file

I figured out the type Qdb.EmbeddedLinuxQt by looking up the Qt version of a manually created configuration.

All the configurations show up as auto-detected in the QtCreator dialog Tools Options Kits. You would have to change the source code of sdktool, which hard-wires auto-detect to true. It is not enough to change the auto-detect property to false in the XML configuration files. QtCreator changes the value back to true on the next restart.


Cmake - CMake Command-Line Reference - Man Page ManKier

When you install a commercial Boot2Qt edition, the Qt installer creates the CMake toolchain files missing from the Yocto SDK, guides you through setting up a device and generates the QtCreator configuration files. When you start QtCreator after the installation, you are ready to cross-build your Qt application. You don’t have to setup the kit and its parts manually in QtCreator.

Specifying Build Settings

Most of the magic comes from the original configure-qtcreator.sh script. I added the generation of the CMake toolchain files and made sure that all parts of a generated kit get removed. My modified configure-qtcreator.sh script provides you with the same convenience as the installer of the commercial Boot2Qt versions. It enables you to cross-build your Qt application for your device and run them on the device within 5 minutes!