How many years has it been since you last used CMake?
CMake suffers from some of the same perception issues as C++. A lot of the criticism usually boils down to the designers prioritizing backwards compatibility, a thing even critics would agree is a good thing. As an example, the OP shows a CMake and Meson snippet. The CMake one is 3 lines, the Meson one is 2. The extra line in the CMake sample is a version declaration for backwards compatibility, but the rest are identical.
If you look past your preconceived notions, you’ll find that CMake is a good build system and very easy to use. It’s also one of the few that fully supports C++20 modules today.
It’s by no means a silver bullet, and the generator-based design isn’t always the best choice, but its undoubtedly the best choice for the vast majority of C or C++ projects.
Out of curiosity, why do you consider CMake to be the better choice compared to Meson?
Personally I landed on Meson a few years ago, from what I remember chiefly due to simply not liking CMake’s DSL and finding Meson easier to work with, despite needing to target a pretty old version for the sake of compatibility. Though Meson is definitely not perfect either; it’s highly opinionated, and for example only recently got support for custom build targets putting stuff in sub-directories (as I discovered while writing this comment), so I’ll personally be stuck with my workarounds for a good while longer
I was never convinced by Meson’s value proposition. From what I remember, it was always just meant to reinvent CMake with a different DSL. Like, literally just CMake but slightly different.
I understand CMake’s DSL isn’t the prettiest, but as far as improving ergonomics of a build system, minimizing the amount of build scripts you write is far more effective than changing the syntax. If you find yourself writing too much CMake in a project, then switching to a build system with a different design (eg Bazel, Scons, Waf, …) is probably the better choice.
And of course, since Meson is just a CMake clone, it’s always going to be compared to it, and its always going to have to compete on features. On that front, CMake has always been ahead, and I don’t see that changing. So in the end, Meson is just another example of that one XKCD meme about standards.
I have not previously heard Meson described as a reinvention of Cmake or a CMake clone, nor that it was meant to be. I would think that Meson being as opinionated as it is, including for example the fact that it does not and will not support user-defined functions, precludes it from being a CMake clone. It seems instead to be a build-system with a rather different philosophy and feature-set compared to Cmake. But if that philosophy or that feature-set does not match your needs, then there’s obviously no reason to pick it over CMake
We don’t have anything better, alas. All those build systems are crazy. Yes, CMake is crazy. And ugly. And inconvenient.
How many years has it been since you last used CMake?
CMake suffers from some of the same perception issues as C++. A lot of the criticism usually boils down to the designers prioritizing backwards compatibility, a thing even critics would agree is a good thing. As an example, the OP shows a CMake and Meson snippet. The CMake one is 3 lines, the Meson one is 2. The extra line in the CMake sample is a version declaration for backwards compatibility, but the rest are identical.
If you look past your preconceived notions, you’ll find that CMake is a good build system and very easy to use. It’s also one of the few that fully supports C++20 modules today.
It’s by no means a silver bullet, and the generator-based design isn’t always the best choice, but its undoubtedly the best choice for the vast majority of C or C++ projects.
Out of curiosity, why do you consider CMake to be the better choice compared to Meson?
Personally I landed on Meson a few years ago, from what I remember chiefly due to simply not liking CMake’s DSL and finding Meson easier to work with, despite needing to target a pretty old version for the sake of compatibility. Though Meson is definitely not perfect either; it’s highly opinionated, and for example only recently got support for custom build targets putting stuff in sub-directories (as I discovered while writing this comment), so I’ll personally be stuck with my workarounds for a good while longer
I was never convinced by Meson’s value proposition. From what I remember, it was always just meant to reinvent CMake with a different DSL. Like, literally just CMake but slightly different.
I understand CMake’s DSL isn’t the prettiest, but as far as improving ergonomics of a build system, minimizing the amount of build scripts you write is far more effective than changing the syntax. If you find yourself writing too much CMake in a project, then switching to a build system with a different design (eg Bazel, Scons, Waf, …) is probably the better choice.
And of course, since Meson is just a CMake clone, it’s always going to be compared to it, and its always going to have to compete on features. On that front, CMake has always been ahead, and I don’t see that changing. So in the end, Meson is just another example of that one XKCD meme about standards.
Thank you for the answer!
I have not previously heard Meson described as a reinvention of Cmake or a CMake clone, nor that it was meant to be. I would think that Meson being as opinionated as it is, including for example the fact that it does not and will not support user-defined functions, precludes it from being a CMake clone. It seems instead to be a build-system with a rather different philosophy and feature-set compared to Cmake. But if that philosophy or that feature-set does not match your needs, then there’s obviously no reason to pick it over CMake