Using your custom CMake toolchain

OUTDATED: Check the new way to customize your toolchain with biicode in this post: Raspberry PI cross building native (C/C++)

Step by step we are making biicode easier to customize, our latest addition is to allow users using a custom CMake toolchain instead of the autogenerated one.CMake toolchain is easier to customize now with biiicode

The problem with CMake toolchains

The main problem achieving this is that toolchains have absolute routes to compilers so they are difficult to share as part of a biicode block so, in addition to providing toolchain customization we also provide a token replacement system which you can configure in your project settings.

Example of how to customize CMake toolchains

Take the block fenix/armadillo. It requires gcc >= 4.7.2 to compile, but the default rpi compiler is 4.7.1, so we’d like to define our toolchain and share it so other people can use it. Biicode installs different rpi compilers in BII_ENV folder, so you can choose a different one for this task. You can create a toolchain file in your block like this:

Now if you want to use this toolchain you can modify your project settings to include the bold line:

If you want to share your toolchain with people reusing your block you will also need to add it to your bii/dependencies.bii (inside your block):

And that’s all, this will work for anyone that has installed cross compilers by running

bii setup:rpi. BII_ENV will expand to default bii tools installation directory. But you can provide even more flexibility to your block’s users and allow them to use any compiler they want by defining replacement tokens, for example:

Then you can set your settings as follows:

Conclusions

Some times our users make us realize we are not providing them all the flexibility they need. Adding this feature was quite easy in fact, but without your feedback we would not have thought of it.

So please keep contributing with your ideas, unresolved problems and opinions. I hope you liked the example and if you have any doubts or questions please feel free to comment the post, share it in our Forum or check our Documentation.


Related Posts
  • Luis Díaz Más

    This new feature is great! I can’t see the moment of taking my Rpi and try this :)