在Yocto中使用Cmake构建Qt5



我们正在Yocto/Bitbake中使用Cortex ARM 9的CMake交叉编译我们的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正在安装。当我做find . -name Qt5Config.cmake时,我发现了很多地方。其中一个地方看起来比其他地方更有希望。它是:./tmp/sysroots-components/cortexa9hf-neon-mx6qdl/qtbase/usr/lib/cmake/Qt5/Qt5Config.cmake。但是,Qt-lib不应该在"我的食谱"的系统根目录中吗?

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

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

并且可以用CMake输出确认它知道路径CCD_ 9。此外,在CMake中设置路径(使用set(Qt5_DIR ...)(也没有帮助。

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

我还能尝试什么?

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

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

您只需要继承类cmake_qt5,并确保您像那样分配do_install((


# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
# Unable to find any files that looked like license statements. Check the accompanying
# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.
#
# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (it
# will not be in most cases) you must specify the correct value before using this
# recipe for anything other than initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
S="${WORKDIR}" 
SRC_URI = "file://login.tar"
DEPENDS += "qtbase wayland"
# NOTE: unable to map the following CMake package dependencies: Qt QT
inherit cmake
inherit cmake_qt5
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = ""
do_install(){
install -d ${D}${sbindir}
install -m 0755 ${WORKDIR}/build/login_system ${D}${sbindir}/login_system
}

最新更新