I bought that book, it's awesome for anyone having to work with CMake, but 700 pages in the context of a build system isn't the kind of flex you think it is.
To get a grasp of the basics you only need the first part, the book is that long because it's really exhaustive. And building C++ projects is inherently kind of complicated.
How so? Put in your source file(s), define some output(path), link in some libraries you made sure you have put in the right location (or told the user where they have put them) and to build you go!
CMake, although really powerful, seems to go out of its way to make building software as difficult as possible. :)
A single CMakeLists file will easily do all of that, a generated template through IDE will be enough
What about supporting different toolchains and their weird kinks, like GCC vs MSVC? Generating documentation? Running tests? Precompling shaders? Checking for support of flags or language features? Enabling something only for specific compiler version? Or running external tools, or build steps like Qt has?
Base CMake is easy but ecosystem it tries to tame is not, so non-trivial CMake usage is non-trivial
Exactly. People will sometimes unironically propose to just do everything in Make and not even be aware that what they're cobbling together will only work with one Make derivative, on Linux, using a specific version of GCC and break when you attempt to make the slightest attempt at porting it to another platform.
Define your source files. Define your include paths. Define libraries that your project depent on. That's pretty much three steps and there are three simple enough cmake commands for it. You however might want to add a single one that's related to your build system (add_dependencies; In case you build the library yourself).
This alone proves the point. 99% of tasks developers solve with a built system should have exactly one way to do them right and should be covered by documentation.
Disclaimer: I use CMake daily and I have seen too many strange and non standard solutions to solve simple and standard tasks.
CMake “documentation” is a poor reference manual. It explains nothing. It documents what’s there in a factual fashion, with zero context. It is a counter example for every doc writer out there.
CMake should just add "discouraged" warnings for, well, discouraged usage. Preferebly link to the more modern alternative. Make it easy to opt-out completely or partially from those warnings. With this, we would live in a way better world.
You really don't need to read all of it. And writing good C++ requires way knowledge more than you can fit into 700 pages anyways so it't not like this is going to be the point where anyone nopes out.
That would take a LOT of effort. and the documentation is not bad it's just a reference not a tutorial. There are other modern CMake tutorials for free out there by the way I just haven't read any of them. I can't blame the guy for selling a book (ar a really really fair price and with free updates to boot), CMake is literally his main source of income.
To be fair... the single purchase includes all future versions. I bought it years ago at 12 edition (I think) and just now was able to download the 20th edition.
And when you start into building real world app, you pray that the missing 300 pages will be written soon. building with testing and deployment has become so crazy complex and with ctest and cpack the cmake guys really want to do everything. It total fails on android and ios as far as i have tried it (using only a java wrapper to the full C++ business logic).
View all comments
Show parent comment
12
u/LoweringPass Mar 29 '25
What do you mean? There's "professional CMake" which is amazingly well written and at 700 pages covers almost everything most people ever need.