Live data from Hacker News

Everything You Never Wanted to Know About CMake

izzys.casa

31–40 of 91 posts

Re: Everything You Never Wanted to Know About CMake

#31

I don't get the hate for CMake. It has several useful advantages over plain makefiles: * It's meant to be cross-platform, so a well structured CMake file will work in Windows. * CMake modules allow you to include source-based libraries without a lot of drama. This is especially useful for cross-compiling or embedded use-cases. * Out-of-source builds are supported with no additional work on my part. This is great for…

> It's meant to be cross-platform, so a well structured CMake file will work in Windows.

A well structured more conventional makefile can also run on Windows. The tree I'm working on builds for Unix and Windows with the same makefile. (No cygwin or WSL either, just GNU make running on Win32. A few ifdefs and strategically placed variables.)

Re: Everything You Never Wanted to Know About CMake

#32
The syntax of cmake is not very elegant, and error-prone. It also does not scale to large projects, configure times go up quickly. The documentation also leaves much to be desired.

That cmake is in the place it is nowadays is a reflection of the state of cross-platform build systems 10 years ago, and possibly some marketing.

Interesting alternatives worth checking out: Meson and gn (the latter can be used for building llvm)

Re: Everything You Never Wanted to Know About CMake

#33

I don't get the hate for CMake. It has several useful advantages over plain makefiles: * It's meant to be cross-platform, so a well structured CMake file will work in Windows. * CMake modules allow you to include source-based libraries without a lot of drama. This is especially useful for cross-compiling or embedded use-cases. * Out-of-source builds are supported with no additional work on my part. This is great for…

Comparing anything against plain Makefiles is a really low bar. Makefiles have been around since 1976. I think the hate for CMake comes from other directions entirely. The CMake scripting language is especially bad. Out-of-source builds were never really that hard in the first place. I think people hate CMake either because they were doing something slightly more unusual than CMake tolerated, or because they hated CMake's language (which is very easy to hate).

CMake has simply sucked less, overall, than the competitors of its time, for most common build tasks. That era is over, now that the new generation of build systems is here (Bazel, Buck, Pants, Please).

Re: Everything You Never Wanted to Know About CMake

#34

I don't get the hate for CMake. It has several useful advantages over plain makefiles: * It's meant to be cross-platform, so a well structured CMake file will work in Windows. * CMake modules allow you to include source-based libraries without a lot of drama. This is especially useful for cross-compiling or embedded use-cases. * Out-of-source builds are supported with no additional work on my part. This is great for…

> It's meant to be cross-platform, so a well structured CMake file will work in Windows. A well structured more conventional makefile can also run on Windows. The tree I'm working on builds for Unix and Windows with the same makefile. (No cygwin or WSL either, just GNU make running on Win32. A few ifdefs and strategically placed variables.)

On Windows, do you edit and debug your code in Visual Studio, or some other editor and just use the MSVC command line tools for building? Because one of the (very few) things I actually like about CMake is that it produces project files that Visual Studio can open directly.

Re: Everything You Never Wanted to Know About CMake

#35

I don't get the hate for CMake. It has several useful advantages over plain makefiles: * It's meant to be cross-platform, so a well structured CMake file will work in Windows. * CMake modules allow you to include source-based libraries without a lot of drama. This is especially useful for cross-compiling or embedded use-cases. * Out-of-source builds are supported with no additional work on my part. This is great for…

Yes, CMake let's you do great things, but holy moly is writing CMake files painful.

Re: Everything You Never Wanted to Know About CMake

#36
post #22

The thing I want most from a build tool is not a nice DSL or portability. What u want most is hermetic builds. There are only a few told out there that do it. CMake is not one of them.

What do you mean "hermetic" in this context, and why does CMake fail? Also, for my purposes (using both Windows and GNU/Linux at work), portability is a tremendous benefit.

In this context, "hermetic" means that for every step in the build, all inputs and outputs are known by the build system. Hermetic builds are reproducible, and can be more easily done by a distributed build cluster. Hermetic build rules can also be run in a sandbox, so you can have assurances that your build scripts are correct.

With non-hermetic builds, it's much more difficult to verify the correctness of your build rules, which means that you might get non-reproducible builds or you might get incorrect incremental builds. With hermetic builds, it's always safe to do an incremental build, no matter what state the repository is in.

Re: Everything You Never Wanted to Know About CMake

#39
post #22

The thing I want most from a build tool is not a nice DSL or portability. What u want most is hermetic builds. There are only a few told out there that do it. CMake is not one of them.

Which tools?

All of the newest generation of build tools.

- Bazel https://bazel.build/

- Buck https://buckbuild.com/

- Pants https://www.pantsbuild.org/index.html

- Please https://please.build/

Re: Everything You Never Wanted to Know About CMake

#40
post #2

I want to upvote this for solid info, but I want to flag it so fewer people have to know about CMake. It blows my mind that experienced software developers would develop yet another pseudo-language DSL vs creating a portable library (python, java, go, whatever) that has a sensible interface.

To be fair, CMake's language was first created somewhere back in 1996. It's quite old at this point and is basically in the "sunk cost fallacy" range of existence.
Post reply on HN