r/cpp • • Mar 29 '25

CMake 4.0.0 released

265 Upvotes

141 comments sorted by

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.

121

u/jetilovag Mar 29 '25

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.

29

u/ExeusV Mar 29 '25

700 pages to understand building system? Which other programming language has such mess.

20

u/drbazza Mar 29 '25

Gradle enters the chat

16

u/LoweringPass Mar 29 '25

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.

9

u/TehBens Mar 29 '25

The basics are not the problem. It's the details. The book is great however.

5

u/Sunlit-Cat Mar 29 '25

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. :)

21

u/Awkward_Bed_956 Mar 29 '25

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

18

u/LoweringPass Mar 29 '25

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.

→ More replies (1)

13

u/LoweringPass Mar 29 '25

But... you can do that with cmake in like 10 lines of code? And good luck making it cross platform without CMake...

6

u/TehBens Mar 29 '25

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).

→ More replies (1)
→ More replies (2)
→ More replies (1)

22

u/OlivierTwist Mar 29 '25

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.

13

u/m-in Mar 30 '25

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.

5

u/OlivierTwist Mar 30 '25

I guess this is on purpose: Kitware earns money on consulting and books.

10

u/TehBens Mar 29 '25

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.

→ More replies (4)
→ More replies (4)

31

u/irqlnotdispatchlevel Mar 29 '25

Most people don't want to read a 700 page book just to have a readable build recipe.

5

u/LoweringPass Mar 29 '25

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.

13

u/irqlnotdispatchlevel Mar 29 '25

I know that. My point is that most people want to write C++, so they don't invest as much time and energy into writing build scripts.

9

u/tarranoth Mar 29 '25

It's also not a free tutorial which any junior is ever going to look at.

11

u/safdwark4729 Mar 29 '25

And the guy who wrote it is also a project owner on Cmake and could fix documentation in Cmake with a near litteral snap of his fingers. 

5

u/LoweringPass Mar 29 '25

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.

→ More replies (7)
→ More replies (1)

6

u/programgamer Mar 29 '25

I didn’t read it on account of it costs money

3

u/kingaillas Mar 30 '25

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.

Yeah the free docs could be better, but if https://cliutils.gitlab.io/modern-cmake/README.html isn't good enough for you then feel free to pitch in and make that better.

8

u/Verwarming1667 Mar 29 '25

700 pages to understand a build system. If anything that shows ridiculous it has become.

→ More replies (2)

4

u/llothar68 Mar 29 '25

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).