TipsAndTricks/Cmake,Eclipse, and SDKS

From Yocto Project
Jump to navigationJump to search

Cmake,Eclipse, and SDKS: Oh My!

Suppose you would like to use cmake in an sdk &/or would like to use cmake from the Yocto Eclipse plugin. There's a couple of tricks/issues to be aware of.

Getting cmake into your sdk

Normally, if you do

$ bitbake core-image-sato -c populate_sdk  

the generated sdk does not include the build system created cmake. Using the host cmake, cross compilation will often work, but you will not have all the cmake options set to the generated cmake.
If you would like to include the generated cmake in your sdk , you need to add the following to your local.conf fille:


TOOLCHAIN_HOST_TASK_append = "${SDK_EXTRA_TOOLS}" 
SDK_EXTRA_TOOLS = " nativesdk-cmake     " 

Using the Eclipse plugin with the cmake from the sdk

This can get confusing because it may be unclear which cmake eclipse is using, if you have one in the sdk and one installed on the host. To make sure you get the cmake from the sdk, launch eclipse from a terminal that has already sourced the environment script instead of launching it by clicking on an icon (old school, I know...). For example, :


$ . /home/me/poky-qemuarm-2.2-cmake/environment-setup-armv5e-poky-linux-gnueabi
$ /home/me/eclipse/eclipse

That way, eclipse will find the "correct" cmake and wont complain about either CMAKE_ROOT or "cmake not installed properly"


Note: the current sdk's published on downloads.yoctoproject.org as of release 2.3 do NOT include cmake

Using the Eclipse plugin with the cmake from the build directory

This is a bit harder, since we won't have the sdk environment setup script to help us. To get cmake to work in this case, you need to point the Yocto Eclipse plugin at your build environment as described in TipsAndTricks/RunningEclipseAgainstBuiltImage and then go to

Project->Properties->C/C++ Build/Setting/CMake configure  

and change the

 Command: cmake  

to

 Command: <path to builddir>/tmp/sysroots/x86_64-linux/usr/bin/cmake   

This will let Eclipse find the cmake in your build sysroot and use it.

Using host installed cmake

This seems to often work since cmake respects the cross compile variables fairly well. So, you can download an sdk without cmake in it, source the env script and then have a cmake project successfully build using the host cmake and the sdk toolchains. This becomes less likely to work in the case where we throw Eclipse into the mix, thus the above suggestions.