6 ms·
An Introduction to Modern CMake
- xvilka 2y agoEven latest CMake version still has that terrible syntax. If they want to survive the competition, at some point they need to provide (an option at least) another, proper syntax.
- djenndhxhd 2y agoYea no. Syntax is just that, syntax. If anything is holding back CMake, it's the strongly typed core. Nevertheless, CMake is simple. There currently nothing convincingly better for the general case.
- wiseowise 2y ago> Yea no. Syntax is just that, syntax. If that was the case, Gradle wouldn’t move from Groovy to Kotlin.
- whatsakandr 2y agoIt would be nice if it just became a python interpreter. The concepts and build that CMake has is pretty good, but implementing it is a pain due to the quasi shell syntax.
- imglorp 2y agoThese guys had a competition way back and settled on python. https://www.scons.org/ https://www.scons.org/
- kstrauser 2y agoWhat’s the competition these days? I've never seriously used anything beyond plain old Make for my C/C++ projects, but that's more because they were dead simple and didn't justify the big-project features. What would someone use to build more complex things?
- TimorousBestie 2y agoMeson and Bazel are the primary contenders in CMake’s market, as far as I can tell.
- bonzini 2y agoEither CMake or Meson. If you never felt the need to move beyond Makefiles, Bazel is almost certainly too complex.
- w4rh4wk5 2y agoIn the realms of Windows and game development you primarily use Visual Studio Solutions / projects with property sheets. The underlying build system is msbuild. It is less powerful than CMake and has a relatively steep learning curve due to poor documentation. But once you get the hang of it, it's actually pretty straight forward with just a few pitfalls here and there. You simply have to accept that certain things are not possible... but chances are, these things can't even be done easily in CMake either.
- cassepipe 2y agoI like xmake, it's fast and it's a lua file, so no DSL https://xmake.io/ https://xmake.io/
- pyjarrett 2y agoFASTBuild[0] is super fast for large projects and comes with distributed builds and caching out of the box. It requires a bit of effort to set up, but it supports globbing sources, there's no separate generate build step, and it can also make Visual Studio solutions. [0]: https://www.fastbuild.org/docs/home.html https://www.fastbuild.org/docs/home.html
- AlotOfReading 2y agoNever going to happen. The kitware folks are aware of how bad the cmake language is, but they would rather corral it into a semblance of sanity (e.g. actual types rather than everything being stringly typed, eliminating the imperative stuff) than provide a different language. Have to say I agree. Anyone who wants to use a different language should really look at a different build system. It would about the same amount of pain.
- wiseowise 2y agoModern CMake is Bazel or Gradle. takes cover
- jedisct1 2y agoI'm switching all my C projects over to the Zig toolchain, and honestly, I'm not looking back.
- david2ndaccount 2y agoYou’re switching to the build system of a different, pre 1.0 programming language that has frequent breaking changes?
- bitwize 2y agoZig has a built-in C compiler, arguably one of the just-worksiest C compilers out there.
- unclad5968 2y agoThe Zig build system is basically cmake except worse but in Zig.
- ndiddy 2y agoCMake gets a lot of hate because a lot of large projects use it poorly and the syntax is strange, but I've found it invaluable for projects I've worked on. The first page of this site has a great list of reasons why someone would want to use CMake. I would recommend at least reading that far rather than reading "CMake" in the title and reflexively commenting something negative. I skimmed through and this seems like a nice resource to get people spun up on CMake, I'll recommend it to new users in the future.
- bch 2y ago> CMake gets a lot of hate because a lot of large projects use it poorly and the syntax is strange Sounds like a ”you’re holding it wrong”[0] defense. In my experience, it’s exciting to start using it, then you start pushing it and it’s annoying or simply falls down. I’ll admit I’ve avoided it for years now (maybe it needs a revisit), but I bought the book, I drank the koolaid, and I tried to like it. But imo it really is problematic, and I’m one of those people who’s since settled on basic (BSD) Makefiles. [0] https://www.cnn.com/2010/TECH/mobile/06/25/iphone.problems.response/index.html https://www.cnn.com/2010/TECH/mobile/06/25/iphone.problems.r...
- AHTERIX5000 2y agoIs there an open source project which uses CMake well and could be used as a reference for good CMake practices? I've been using CMake for years and it's definitely not the worst solution for building multiplatform C++ projects. But I've never read a CMake script and thought what a clean solution, it's always a bit gnarly.
- sho_hn 2y agoKDE's stuff (which is the original reason CMake became popular and adopted) remains updated and fairly clean.
- OneOffAsk 2y agoParaView [0] and VTK [1] are big projects from the same shop that does CMake. [0] https://github.com/Kitware/ParaView https://github.com/Kitware/ParaView [1] https://github.com/Kitware/VTK https://github.com/Kitware/VTK
- kevin_thibedeau 2y agoI do wish some brave soul would update the main parser to support generator expressions directly so they can have whitespace. Then make the end* commands have optional parens and you've almost got a decent language.
- sorenjan 2y agoI don't think these two statements are fully compatible: > Do any of the following apply to you? > - You want to avoid hard-coding paths > ... > If so, you’ll benefit from a CMake-like build system. and > Don’t GLOB files I find it very annoying that I, a human, am expected to keep a current list of all source code files, when listing files is something that computers are very good at. They even tell us how to structure the project with a src folder, but I still have to remember to add or remove source code files to the right CMakeLists.txt when the content of that folder changes. It's poor design.
- TimorousBestie 2y agoAll of my projects GLOB source files, headers, and test source with CONFIGURE_DEPENDS. Haven’t had a problem yet.
- sorenjan 2y agoYet you won't find a CMake best practices text that won't mention how bad globbing is.
- kevin_thibedeau 2y agoYou don't notice it on an SSD but glob hits spinning drives hard.
- HelloNurse 2y agoThere's the traditional criminal behaviour of CMake: setting a variable to a globbed set of files ONCE and obliviously caching the value ever after. A build system where it is possible cannot claim to be well designed.
- gpderetta 2y agoTrue. But I don't think CMake has ever been accused to be well designed.
- 2y ago
- ingen0s 2y agoyeah CMake has been good to me past few years.
- mrlonglong 2y agoI love cmake. It's a brilliant tool. I've used it extensively. In fact, I've recently reworked a large collection of applications and their C++ sources plus test units. The whole process was a joy.
- vrajspandya1 2y agoFrom last couple of years, VSCode's CMake Debugging plugin has made using CMake much easier. After using that I don't spend endless amounts of time figuring out what went wrong. This also helps me not to be afraid of CMake and I have started to like it.
- ahartmetz 2y agocmake --trace-expand + your terminal's built-in search works quite well, too
- dang 2y agoRelated. Others? An Introduction to Modern CMake - https://news.ycombinator.com/item?id=39784784 https://news.ycombinator.com/item?id=39784784 - March 2024 (28 comments) An Introduction to Modern CMake - https://news.ycombinator.com/item?id=22577889 https://news.ycombinator.com/item?id=22577889 - March 2020 (41 comments) An Introduction to Modern CMake - https://news.ycombinator.com/item?id=17897685 https://news.ycombinator.com/item?id=17897685 - Sept 2018 (122 comments)
- fithisux 2y agoIt is a noble attempt But they should support more native languages D Odin Rust Nim C3 Freebasic Freepascal
- sirwhinesalot 2y agoFor better or worse CMake has become a de-facto standard. You can (justifiably) argue Meson is better but honestly CMake is "good enough" and a slightly saner build system is not worth the loss of "standardization". For C and C++, if I'm not using CMake, then I'm using some cobbled together shell scripts that do precisely what I need, no more, no less. But for libraries there's a huge benefit to CMake since you can create a Config.cmake file for other projects to easily add your project as a dependency. Or to use with FetchContent for rather nice dependency management. The syntax is horrible, the semantics confusing, the way to do anything correctly weird and unintuitive like those generator expressions or whatever they're called and how the Config.cmake file is supposed to be generated. It is hot garbage. But I'll still use it because the alternative is making dependency management in C/C++ land even worse.
- Iwan-Zotow 2y ago> The syntax is horrible that! that!!! If someone replace top level with anything (even Python) I would be a lot happier
- jojo14 2y agoScons is very easy and readable yet very powerful. It is Python based and extensible. https://scons.org/ https://scons.org/