c++ - 在 Yocto 中使用 Cmake 构建 Qt5

标签 c++ qt cmake embedded-linux yocto

我们正在使用 CMake for Cortex ARM 9 在 Yocto/Bitbake 中交叉编译我们的 Qt5 应用程序。

无论我做什么,我都无法让 Cmake 找到所需的 Qt5Config.cmake 配置文件。

错误信息众所周知:

 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!

到目前为止,收件人似乎还不错。我依赖 Qt 并通过以下方式使用 Cmake:

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

不幸的是,我不确定两件事:

  1. 当我构建 Yocto(在 2 个内核上)时,为什么 bitbake 在我的错误配方之前或同时构建 qt5 包?依赖关系不应该解决这个问题吗?我还尝试使用 DEPENDS 而不是 RDEPENDS,但这没有什么区别。

  2. 我不知道 Qt 安装在哪个 sysroots 中。当我执行 find 时。 -name Qt5Config.cmake 找了好多地方。其中一个地方看起来比其他地方更有希望。它是:./tmp/sysroots-components/cortexa9hf-neon-mx6qdl/qtbase/usr/lib/cmake/Qt5/Qt5Config.cmake。但是,Qt 库不应该在“我的食谱”的 sysroot 中吗?

所以,毕竟,我尝试让CMake知道Qt5Config.cmake的位置。我尝试通过设置

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

在配方中,可以通过 CMake 输出确认它知道路径 Qt5_DIR。在 CMake 中设置路径(使用 set(Qt5_DIR ...))也无济于事。

路径仍然未知。即使我现在很乐意让 CMake 了解 Qt5 在哪里 - 似乎配置错​​误,因为我认为 Qt 应该自动为我的食谱所知。

我还能尝试什么?

最佳答案

终于抽出时间来回答了。我有一段时间遇到同样的问题并发现了 cmake_qt5 bitbake类。

使用此类代替 cmake 应该填充在 Yocto 项目中将 Qt5 与 CMake 一起使用所需的所有必要标志。

关于c++ - 在 Yocto 中使用 Cmake 构建 Qt5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51597322/

相关文章:

c++ - sizeof() 是递归的吗?

visual-studio - 如何创建一个cmake变量

c++ - cmake交叉编译boost链接错误

c++ - 如何检测 Asio 库的死锁?

c++ - 为什么 const 右值引用隐式转换为 const 引用?

qt - QML Canvas.requestAnimationFrame 爆炸

c++ - 如何设置QPlainTextEdit的水平溢出?

linux - 简单的Qt5应用程序在终端上输出空白行

c++ - 链接无法正常工作

c++ - 内存池 : will they improve cache usage for structs larger than the cache line size?