Yocto SDK with cmake toolchain file - sdk

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.
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.
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.
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.
Or shall I just tell the users of the SDK to manually create a toolchain file and add it to their cmake call?

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"
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.

I'd like to add to Anders answer that while it worked great for me to add nativesdk-cmake this way it did not work when I tried to add nativesdk-python3-numpy. After some googling I found this, suggesting that TOOLCHAIN_HOST_TASK has to be extended using _append instead of +=.

Related

How debug Kotlin on iOS with Xcode

Currently I am working on one KMM project. It would be really useful to be able to debug the shared code which is in kotlin in xcode project.
I am aware of this solution but I have problem to tell Xcode that *.kt files are source files
to be more specific in the above github link it is written :
You need to tell Xcode that *.kt files are source files, and run an lldb formatter script when debugging starts. Advanced users may want to do this manually, but if you have Xcode installed in the default place, you can run the setup script.
Unless you're using Xcode 11 (in which case look here for help), the following script will install both debugging and formatting support:
./setup.sh
I do not know where and how I should run the ./setup.sh or if there is another way to do it?
The setup script is included in the github repository: https://github.com/touchlab/xcode-kotlin/blob/main/setup.sh
The above plugin is great if you want to debug on Xcode and I highly recommend it.
Just an FYI, in case you didn't notice, there is also a plugin for debugging shared code on iOS for Android Studio: https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile

Add lib to SDK generated from meta-toolchain-qt5 with Yocto

I'm building an core-image-minimal for my target with Yocto.
To build an application for it, I generate an SDK using:
bitbake meta-toolchain-qt5
It works fine, but the SDK do not include all the lib installed on my target.
So, I tried the following:
bitbake core-image-minimal -c populate_sdk
It generate an SDK, but when installed, it does not include all the files present in the SDK generated by meta-toolchain-qt5
In sysroots/cortex...gnueabi/usr/lib/qt5 there is no directory mkspecs.
So I would like to generate the SDK using meta-toolchain-sdk, with a meta-toolchain-sdk.bbappend file to add the lib that I need. How can I do that?
I want to include log4cxx and tried the following:
SDKIMAGE_FEATURES += "liblog4cxx10"
Could not find log4cxx files in the SDK :-(
Any ideas?
Thank you

How to include a own libary into the toolchain(SDK) for an embeeded Linux generated by Yocto?

I am looking for an example where is shown how to include an own library into the toolchain.
Let's call the library "myLib". For it I created an recipe "myLib.bb" and added:
BBCLASSEXTEND = "native nativesdk"
In my "local.conf" I added:
IMAGE_INSTALL_append = " myLib"
When building the SDK by:
$ bitbake myTarget -c populate_sdk
It produces a installer for the SDK and two manifest files. "myLib" is only included at the target manifest and not on the host. How can I include myLib on the host system?
The idea is, that a other person can build software on his system without the Yocto system. Only by using the toolchain he can generate binaries, which can be transferred and executed at the evalboard.
As long as your library myLib is installed into the image, it's supposed to be part of your generated SDK. Which you also say that it is, at least as part of the target manifest.
Ensure that you install the required header files for your library, then you should be able to cross-compile against your library.
Do you need to use myLib on the developers build machine? Otherwise, why do you want to have it added to the nativeskd part? (I.e. the host manifest). This is for applications that needs to run on the host machine, i.e. the cross-compiler, code generators etc.

Edit custom path with OpenCV framework using CMake to generate XCODE project in iOS

I have a cross-platform build system using CMake, and I have OpenCV dependency for iOS.
Setting ${OpenCV_DIR} manually, my project compile and execute correctly if and only if I set manually every time I generate XCODE project variable Project > Build Settings > Framework Search Paths with ${OpenCV_DIR}.
How can I set this variable using CMake directly?
CMake has no full integration with XCode. You can generate a project using it but a lot of things fails. Just drag into your project OpenCV and it will be detected.

How to build opencv_contrib module for iOS

I want to use some function in the newly introduced opencv_contrib modules on iOS, how can I build a iOS framework with those extra modules. Thanks in advance.
I am answering this (old) question for the benefit of other developers who would like to try this on newer OpenCV versions.
It is possible to build opencv_contrib modules together with the iOS framework, in version 4 (current at the time of answering).
set path to the Xcode command line tools:
sudo ln -s /Applications/Xcode.app/Contents/Developer Developer
cd to the path above the opencv directory
cd ~/
Build the framework with the --contrib option:
python opencv/platforms/ios/build_framework.py --contrib <'relative_path_to_opencv_contrib'>/opencv_contrib/ ios
If an individual module does not get build, you should check the CMakelists.txt of that module to see if it has been disabled for iOS.
I just tested this before answering, so feel free to drop a comment or a question if there are issues.
See fficial document tutorial_ios_install!
This works well.
The official document does not include building iOS framework with opencv_contrib.
But inferring from the cmake file, you can copy the module you want (ximgproc in your case) to opencv/modules. Then run build_framework.py as usual.
You can checkout this post

Resources