Yocto recipe compiling Qt apps with cmake

Compiling Qt apps with qmake using Yocto if really straight forward.

The following example is based on poky/warrior and my small bit counting tool:

SUMMARY = Registerer is a Hex/Bin/Dec converter aiming embedded developers 
HOMEPAGE = http://staging.mdb977.de/
LICENSE = GPLv2+
LIC_FILES_CHKSUM = file://LICENSE.txt;md5=39bba7d2cf0ba1036f2a6e2be52fe3f0

inherit qmake5
DEPENDS = qtbase 

SRC_URI = git://github.com/MikeBergmann/Registerer.git;protocol=https
SRCREV = e3c52c9aa8b6fa18fcf0caad038da81f3e56f313

S = ${WORKDIR}/git

Doing the same using CMake, one may think inheriting cmake instead of qmake5 should be enough.

Unfortunately, this is not true and leads to the error message:

Skipping because OE_QMAKE_PATH_EXTERNAL_HOST_BINS is not defined

The reason for this is that the qmake5 recipe is doing some more stuff:

  • First, the variable OE_QMAKE_PATH_EXTERNAL_HOST_BINS is defined by qmake5_paths, so if we want to make use of this variable, we have the inherit qmake5_paths, too.
  • Second, qmake5 depends on qtbase-native, providing the qmake tools we need, so we have to make sure we depend on the native package.
  • Third, we have to make sure CMake is infirmed about the OE_QMAKE_PATH_EXTERNAL_HOST_BINS variable by setting it explicitly using EXTRA_OECMAKE.

So, the complete CMake based recipe will look like:

SUMMARY = Registerer is a Hex/Bin/Dec converter aiming embedded developers 
HOMEPAGE = http://staging.mdb977.de/
LICENSE = GPLv2+
LIC_FILES_CHKSUM = file://LICENSE.txt;md5=39bba7d2cf0ba1036f2a6e2be52fe3f0

inherit cmake qmake5_paths
DEPENDS = qtbase qtbase-native 

SRC_URI = git://github.com/MikeBergmann/Registerer.git;protocol=https
SRCREV = e3c52c9aa8b6fa18fcf0caad038da81f3e56f313

S = ${WORKDIR}/git

EXTRA_OECMAKE = -DOE_QMAKE_PATH_EXTERNAL_HOST_BINS='${OE_QMAKE_PATH_EXTERNAL_HOST_BINS}'