【问题标题】:Build Qt5 with Cmake in Yocto在 Yocto 中使用 Cmake 构建 Qt5
【发布时间】:2018-07-30 15:23:07
【问题描述】:

我们正在使用适用于 Cortex ARM 9 的 CMake 在 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!

到目前为止,recipy 似乎还不错。我依赖 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 应该自动被我的配方知道。

我还能尝试什么?

【问题讨论】:

    标签: c++ qt cmake embedded-linux yocto


    【解决方案1】:

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

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

    【讨论】:

    • 非常感谢@mascoj!这很好地解决了这个问题。
    • cmake_qt5 配方还展示了如何使用 RDEPENDS_prepend 依赖项。我不知道——这解决了我的观点“1”。不明白,为什么依赖包是并行构建的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    • 2016-08-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多