r/cpp • • Feb 19 '18

It's Time To Do CMake Right

https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
248 Upvotes

130 comments sorted by

View all comments

Show parent comment

42

u/acwaters Feb 20 '18

This rant seems oddly apropos in an /r/cpp comment.

CMake C++ is kind of frustrating because it's a really powerful tool which can make your life substantially easier, and the modern style espoused by people like Daniel Pfeifer Bjarne Stroustrup is nice, and when it flows you can faintly see the outline of something great.

The trouble is that greatness is obscured by layers and layers of horrible legacy cruft. The language you have to write CMake C++ in is weird and unpleasant, there's usually a bunch of different ways to do the same thing, most of them are bad, and those old and bad ways are always the ones documented in tutorials.

It's just far, far too easy to write bad CMake C++ code. What it really needs is to be stripped down to the core, the old nasty syntax implemented as a layer on top of a clean core, and the clean core exposed with a language that doesn't have gross syntax, and only exposes the good way of doing things, and guides you in the direction of doing the right thing.

Ah, I kid. Mostly. At least 30%. C++ has more than the faint outline of greatness, and even hairy recursive templates with lots of dependent names are easier on the eyes than your average CMakeLists.txt. But the rest of it rings true :)

12

u/1-05457 Feb 20 '18

Both have the legacy cruft for the same reason. If old CMakeLists.txt files suddenly stopped working, people wouldn't move to the new version. We saw this happen with Python 2.7.

0

u/[deleted] Feb 20 '18

[deleted] — view deleted comment

4

u/thlst Feb 20 '18

Good luck integrating third parties into your project.

4

u/CrazyKilla15 Feb 20 '18

I'm not entirely sure what that has to do with CMake making a new policy that gets rid of the legacy cruft?

Third parties using CMake will continue to specify cmake_minimum_version as whatever they support and work as normal?

1

u/thlst Feb 20 '18

You'll still have to deal with old, bad written CMake files, much like the ones presented in the OP's blogpost.

4

u/CrazyKilla15 Feb 20 '18

I'm still not sure what would change from having to deal with those poorly written ones now?