TExcelTAD
Home › Meson, Autotools & xmake › Beyond CMake: Three Other Ways to Build C

Beyond CMake: Three Other Ways to Build C

CMake is the default build system for new C and C++ projects, but it is far from the only one. Open the source of GNOME, systemd, Mesa, GStreamer, PostgreSQL 16+, QEMU or the X.Org server and you find Meson. Download almost any classic GNU or Unix library (coreutils, bash, curl, libpng, ImageMagick) and you get a ./configure script made by GNU Autotools. And a growing number of game, embedded and Chinese open-source projects use xmake, which bundles a build system and a package manager in one binary.

A build engineer meets all three. This course teaches each well enough to build, test, install and package a library with it, to read and fix other people's projects, and to judge which tool fits a new project.

The three tools at a glance

Meson GNU Autotools xmake
First release 2013 1991 (autoconf), 1994 (automake) 2015
You write meson.build (a small, non-Turing-complete language) configure.ac (M4 macros + shell) and Makefile.am xmake.lua (Lua)
It generates build.ninja (or VS / Xcode projects) a portable configure shell script, which writes Makefiles nothing: xmake runs the build itself
Build step run by Ninja GNU Make (any POSIX make) xmake
Dependencies dependency(): pkg-config, CMake, system, or a fallback subproject (wrap) PKG_CHECK_MODULES, AC_CHECK_LIB add_requires(): the xrepo package manager, or system packages
Strengths fast, strict, readable; very good cross-compiling runs on any POSIX shell with no build tool installed; the release tarball is self-contained one tool for build + packages; short config; many toolchains
Weak spots needs Python 3 + Ninja; no globbing (on purpose) three languages at once (M4, shell, make); slow configure; arcane errors smaller community; package recipes come from the network

CMake sits between them: a generator like Meson, with a scripting language that is more powerful but less strict. The comparison lesson goes through the differences in detail, once you have used all four.

One program, three builds

Here is the same one-file program built with each tool, in one session. Every session in this course is a real run in Ubuntu 24.04 with Meson 1.12.1, Ninja 1.13.2, autoconf 2.71, automake 1.16.5, libtool 2.4.7, xmake 3.1.2 and GCC 13, without network access; the output under it is what the tools printed. Don't worry about the details yet: notice the shape of each workflow.

bash · try it yourself
mkdir -p hello && cd hello
cat > main.c <<'SRC'
#include <stdio.h>
int main(void) { puts("hello"); return 0; }
SRC

echo "### Meson: describe, set up a build directory, compile"
cat > meson.build <<'M'
project('hello', 'c', version: '1.0.0')
executable('hello', 'main.c')
M
meson setup build-meson > /dev/null
meson compile -C build-meson -j 1 | grep '^\['
./build-meson/hello

echo "### Autotools: describe, generate ./configure, configure, make"
cat > configure.ac <<'AC'
AC_INIT([hello], [1.0.0])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
AC
cat > Makefile.am <<'AM'
bin_PROGRAMS = hello
hello_SOURCES = main.c
AM
autoreconf -i 2> /dev/null
./configure --quiet
make -j1 -s
./hello

echo "### xmake: describe, build"
cat > xmake.lua <<'L'
target("hello")
    set_kind("binary")
    add_files("main.c")
L
xmake -j1 2>&1 | grep '%'
xmake run hello
### Meson: describe, set up a build directory, compile
[1/2] Compiling C object hello.p/main.c.o
[2/2] Linking target hello
hello
### Autotools: describe, generate ./configure, configure, make
hello
### xmake: describe, build
[ 23%]: <hello> cache compiling.release main.c
[ 47%]: <hello> linking.release hello
[100%]: build ok, spent 0.193s
hello

Three different philosophies are visible already:

  • Meson keeps everything in a separate build directory (build-meson/) and hands the actual work to Ninja (the [1/2] lines are Ninja's).
  • Autotools generates a shell script, configure, which you (or your users) run to produce a Makefile; then ordinary make builds the program in the source tree (out-of-tree builds are possible too).
  • xmake reads xmake.lua and builds directly, printing its own progress lines; there is no generated build file to run.

How this course is organised

  1. Meson (11 lessons): the language, targets, dependencies, options, configuration headers, tests and install, subprojects and wraps, cross files, introspection and release tarballs.
  2. GNU Autotools (7 lessons): the autoreconf → configure → make pipeline, configure.ac checks, Makefile.am, libtool shared libraries, make distcheck, and how to read and fix a legacy ./configure project.
  3. xmake (4 lessons): xmake.lua, build modes, toolchain switching, project generators, and packages.
  4. Choosing: build2 and Zig's build system as contrasts, then the four-way comparison.
  5. Toolkit and Field notes: the satellite tools (muon, samurai, autoscan, autoupdate, meson wrap) and practical advice from real projects.
  6. Practice: exercises, and a two-part Mini Project that builds the same library with Meson, Autotools and xmake, installs each with a pkg-config file, and consumes them.

The sessions run without network access, which is also a good habit for reproducible builds. Where a tool wants to download something (Meson's WrapDB, xmake's package repository), the course shows the offline failure once, honestly, and then uses a local alternative.

Background: you should know CMake (targets, configure/build/install, find_package) and the basics of Make & Ninja. Libraries, sonames and pkg-config were introduced in Build Fundamentals.

Test yourself

Which of these tools does NOT generate a build file for another tool to run?

  1. Meson
  2. Autotools
  3. CMake
  4. xmake

A user downloads foo-2.1.tar.gz and builds it with ./configure && make && make install. Which build system did the project use?

  1. Meson
  2. GNU Autotools
  3. xmake
  4. Bazel

In the session, which program actually ran the compiler for the Meson build?

  1. Python
  2. GNU Make
  3. Ninja
  4. xmake