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.
我提供了一个Yocto SDK来跨构建一个嵌入式目标的应用程序。应用程序本身是用CMake构建的。SDK安装脚本提供了许多必要的环境变量(如交叉编译器、sysroot等),到目前为止已经足够构建应用程序了。
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.
但是,从最近开始,应用程序对Boost库有依赖关系(通过在CMakeLists.txt中通过命令find_package(Boost REQUIRED))。现在CMake抱怨它找不到库,尽管它安装在SDK sysroot中。但是如果我直接在Yocto中构建应用程序,它就可以正常工作了。
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产生了一个工具链。添加到cmake调用的cmake文件。在这个文件中,设置了变量CMAKE_FIND_ROOT_PATH, CMake需要查找库。使用这样的工具链文件,我还可以使用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.
现在,我想知道Yocto是否提供了用SDK导出这样一个工具链文件的机制。或者,如果SDK提供了一个脚本或一些东西,可以直接在SDK构建主机上创建一个工具链文件。
Or shall I just tell the users of the SDK to manually create a toolchain file and add it to their cmake call?
或者我是否应该告诉SDK的用户手工创建一个工具链文件并将其添加到他们的cmake调用中?
1 个解决方案
#1
8
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:
假设您使用的是基于图像的SDK,也就是用bitbake -c populate_sdk构建它,添加以下toimage。bb应该改正:
TOOLCHAIN_HOST_TASK += "nativesdk-cmake"
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.
这应该会给你一个OEToolchainConfig。cmake文件在SDK中。在找到SDK环境文件后,cmake将是cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig的别名。cmake进一步帮助您的开发人员。
#1
8
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:
假设您使用的是基于图像的SDK,也就是用bitbake -c populate_sdk构建它,添加以下toimage。bb应该改正:
TOOLCHAIN_HOST_TASK += "nativesdk-cmake"
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.
这应该会给你一个OEToolchainConfig。cmake文件在SDK中。在找到SDK环境文件后,cmake将是cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig的别名。cmake进一步帮助您的开发人员。