3 ms·
Everyone is entitled to their opinion, and I respect the one in the blog post. Here is mine: Half of the post complains about syntax. In my opinion, that's irr
by palata 4y ago
Everyone is entitled to their opinion, and I respect the one in the blog post. Here is mine:
Half of the post complains about syntax. In my opinion, that's irrelevant. If the `if() else() endif()` syntax is too hard to understand, good luck with modern software engineering, because you'll have to deal with many languages.
The "dealing with more complex projects" section actually shows a very simple project. IMO CMake should be just fine for that complexity, which encompasses most projects out there. If your project is too complex for CMake (and that happens, I don't deny it), then you are an exception, not the rule.
This said, the example creating a lib (lib/) and using it in a binary (exec/) in the very same project seems wrong (edit: I mean that the blog snippet seems wrong. Trying to have both lib/ and exec/ together is totally normal). I agree that `if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)` looks ugly, but I wouldn't blame CMake for that: I would refactor the CMakeLists instead, because it just seems wrong :).
"Weird function definitions" -> most of the time, functions are a coding smell to me. I always managed to not use them (or maybe I used one or two? I don't remember) and that's all fine. Projects that define a ton of functions get unreadable extremely quickly.
Admittedly, the syntax for installing the target is a bit weird. I wouldn't say it's impossible to get right, though. Usually it's similar to most of your other projects (so you essentially have to get it right once, then copy-paste), and it has to be done once per project. It's not that big of a deal.
Meson is cool, but I have seen messy Meson projects, like I have seen messy CMake projects. I wouldn't say Meson is that much better than CMake. And autotools is not that bad when done right.
- jvanderbot 4y ago> This said, the example creating a lib (lib/) and using it in a binary (exec/) in the very same project seems wrong. Not only is this a bog standard thing to do, it's really really easy with cmake. > refactor the CMakeLists Precisely. This is a totally normal organization just done incredibly badly.
- palata 4y agoThat's exactly what I meant. The example in the blog seems wrong. Of course having both a binary and a library in the same CMake project is totally normal. Let me try to edit my post :)
- ajross 4y ago> Half of the post complains about syntax. FWIW, a lot of complaining about syntax only looks like complaints about "syntax" to someone who already understands the tool. The problem with cmake is that it's underlying execution model is a huge frothing mess. Is that all-caps thing a variable name or a string or a special token being passed to the function to make it do something special? What's the difference between a target and a rule again? What's the difference between a property and a variable again? When do I need to manually expand list elements and when don't I? How does All That Wrapping work when I just want to pass one -fno-this-bad-warning flag?! To someone who knows cmake, all that fury sounds like someone complaining about mechanics. Cmake allows you to do all that stuff, just maybe with funny "syntax", so what's the problem? The problem is that even those of us who have to use it professionally, regularly, Just Can't Understand The Thing at anything more than a superficial level, despite knowing all our other tools with depth and grace. That's the sign of a bad tool.
- palata 4y agoI respectfully disagree. I could say the same about any programming language. What is this `if (...)` function? Where is it defined? Why are some functions already there, while others I need to write myself? How does memory work when I just want to run computations with data? What is the difference between a primitive type and an object again? What the hell is an anonymous function? I don't think it's that hard to learn the basics with CMake, and it's completely worth it when we have to use it professionally.
- kaba0 4y agoPeople have a mental model of programming languages, and a better language won’t make you question it all that much, most things should be somewhat understandable even by just knowing another language in the same paradigm. Cmake is its own universe of random conventions duck taped together, and is famously hated. It is a great tool in that cross-platform building of C/C++ programs is a very hard problem and it is the de facto choice for that since it can solve it, but that doesn’t make criticism of its abstractions/language less true. It really is terrible.
- BeetleB 4y agoI'm not a cmake guy, but seeing this: > If the `if() else() endif()` syntax is too hard to understand, good luck with modern software engineering, because you'll have to deal with many languages. Coupled with: > "Weird function definitions" -> most of the time, functions are a coding smell to me. I always managed to not use them (or maybe I used one or two? I don't remember) and that's all fine. Projects that define a ton of functions get unreadable extremely quickly. is weird. If you can't handle a lot of functions, you'll struggle with many languages. If a lot of functions is a code smell, then the problem is with the language.
- palata 4y ago> If a lot of functions is a code smell, then the problem is with the language. Let me kindly disagree :). You do not use a build system to write a complex program, you use it to call a compiler. You could run your compiler manually, but it doesn't scale. You could write a shell/python/lua/etc script that scales better, but nobody else will know it (and chances are that nobody will want to learn about it). By using a build system (autotools, cmake, meson, gradle, ...), you agree to use a standardized API to call your compiler. It doesn't really matter what API it is; what matters is that it is standardized: once you know it, you can build all the projects that use it. Now it is true that CMake projects are often a mess. Either because it's used incorrectly, or because it's doing a lot of magic with custom functions (and therefore it looks more like a custom shell script than a CMake project). Do I mean that CMake is perfect? Certainly not. But it doesn't suck either. And I see a whole lot of criticism coming from people who write messy CMakeLists. For a criticism to be constructive, it has to be informed.