带cmake工具链文件的Yocto SDK [英] Yocto SDK with cmake toolchain file

查看:266
本文介绍了带cmake工具链文件的Yocto SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供了Yocto SDK来为嵌入式目标交叉构建应用程序。应用程序本身是使用CMake构建的。 SDK设置脚本提供了许多必要的环境变量(例如交叉编译器的位置,sysroot等),到目前为止,这些变量足以构建应用程序。

I provide a Yocto SDK to cross-build an application for an embedded target. The application itself is built using CMake. The SDK setup script provides many necessary environment variables (like location of the cross-compiler, sysroot, etc.), which so far was enough to build the application.

但是,因为最近该应用程序依赖于Boost库(通过CMakeLists.txt中的命令 find_package(Boost必填))。现在,CMake抱怨即使该库已安装在SDK sysroot中,也找不到该库。但是,如果我直接在Yocto中构建应用程序,它就可以正常工作。

However, since recently the application has a dependency to the Boost library (through the command find_package(Boost REQUIRED) in the CMakeLists.txt). Now CMake complains that it cannot find the library, even though it's installed in the SDK sysroot. But if I build the application directly in Yocto, it works fine.

经过一些研究,结果证明Yocto生成了 toolchain.cmake 文件添加到cmake调用中。在此文件中,设置了变量 CMAKE_FIND_ROOT_PATH ,CMake需要此变量来查找库。使用这样的工具链文件,我也可以使用SDK进行构建。

After some research it turned out that Yocto generates a toolchain.cmake file which is added to the cmake call. In this file, the variable CMAKE_FIND_ROOT_PATH is set, which CMake needs to find libraries. Using such a toolchain file, I can also build using the SDK.

现在,我想知道Yocto是否提供了使用SDK导出此类工具链文件的机制。或者,如果SDK提供了脚本或其他直接在SDK构建主机上自动创建工具链文件的工具。

Now I'm wondering if Yocto provides any mechanism to export such a toolchain file with the SDK. Or alternatively if the SDK provides a script or something to automatically create a toolchain file directly on the SDK build host.

或者我只能告诉SDK用户手动创建工具链文件并将其添加到他们的cmake调用中?

Or shall I just tell the users of the SDK to manually create a toolchain file and add it to their cmake call?

推荐答案

假设您正在使用基于图像的SDK,即构建使用 bitbake< image> -c populate_sdk ,将以下内容添加到 image.bb 应该可以解决:

Assuming that you're using the image based SDK, i.e. building it with bitbake <image> -c populate_sdk, adding the following toimage.bb should fix it:

TOOLCHAIN_HOST_TASK += "nativesdk-cmake"

那应该给你SDK中的 OEToolchainConfig.cmake 文件。在获取SDK环境文件后, cmake 将成为 cmake -DCMAKE_TOOLCHAIN_FILE = $ OECORE_NATIVE_SYSROOT / usr / share / cmake / OEToolchainConfig.cmake的别名。 code>进一步帮助您的开发人员。

That should give you a OEToolchainConfig.cmake file in the SDK. After sourcing the SDK environment file, cmake will be an alias to cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake to further help your developers.

这篇关于带cmake工具链文件的Yocto SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆