On CMake


I’ve changed the build process of the RandFill project recently from using the Visual Studio files (*.sln, *.vcxproj, etc.) to maintaining and generating those with CMake.

RandFill might not be the ideal candidate for this switch, since it is (and will, for the foreseeable future, stay) a pure Windows/Win32 application; support for other platforms or development environments beside Visual Studio isn’t planned for now. But I always had a soft spot for text-based configuration and I was working on RandFill anyway at the moment.

Years ago, when I started with that little program, I used the MinGW compiler and even dabbled in working with makefiles. Then later on I used Visual Studio and after a while looked around again for a more modern alternatives to makefiles on Windows.

I discovered CMake and SCons as two possible build systems; CMake looked a bit strange, but SCons was interesting: It used the Python language, which I also had begun to use and like shortly before, and seemed sensible.

I experimented a bit with it, but in the end, I switched back to using Visual Studio directly again.
The most prominent argument on the internet against SCons seems to be that it’s too slow — can’t say anything about it, because my projects are too small as that it would matter.
What turned me off was, funnily enough, that you would have to write and maintain more-or-less python scripts.

Don’t misunderstand me: I still like and use Python, it’s a great general purpose scripting language — but using it just to kick off a build process didn’t feel right. It might come in handy if one has lots and lots of tasks in the workflow that needs extended scripting support, but that’s not the case for my projects (yet?).

Also, it was just a happy incident that SCons was using a language that I liked. Similar systems that used Java, Ruby or other languages weren’t on my radar because I didn’t want to learn yet another language for building my programs.

So I looked around again and CMake became rather popular over the years, thanks to some prominent open-source projects using it; it’s not really a build system like SCons, but a “makefile generator”: Meaning you configure the project settings (flags, paths, etc.) in a text file and CMake spits out the project files for whatever environment it should: Visual Studio, XCode, Makefiles, …

The syntax ist still weird and documentation is still a weakness (had to dig through tons of old mailing list messages, obsolete tutorials and ambiguous reference material on the net until the script made what I expected it to do; took me several evenings).

But for now I like what I have. We’ll see how it scales and how maintainable it is; maybe in a couple of months or years I’ll go back to pure Visual Studio, or investigate SCons again, or something completely different comes along…

Leave a comment

Your email address will not be published.