Build system

RxDock uses the Meson build system.


Meson is a fast and user-friendly build system, and therefore building and testing of RxDock is now straightforward. But it was not always so simple.

rDock built using tmake

When we stumbled upon rDock back in April 2019, the first thing we noticed was its build process that required tmake command. As you might know, tmake was developed by Trolltech (now Qt Company) during the 1990s as a build system for cross-platform applications, specifically Qt Toolkit and applications using it. It was still somewhat popular in the early 2000s, but afterward, it got superseded by qmake and later Qbs. Well, as you might observe, rDock never migrated away from tmake. Luckily, tmake could still run on modern Linux distributions so building rDock was possible.

Once we got rDock to build, albeit, with thousands of lines of warnings (more on that in the future posts), we decided that the first step is replacing tmake. The replacement should be some actively maintained build system, but we also wanted it to be cross-platform just like tmake as we intended to expand the number of supported platforms. rDock as we found it ran only on Linux, but after forking as RxDock we ported it to FreeBSD, Solaris, and Windows over a few months.

Aside from portability, we also wanted our build system to be easy to use; one wants to spend time developing software, not writing build scripts. In the process of choosing the replacement for tmake, we evaluated CMake, Waf, and Meson.

Choosing the build system

There is the old saying that Linux is user friendly, but picky who its friends are. CMake is similar, and unless you can sing precisely quoted passages from CGold when woken up in the middle of the night, you are not in that circle of friends (sorry to disappoint). To be fair, the syntax of the CMakeLists.txt build configuration files has gotten simpler over time, but CMake is still a lot more painful to use compared to Waf and Meson. Furthermore, guides like An Introduction to Modern CMake are a great resource if, for whatever reason, CMake is the way you want to go.

Waf is a mature build system, but it’s nowhere near as big and popular as CMake. Vedran Miletić worked with it quite a bit while developing ns-3 during his Ph.D. days so it was an attractive option for RxDock as well. Waf’s build scripts are Python scripts so it’s very flexible in terms of what it can do while being easy to use. In summary, we would likely have picked Waf over CMake if Meson didn’t exist. Despite being somewhat niche, Waf is still used by important projects such as mpv and Samba.

Finally, Meson, a build system originally developed by Jussi Pakkanen as a hobby since 2012. Jussi carefully evaluated the existing solutions and concluded that building software can be done better (xkcd about standards comes to our mind and critics of Meson agree in that regard). A good overview of Meson is the presentation at in 2015, where the author credits SCons, GYP, and qmake/Qbs for inspiration. The usage of Meson started to grow steadily after that presentation: it started building GStreamer in 2016 and it was adopted by GNOME in 2017. It’s no longer a niche tool as it’s used by 100+ other projects today, including some big names such as Mesa, Linux Vendor Firmware Service, systemd, and DXVK. DOSBox is switching to Meson at the time of writing in the staging branch.

The joy of working with Meson

The reason why we picked Meson among the three build systems was the ease of use. It took just a few hours and 120 lines of the build configuration file (more than a third of that being the names of the source files) to get RxDock building and running, and tests came soon afterward. This tweet from Vedran Miletić captures some of the initial excitement coming from replacing tmake and custom Makefiles with Meson.

Unlike Waf, the syntax isn’t Python (there’s a good reason for that), but it’s very much Python-like and therefore easy to get started. At CppCon 2018, Jussi told the audience to just look at the build configuration file for 10 seconds without any prior knowledge of the Meson syntax; it’s just so obvious what it does. The documentation is very good, especially its coverage of common use cases. You get reproducible builds for free. IDE integration is getting there, e.g. Qt Creator added Meson support in summer 2020 and Visual Studio Code had it for a while.

It has been almost two years at the time of writing since we switched to Meson and we are very happy with how it builds RxDock. The Meson community is very active and therefore we expect to continue using Meson to build RxDock for the foreseeable future.