CMake is cross-platform build and configuration system for C and C++ code, which also happens to be my favourite build system. In this post, I’ll present a quick tutorial on getting started with CMake.
But before we do, let’s start with an example of why other build systems such as Makefiles don’t necessarily cut it. Actually, Makefiles work fairly well, but writing Makefiles by hand is generally a pain in the neck.
I’ve seen a lot of people (I’m looking at you Daniel Lemire) praise newer languages like Go, which makes me sad as a C++ programmer. Well, that’s until I realise that most of the features touted could be easily incorporated in C++ with just a bit of elbow grease. In this post, I’ll show how to add an automated testing system using CTest.
I use Linux when I work from home, I’m forced to use a Mac at work (well, I boot up a virtual Linux OS), and I use Windows when I just want to goof around with my computer. So, while most of my work is done on Linux, it’s imperative that my code work on all platforms; just because I could use any of the three.
Traditionally, C required multiple versions of code, protected by #ifdefs.
People familiar with the GNU/Unix system would know that the standard way to install about any GNU software from code is to run the following commands
configure make sudo make install These commands are from the GNU autotools environment. Knowing the GNU environment, these tools are what I used to compile most of the (relatively small) pieces of code I wrote.
Until I discovered CMake.
CMake, or Cross-platform Make is a tool that serves the same functionality as the GNU autotools (hereafter referred to as autohell).