the jenny jam blog

CMake: the Good, the Bad, the Weird

CMake is one of the most popular build systems in the C/++ ecosystem according to a few recent developer surveys (IsoCPP survey, CLion Survey).

At the same time, it's kind of an infamous one -- anytime I see it mentioned, I see a lot of negative feelings and opinions toward the language. I think it's important to acknowledge peoples feelings and where they are coming from and their frustrations -- I have certainly ranted to my friends about CMake when I've been stumped by it before!

But I also find the build system useful, so inspired by the Lua: The Good, the Bad, The Ugly I'm going to try to articulate my thoughts on what's good about it, what's bad about it, and what's kind of just a weird quirk about it.

I also strongly recommend for any developers who are learning or struggling with CMake to purchase Professional CMake -- I have found it very helpful in explaining things where most other resources haven't, and it is consistently updated with new major versions of CMake.

The Good

The Weird

The Bad

So, is CMake worth it?

It depends on you and your project!

I think Cmake has a ton of benefits, but a huge learning curve and plenty of issues. I think the friction the defensive boilerplate coding required for CMake is maybe not worth it for exploratory or prototype code, but at the same time I think the benefits for very large codebases are worth it.

At the same time, if you find yourself doing just fine with Makefiles, or Meson, or SCons, or Bazel, or xmake -- keep doing what you're doing! Build systems are to help build a project, and if you're use case is being met then I don't think you need to switch over to a new build system for hazy network effects.

It's totally possible that in the future, CMake becomes a legacy thing that has a similar reputation to autotools, but for now it is if anything growing in use and adoption.

I also personally think build tools need more love: it's easy to ignore them because they are cost centers for developing code, but they are a vital part of the development, release and management lifecycle.