Yocto SDK with cmake toolchain file

I provide the Yocto SDK for cross-building an application for an embedded goal. The application itself is built using CMake. Setting up the SDK script provides many of the necessary environment variables (for example, the location of the cross-compiler, sysroot, etc.), which so far have been enough to create the application.

However, since then the application has been dependent on the Boost library (via the find_package(Boost REQUIRED) in CMakeLists.txt). Now CMake complains that he cannot find the library, even if it is installed in the sysroot SDK. But if I create the application directly in Yocto, it works fine.

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

Now I wonder if Yocto supports any mechanism for exporting such a toolchain file from the SDK. Or, alternatively, if the SDK provides a script or something that automatically creates a tool binding file directly on the SDK assembly host.

Or will I just tell the SDK users to manually create the tool binding file and add it to my cmake call?

+6
source share
1 answer

Assuming you are using an image-based SDK, i.e. create it with bitbake <image> -c populate_sdk , adding the following to image.bb should fix it:

 TOOLCHAIN_HOST_TASK += "nativesdk-cmake" 

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

+8
source

Source: https://habr.com/ru/post/1014603/


All Articles