Publish, share and reuse CMake macros

CMake Macros for everyone!

There were many great reasons to develop this feature, main is that you want it and as fun as Mastering CMake can be, this feature is a way to reuse CMake “recipes”, don’t repeat yourself.



Publish, share and reuse CMake macros/scripts and use any “recipe” in your CMakeLists.txt.

Reusing CMake code is as simple as  “#including” libraries in C++.


And execute bii find to download the dependency as usual:

Once done, you can finde your CMake dependencies in your  project/deps/user/block folder.

Example: how to activate C++11 flag with a macro in biicode?

“biicode” featured user has a block named cmake where you can find useful macros from the tools.cmake file, like one to activate C++11 flags for any OS, or to link a OSX framework to a target, etc.

Follow this example to understand it fully, start creating a project:

and create the files below into your user/hello_cpp11 folder:


This is the basic CMakeLists.txt file with an include: INCLUDE(biicode/cmake/tools) and a line to use the Macro:


Execute bii find to download the dependency as usual and bii cpp:build to compile:

Now you’re ready to run your executable, it’s in your cpp11/bin folder:

I hope you enjoy this new feature and, as always, we look forward to read what you think. Just click on the sidebar button to try biicode, check our docs, forum and/or Stackoverflow tag for questions and answers.

Related Posts