This is how libgd is supposed to be used, and it also works around: https://github.com/mesonbuild/meson/pull/1368