I would like to share my experiences with CMake.
I started using CMake because I needed a cross-platform build system for
making UHD and I stumbled upon CMake. After learning CMake and building
UHD on-top of it, I can conclude that CMake is indeed awesome.
– OK, what is it?
CMake is a cross platform build system. In short, it translates a
description of your projects build rules and files and generates a
platform specific build system. This means that it not only generates
Makefiles (like autotools), but can also generate eclipse project files,
xcode projects, MSVC projects, and more.
– How does it compare to autotools?
- Project description:
In autotools there is there *.m4/Makefile.am/configure.ac/bash
dichotomy. With CMake, the project description goes into one type of
file, written in one scripting language. Now the language is CMake’s own
invention. I don’t know why they reinvented the wheel, but its dead
simple and very powerful.
This way, a projects configuration, sanity checks, library setup, target
setup, etc, can occur all in the same environment and only at the scope
or level that it needs to be introduced.
- CMake is fast:
Ever watch the paint dry after changing something in an m4 file? With
CMake, it just knows what “going on”. Change something and type make,
and only the smallest delta to meet the dependencies will be affected.
In addition, there is only 1 level of generation (CMake just generates
- CMake makes packages:
It generates debs, rpms, windows exes, mac packages…
- Configuration gui:
You could enable components and set paths with command line switches,
but CMake has a gui for this as well (even one in ncurses). Suppose you
want to enable a component during configuration, its as simple as
checking a box.
- No convenience libraries:
I miss them, it would be convenient to have, but its more than possible
to do without them.
– Example of a stand-alone gnuradio project with CMake
I put together a CMake build system for a gnuradio project. So, I
CMake’d up gr-uhd in the style of how-to-write-a-block. It handles
library, headers, swig, grc, and some generation. The CMakeLists.txt
files are sitting along side the Makefile.ams on this branch:
The CMakeLists.txt may seem quite wordy, but keep in mind that most of
this business could be moved out into a set of cmake includes with
common configuration setup and macros/functions.
Compare gr-uhd/swig/CMakeLists.txt to gr-uhd/swig/Makefile.swig.gen +
Makefile.am and you will see what I mean.
Here is the verbose from the build process:
– Knocking on autotools:
I tried not to bash autotools too hard. But seriously, the gnuradio
gurus have put in a massive amount of effort to work around the
limitations of autotools. Maybe some share my sentiments.
KDE thought switching its build system to CMake was a good idea:
Going forward, when the gnuradio source gets the much needed
reorganization, I hope that the gurus will consider CMake for all the