News for hackers. Stuff that matters.
Re:Ray Tracing in pure CMake by MaxBarraclough on Saturday January 09, 2021 @10:05AM (#25700881)
I agree that CMake is pretty awful, [0] but I'm not convinced that we'd be better off using its immature competitors, especially considering the fragmentation that would bring.

[0] https://news.ycombinator.com/item?id=24203172

Re:Ray Tracing in pure CMake by ajconway on Saturday January 09, 2021 @01:17PM (#25702889)
There seems to be a kind of “network effect” here with CMake, considering how popular it is among C/C++ projects.

Meson is more or less equivalent in the functionality it provides. There is also Gradle, but it doesn’t seem to have gained much traction outside of Android development.

My personal favorite is Bazel (and others from the Blaze family of build systems). It uses a python-based language for describing build rules, an extensive documentation and developers that respond to issues. Among the downsides is the lack of proper dependency management which is critical for public, open source projects.

There is also Nix which takes it even further, but it requires much more involvement from the developer.

Re:Ray Tracing in pure CMake by milanove on Saturday January 09, 2021 @01:40PM (#25703129)
Waf is another interesting build system I've seen used in production. It's config is done with Python scripts, which is cool.
Re:Ray Tracing in pure CMake by MaxBarraclough on Saturday January 09, 2021 @02:19PM (#25703589)
There's also Premake, [0][1] Buildout, Ninja, SCons, and no doubt there are others. qmake was recently deprecated.

It would take a lot to persuade me to move away from CMake and to use something 'non-standard' that few developers are familiar with:

* Excellent support for command-line builds on Unix

* Excellent support for Visual Studio

* Excellent cross-platform package-detection. (Acid test: Can it detect and link against OpenCL without me having to write my own cross-platform OpenCL-detection script?)

* Excellent documentation, including clear and consistent best practices and design patterns

* A sensible language, whether a scripting language or a declarative language. Must follow the principle of least astonishment and be relatively free of foot-guns. (CMake fails tragically on both counts.)

[0] https://premake.github.io/

[1] https://en.wikipedia.org/wiki/Premake

Re:Ray Tracing in pure CMake by knorker on Saturday January 09, 2021 @04:13PM (#25704812)
I can't speak for MSVC support, but to me CMake fails all other bullet points. especially cross-platform package detection.

I haven't seen anything except autotools get this right.

Re:Ray Tracing in pure CMake by MaxBarraclough on Saturday January 09, 2021 @05:22PM (#25705551)
> especially cross-platform package detection

I disagree here. CMake has working FindXyz modules for most major libraries. To write one of those modules is an exercise in soul-destroying tedium, but there's a pretty impressive body of existing modules out there, many of them officially bundled with CMake.

When used correctly, both CMake and Autotools are capable of robust package-detection.

Regarding point 1: CMake works pretty well on Unix, but it's a pity there's a runtime dependency on the CMake package. Autotools is much better in that particular regard: just about any Unix system can run a configure script, as it's just a plain old shell script.

CMake certainly falls short on the final 2 points, as I rambled about at https://news.ycombinator.com/item?id=24203172

It's too late for me to edit my earlier comment, but here's another alternative to CMake for the list: Bazel.

Re:Ray Tracing in pure CMake by tn1 on Saturday January 09, 2021 @10:52PM (#25709574)
> CMake has working FindXyz modules for most major libraries

Unless you have that library installed anywhere that is not /usr/include Then you have to just hope and pray that there's some magic incantation that will make it find the right one (especially if your system-installed version is the wrong version and you'd really like to use the newer version you installed to $HOME)

Re:Ray Tracing in pure CMake by MaxBarraclough on Sunday January 10, 2021 @06:29AM (#25713618)
Right, but it's always like this. If you're on Windows and you install Boost to C:\random\directory, it seems fair that CMake will require you to specify that directory manually.

The alternative is to have a global database, like the Windows registry or like pkg-config (which I have to admit I don't know much about). Perhaps CMake could have better support for pkg-config, I don't know.

Re:Ray Tracing in pure CMake by slavik81 on Saturday January 09, 2021 @04:24PM (#25704917)
I used Waf before I tried CMake, and I found the latter much easier to understand. The CMake language is a mess, but the compilation model is simple.
Re:Ray Tracing in pure CMake by jcelerier on Saturday January 09, 2021 @04:10PM (#25704780)
> Meson is more or less equivalent in the functionality it provides.

but meson needs everything to be quoted which is frankly a gigantic PITA - like, look at that, there's more quoted stuff than anything else: https://mesonbuild.com/Generating-sources.html

Re:Ray Tracing in pure CMake by MaxBarraclough on Saturday January 09, 2021 @05:10PM (#25705425)
I've not used it, but that wouldn't bother me too much. It's far preferable to a language like Bash where you're permitted to omit quotes, but consequently it's a minefield to write scripts that can robustly handle strings containing whitespace (e.g. arbitrary file paths). The Ada philosophy has it right: readability and correctness far outweigh writeability.
Re:Ray Tracing in pure CMake by jcelerier on Saturday January 09, 2021 @06:20PM (#25706158)
> The Ada philosophy has it right: readability and correctness far outweigh writeability.

Given the popular success of Ada I'm not sure I would call that "having it right" except in very specific circumstances

Re:Ray Tracing in pure CMake by MaxBarraclough on Saturday January 09, 2021 @07:00PM (#25706558)
There are various reasons Ada didn't take over the world, I'm not convinced that its emphasis on readability over writeability is one of them. Far more time is spent on maintaining code than on initial development, and anyway, typing speed isn't the bottleneck for writing new code.

Code review? You're in the business of reading code. Fixing bugs? You're in the business of reading code. Modifying/extending/porting an existing codebase? You're in the business of reading code.

If you're writing trivial single-use 'throwaway' code that needs no review, then readability doesn't much matter, but it's an important factor for just about all serious codebases.

Of course, there's also the question of whether Ada's specific syntax really succeeds in being more readable. It makes extensive use of English words in ways that are sometimes awkward and unnatural. I'm not a fan of its and then / or else short-circuit operators, for instance, and think they should just have gone with something like C's && / || operators. Neither syntax is self-explanatory to someone who doesn't know the language, but at least C's syntax doesn't counterintuitively collide with English.

Re:Ray Tracing in pure CMake by mhh__ on Saturday January 09, 2021 @01:30PM (#25703021)
I'm increasingly convinced that a script in a real programming language is the way forward.

The D compiler used to have a bunch of fairly flaky makefiles (different make vendors => pain), but now there's a shebang script written in D that not only does it's job well but also handles args properly and to top all that off is actually readable by people who aren't used to building software on Linux

Re:Ray Tracing in pure CMake by kortex on Saturday January 09, 2021 @05:14PM (#25705464)
What we could really use is some new declarative syntax that interoperates with existing cmake projects.

There is already talk of such a system and even some implementations. I am sure many people have thought to themselves "This is so complicated! So much legacy cruft! I bet I could build a way cleaner c/c++ build system! " only to run into all of the complexity of cross platform c++.

I highly doubt there will be a cargo for c/c++, because it simply isn't rust.

https://gitlab.kitware.com/cmake/cmake/-/issues/19891

https://gist.github.com/stryku/4c69aa510711c9da6705fa4df4545...

Re:Ray Tracing in pure CMake by humanrebar on Saturday January 09, 2021 @05:21PM (#25705549)
I like declarative approaches, but there's such a long tail of weird things to support. I'm skeptical something declarative can do the job on its own.

Maybe some time after modules become available and then a known quantity.

Re:Ray Tracing in pure CMake by kortex on Sunday January 10, 2021 @09:19AM (#25714817)
The discussions mention this. Any such system would likely need to interoperate with existing building system, and serve as the leaf nodes wherever possible.
Re:Ray Tracing in pure CMake by jcelerier on Sunday January 10, 2021 @06:58AM (#25713822)
QBS was such an attempt to declarative building in C++ in a declarative way which looks sooo elegant on a first glance, and we all saw how well it did work out (it did not)
Re:Ray Tracing in pure CMake by kortex on Thursday January 14, 2021 @03:46PM (#25782240)
What was the issue with QBS? The syntax looks clean and concise. Seems like the main issue is lack of traction.