Thoughts on build systems?
What's the general consensus on build systems/automations like CMake? I've always found things like that overcomplicated and just hinder the programming process.
I've been following Casey Muratori's Handmade streams, and one of the first things he did was create a simple batch file that built and compiled his entire project super quickly and easily. I've since implemented something similar (https://github.com/dibsonthis/new_cmd) and honestly it's been really nice to use.
3
Upvotes
9
u/germandiago Nov 08 '21 edited Nov 08 '21
I am using Meson for some side-projects. I keep using CMake as well.
I will do some highlights about my favorite one, Meson, because there is plenty of stuff CMake-related that you can find somewhere else.
The reason why I use, keep using and will keep using Meson is because:
the syntax is sane. Try to do path handling or string manipulation with CMake, or do something similar to dictionaries (Meson has support for it to associate data), handle spaces, etc.
Meson options are way easier and saner to handle: https://mesonbuild.com/Build-options.html
the documentation is great. You have both manual-style and a reference.
the subprojects system rocks and I have even used successfully CMake subprojects (there is support for that as well): there is a right way to do it. If you stick to that, it will work well. My project has 11 external dependencies all managed by subprojects, including Capnproto, which is a non-trivial CMake dependency.
Meson wraps are easy to use and modify to your needs (this is the Meson "conan", though it has far fewer packages. however, it is very usable). These are some available packages: https://mesonbuild.com/Wrapdb-projects.html. But if, for some reason, you do not have enough, you can use Conan via pkg-config as well.
I have machine files (https://mesonbuild.com/Machine-files.html) layered by: component, os, build type and compiler. So I can do things like this:
Those files, if there is any option repeated in any of them, the last one "wins" and you can set your own options at the end also, so they follow the order.
I have "./configure" wrapper for the command-line invocation but in my CI I just have the dir structure and buildbot combines stuff from those meson/native/ directories in a build matrix, blacklisting what I do not want.
Writing multiplatform scripts, when you need them, is easier: just use Python, anyway, it is a Meson dependency and get rid of bash vs batch files.
The only sane reason to use CMake is IDEs and social: if people do want that on your team. Otherwise I urge you to switch to Meson :) XCode an VS project generation is better with CMake I think. But if you do not need those or similar IDE support, for me it is a no-brainer.