YOCTO PROJECT

# Using CMake With The SDK

Article by:

## Overview

Although Yocto seems to use Autotools more than CMake, you can easily configure a generated Yocto SDK to include all the neccessary tools so that you can build a targeted software application using CMake instead (which, IMO, is much better than Autotools).

## Add CMake To The Yocto SDK

This first thing is to add the CMake binary to the Yocto SDK. This version of CMake will be set up exactly as needed to build applications for your target architecture (which is typically not the same as your host/development system!).

 1  TOOLCHAIN_HOST_TASK += "nativesdk-cmake" 

Then rebuild the SDK command with:

 1  ~/poky/build$bitbake core-image-minimal -c populate_sdk  Replacing core-image-minimal with a different target if needed. ## Install The New SDK Now install the new SDK:  1  ~/poky/build/tmp/deploy/sdk$ ./.sh 

The new SDK should contain cmake.

## Source Environment Variables And Build

Because you are now going to be using a custom version of cmake, you don’t have to modify the CMakeLists.txt of the project you are building!

Before building, source the environment setup script.

 1  $source environment-setup-  This will create an alias to cmake. You can check this by running the command which cmake.  1 2  gbmhunter@ubuntu:/opt/poky/2.2.1$ which cmake /opt/poky/2.2.1/sysroots/x86_64-pokysdk-linux/usr/bin/cmake 

Now go to the root directory of the CMake project you wish to build and use the standard CMake process as below:

 1 2 3 4  ~/$mkdir build ~/$ cd build/ ~//build$cmake ../ ~//build$ make 

The above assumes CMake will use make to do the actual building, but this could be different.

## Authors

### Geoffrey Hunter

Dude making stuff.