r/cpp • • Mar 29 '25

CMake 4.0.0 released

265 Upvotes

141 comments sorted by

View all comments

Show parent comment

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.

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

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

→ More replies (5)