I actually think this is a bug in Meson. I created a PR[0] to propose a fix, but one person's bug is another person's feature. The actual content of the patch seems fine to me, but I would wait to see the result of the pull request fist.
[0]: https://github.com/mesonbuild/meson/pull/15714 -- Tristan Partin PostgreSQL Contributors Team AWS (https://aws.amazon.com)
