2
votes

We are cross-compiling our Qt5 application within Yocto/Bitbake using CMake for Cortex ARM 9.

No matter what I do, I can't get Cmake to find the required Qt5Config.cmake config file.

The error message is well known out there:

 CMake Error at CMakeLists.txt:71 (find_package):
 By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
 asked CMake to find a package configuration file provided by "Qt5", but
 CMake did not find one.

 Could not find a package configuration file provided by "Qt5" with any of
 the following names:

     Qt5Config.cmake
     qt5-config.cmake

 Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
 to a directory containing one of the above files.  If "Qt5" provides a
 separate development package or SDK, be sure it has been installed.

 -- Configuring incomplete, errors occurred!

The recipy seems to be fine so far. I depend Qt and use Cmake by:

RDEPENDS_${PN} += " qtconnectivity "
inherit pkgconfig cmake

Unfortunately I am uncertain about two things:

  1. When I build Yocto (on 2 cores), why is bitbake building the qt5 packages before or at the same time as my faulty recipe? Shouldn't the dependency sort this out? I also tried to use DEPENDS instead of RDEPENDS, but that doesn't make a difference.

  2. I don't know in which sysroots Qt is being installed. When I do find . -name Qt5Config.cmake I find so many places. One of the places looks a bit more promising than the others. It is: ./tmp/sysroots-components/cortexa9hf-neon-mx6qdl/qtbase/usr/lib/cmake/Qt5/Qt5Config.cmake. But still, shouldn't the Qt libs be in the sysroot of "my recipe"?

So, after all, I try to let CMake know the location of Qt5Config.cmake. I try by setting

export Qt5_DIR = "/home/vagrant/build/tmp/sysroots-components/cortexa9hf-neon-mx6qdl/qtbase/usr/lib/cmake/Qt5/"

in the recipe and can confirm with a CMake output that it knows the path Qt5_DIR. Also setting the path in CMake (with set(Qt5_DIR ...)) doesn't help.

The path remains unknown. Even if I would be happy now to make CMake understand where Qt5 is - there seems to be a misconfiguration, as I would assume that Qt should be known to my recipe automatically.

What else can I try?

1

1 Answers

3
votes

Finally got around to answering. I had the same issue for awhile and discovered the cmake_qt5 bitbake class.

Using this class in place of cmake should populate all the necessary flags needed to use Qt5 with CMake in the Yocto Project.