Building RxDock using Meson build system

foss meson rxdock

Photo credit: Harry Cunningham, Unsplash

In the previous article we demonstrated how to install RxDock. In the process we used Meson, a fast and user friendly build system, and therefore the process was straightforward. But building RxDock wasn't 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. 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 early 2000s, but afterwards it got superseded by qmake and later Qbs. Well, you see, rDock never migrated away from it. 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 obviously 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 platforms that RxDock runs on. rDock as we found it ran only on Linux, but we ported it to FreeBSD, Solaris, and Windows over the course of a few months (more on that in the future posts as well).

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 worked with it quite a bit while developing ns-3 during his PhD days so it was an attractive option for RxDock. Waf's build scripts are Python scripts so it's very flexible in terms what it can do, while being easy to use. In summary, it's likely that we would 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 evaluating the existing solutions and concluding 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 right now in the staging branch.

The joy of working with Meson

The reason why we picked Meson among the three was the ease of use. It took a just a few hours and 120 lines of the file (more than a third of that being the names of the source files) to get rDock building and running, and tests came soon afterwards. This tweet 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 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 prior knowledge of Meson syntax; it's 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 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 forseeable future.

Previous Post