我们正在使用 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
不幸的是,我不确定两件事:
当我构建 Yocto(在 2 个内核上)时,为什么 bitbake 在我的错误配方之前或同时构建
qt5
包?依赖关系不应该解决这个问题吗?我还尝试使用DEPENDS
而不是RDEPENDS
,但这没有什么区别。我不知道 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/