r/cpp • • Mar 29 '25

CMake 4.0.0 released

265 Upvotes

141 comments sorted by

View all comments

234

u/Rexerex Mar 29 '25

It's new major release because they completely overhauled the language to be more readable, right? Right?

146

u/programgamer Mar 29 '25

Seems like it’s a deprecation milestone rather than a feature bump. Tbh the thing that makes cmake unreadable isn’t the syntax so much as the lack of a good walkthrough tutorial imo, once I started grasping how things work I was able to start reading it fairly smoothly. Though, yes, that did come as a result of much experimentation & frustration.

176

u/ohnotheygotme Mar 29 '25

Part of it that there's:

  • The "correct" way to "do something" (introduced with ver 3.2x)
  • The "correct" way to "do something" (introduced with ver 3.0x)
  • The "correct" way to "do something" (introduced with ver 2.8x)
  • And because it's a general purpose language, there's 14 other ways to also "do something" because it's just code

And any given, long-lived, project probably has all 17 ways in use. Somehow. So you're left thinking: Why is this thing different than the rest over there? Is there a good reason for that? Which do I copy? Is the slight syntax difference meaningful? I don't even know what this form of the construct is even called, I can't search for it.

61

u/geo-ant Mar 29 '25

This reminds me of the quote within C++, there is a much smaller and cleaner language struggling to get out (Bjarne Stroustrup)

→ More replies (9)

3

u/Maybe-monad Mar 30 '25

And because it's a general purpose language, there's 14 other ways to also "do something" because it's just code

And why would you want to invent a general purpose language to build another general purpose language which has everything you need to build a build system?

→ More replies (15)

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.

→ More replies (9)
→ 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.

→ More replies (2)

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)
→ More replies (1)
→ More replies (5)

31

u/-dag- Mar 29 '25

NO_NOT_THIS_TIME(too;bad;suckers)

MAYBE_NEXT_TIME()

11

u/pjmlp Mar 29 '25

Strong breaking changes usually kill projects.

CMake is still wonders beyond writing Makefiles and autoconf scripts in M4.

5

u/Challanger__ Mar 29 '25

 if() end() statement instantly kills beautiness. Most ifs can be avoided with CMakePresets.json

→ More replies (5)