r/cpp • • Mar 14 '21

CMake IS a Build System

https://alexreinking.com/blog/cmake-is-a-build-system.html
7 Upvotes

16 comments sorted by

20

u/khleedril Mar 14 '21

Wow, an entire essay on pedantry!

10

u/AlexReinkingYale Mar 14 '21 edited Mar 14 '21

You're not wrong!

Edit: the essay itself is about how this particular bit of pedantry makes it harder to understand CMake, not easier. It's not (trying to be) pedantic on its own.

3

u/wrosecrans graphics and network things Mar 18 '21

I have described the CMake devs as people who think it's reasonable to say, "I don't make the rules, I just write them."

8

u/[deleted] Mar 14 '21

As the Internet intended.

3

u/goranlepuz Mar 15 '21

This is from his blog post "The F5 Key Is Not a Build Process". This was written a while ago, in 2007, somewhat before CMake became wildly popular. It was also written in the context of C#, which is more tolerant of "just click 'build' in Visual Studio" workflows than C++, which isn't managed.

Funnily enough, "just click build", for C++, is likely some 20 years older than C# itself. 😉

In Visual studio, it is also older than C#.

1

u/AlexReinkingYale Mar 15 '21

That's a really good point! I'm showing my youth here. I got started programming in 2002.

8

u/helloiamsomeone Mar 14 '21

While still being correct, but avoiding this argument, I just call CMake a build tool. Whether it's a build system or not, it is still a tool to build software, so the build tool name just removes this aspect of the discussion altogether.

0

u/pdimov2 Mar 16 '21

As I like to say, if you see people repeatedly insisting that X is not Y, this typically means that X is Y, but not a very good Y.

0

u/[deleted] Mar 14 '21

[deleted]

3

u/AlexReinkingYale Mar 14 '21

That is absolutely correct! :)

-2

u/victotronics Mar 14 '21

If the target language is both easier to write and easier to debug, what's the point of the source language?

20

u/AlexReinkingYale Mar 14 '21

None, obviously, but that isn't the case here. CMake scripts are significantly more portable across operating systems and compilers/toolchains than raw Makefiles or especially IDE projects.

I don't know if you've ever had the experience of writing an NMake (Visual Studio) and GNU Make polyglot Makefile, but it's awful if not impossible in some scenarios.

-14

u/victotronics Mar 14 '21

My only target platform is Unix, so I compare CMake to Make and then I vastly prefer Make. I can debug Makefiles; for CMake I pretty much have to contact the developers.

And I'm not sure about portability. Usually I have to supply at least two dozen commandline defines before CMake properly installs a package. The difference between doing that and having a Make.inc file is vanishingly small to me.

9

u/almost_useless Mar 14 '21

May I ask what you are trying to do where cmake gives you such big problems? We have also had some problems, but none of the magnitude where Make would be easier.

How do you get Make to install packages?

-4

u/victotronics Mar 14 '21

Well, I often have to install one application library that builds on a couple of other application libraries. Which means that I have to tell it about compilers (note that I have half a dozen compilers on the system), python (any of several available versions), Blas/lapack, where the other application libraries are, disabling this, enabling that, ....

With Make you'd have a make.in file that has a list of macros that you need to fill in, which is exactly the same amount of work. So CMake doesn't help me squat, but is harder to debug.

How do you get Make to install packages?

What is a package? I know about executables and libraries.

12

u/almost_useless Mar 14 '21

So CMake doesn't help me squat, but is harder to debug.

But writing the cmake file is usually easier than the corresponding Makefile.

What is a package? I know about executables and libraries.

Package was your word from the previous post, so I assumed you knew what it meant :-)

But including external libraries is significantly easier with cmake in my experience. Sometimes as easy as adding the url where the sources are located, and *boom*, it works automatically with every different compiler.

0

u/[deleted] Mar 14 '21

[deleted]

0

u/tarranoth Mar 15 '21

I've been working with somewhat templated msbuild files for some time, and honestly once you get used to it, it isn't any harder than cmake. In fact I think it is easier to have some custom targets/scripting going on than it is in cmake. The real downside is that ninja is just plain faster in detecting no-ops usually, so if possible, you should probably stick to that.