I love build tools, and CMake has great potential. The documentation and examples aren’t great though. Here’s my journey so far…
What is CMake?
If you’ve not come across it, CMake is a cross platform build tool. Given a single project definition of dependencies, components, libraries, and executables, CMake can generate system-specific build configuration for many platforms. You are then free to use the development tools of your choice.
A single definition allows generation of Unix Makefiles, Eclipse project files, Mac XCode project files, and Visual Studio files, to name but a few.
This means supporting cross platform development is much easier… In theory.
Sounds too good to be true!
Of course the devil is in the detail. CMake’s strength is its flexibility… Its weakness is that this flexibility means you can construct the files in a number of ways to accomplish the same task. This can make it hard to learn and to find examples to apply to your own project.
Think of CMake as the Perl of build systems.
The documentation on cmake.org isn’t the easiest to follow either. Descriptions are provided for common CMake tasks, but no real world examples for how they are used.
Equally, as we all know, build settings need to be tweaked depending on Operating System and Compiler used. These are left for the CMake build file developer to fathom.
This at least gave me a working build I knew would link with their cpprest (aka casablanca) library.
From there the real fun began…
Adding Doxygen documentation build support, supporting Mac OS X Universal Binary builds (archaic I know… don’t ask…), supporting make install and CPack…
I’m still not quite complete. For example, installing dependencies before build isn’t generally supported – CMake assumes all dependencies exist and just ‘discovers’ their location/settings on your machine. No links to npm/yum/brew/nuget or the like.
In short, there’s a lot of leg work to get CMake working.
I don’t want to appear all negative and shouty. I love CMake. It’s just that the documentation ain’t great.
The CMake files I have now for example are positively well laid out, logical, and even quite pretty (for a text file…). It’s taken a lot of effort to get there though.
I’d love to spend some time documenting a set of basic tutorials for CMake using a real library as an example… It’s just getting the time as ever, isn’t it?
I certainly wish that the excellent people behind CMake spend more time pretty-fying their website and generating good tutorial documentation.
CMake could easily become the build system of choice if they spent just a little time working on docs, and CMake’s integration with dependency tools, and install tools – not just build tools.
If I get time I’ll certainly write a few blog posts about it, and provide some sample project folders. In the meantime if you have some great resources for CMake, please add a comment and share with the community!