i.MX 8 getting started: cmake package
We already started to use cmake instead of writing Makefile by our own in buildroot. Let’s see how to have a cmake package in Yocto.
Add your source file and CMakeLists
Here we use a simple cpp source file to test c++11 and pthread.
alexcmaketest.cpp :
1 |
|
Then prepare your CMakeLists.txt:
CMakeLists.txt:
1 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) |
Notice : install should be added into your CMakeLists.txt if you want your binary to be installed into rootfs.
Write your recipe
cmakeexample_0.1.bb :
1 | SUMMARY = "cmake example" |
There is no need to override do_install nor do_config in this scenario. cmake.bbclass has already defined those tasks and we can just inherit from it.
If pkgconfig is required by your cmake, use inherit pkgconfig cmake instead.
Then add your packages into your layer, don’t forget config your package as IMAGE_INSTALL_append in layer.conf. After that, you should have a folder tree like this:
1 | . |
Build your package!
1 | $ bitbake cmakeexample |
Build your image
Of course don’t forget to re-build your image.
1 | $ bitbake fsl-image-qt5-validation-imx |