Advent 2021: CMake
This blog is part of the 24 posts long series "Advent 2021":
- Advent 2021: Intro (December 01, 2021)
- Advent 2021: C++ (December 02, 2021)
- Advent 2021: C# (December 03, 2021)
- Advent 2021: Python (December 04, 2021)
- Advent 2021: Go (December 05, 2021)
- Advent 2021: TypeScript (December 06, 2021)
- Advent 2021: CMake (December 07, 2021)
- Advent 2021: Django (December 08, 2021)
- Advent 2021: Angular (December 09, 2021)
- Advent 2021: Flask (December 10, 2021)
- Advent 2021: gRPC (December 11, 2021)
- Advent 2021: GraphQL (December 12, 2021)
- Advent 2021: XML & JSON (December 13, 2021)
- Advent 2021: Matplotlib, Pandas & Numpy (December 14, 2021)
- Advent 2021: Linux (December 15, 2021)
- Advent 2021: Ansible (December 16, 2021)
- Advent 2021: SQLite (December 17, 2021)
- Advent 2021: Catch2 (December 18, 2021)
- Advent 2021: Zstandard (December 19, 2021)
- Advent 2021: ZFS (December 20, 2021)
- Advent 2021: Thunderbird (December 21, 2021)
- Advent 2021: Visual Studio Code (December 22, 2021)
- Advent 2021: Blender (December 23, 2021)
- Advent 2021: Open source (December 24, 2021)
I like C++ the language, and historically the worst part of C++ has been – building C++ projects. It used to be a chore at best, with build systems ranging from “opaque” (Visual Studio project files) to “arcane” (Makefiles with Configure/Automake.) Fortunately, the situation did improve over the years, and my big a-ha moment was the day I learned about CMake. Out of curiosity, I spent some time digging around in the history of my (relatively large) home framework and tried to figure out when that day was. Turns out, I switched to CMake on the 28th of February, 2008 – over 13 years ago.
Over those 13 years, I did learn to appreciate CMake, and there are several reasons why I still pick CMake as my default build system for C++ projects. The main reason is stability. CMake is one of those projects that has been around for long and is a rather conservative project. Even today it still supports files from 10 years ago. In fact, I’ve been very aggressively moving to new CMake releases as they become stable and never did it fail to build an old CMake project that wasn’t upgraded. In today’s world of “move fast & break things” that’s really refreshing to see.
The fact that it “just works” is more remarkable if you consider the changing environment. Finding dependencies and keeping up with new compilers is a real chore and CMake does an admirable job keeping everything and everyone working.
Finally, CMake is constantly getting updated and doing so in a way that makes modern CMake much simpler and safer, while not breaking existing code. You can easily and gradually migrate and not have to worry. This new way of CMake very much reminds me of how C++ is evolving, and I do enjoy writing new projects from scratch in CMake as it means I can write really simple, easy to understand build files. I’m looking forward to what the next 10 years of CMake will bring, and if you are writing C++ and haven’t used it, I hope you give it a shot!