Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building with Meson #2530

Merged
merged 4 commits into from Oct 1, 2022

Conversation

mikecrowe
Copy link
Contributor

The Meson[1] build system makes it easier incorporate third-party libaries into a project if they also build using Meson.

Let's add a minimal Meson build that's compatible with the CMake build, along with a GitHub workflow to check that it builds and that at least the simplest SelfTest runs.

The handling of catch_user_config.hpp is inspired by BUILD.bazel and doesn't attempt to support any configuratons options. Such features could be added later.

Meson strongly discourages using wildcards to specify sources, so the source and header lists are copied from CMakeLists.txt.

Add a new test workflow to test the Meson builds. I was unable to get these tests to pass with Ubuntu 20.04, so they use Ubuntu 22.04.

I'm neither a CMake nor a Meson expert, but the results seem to work for me.

[1] https://mesonbuild.com/

Description

GitHub Issues

@codecov
Copy link

codecov bot commented Sep 19, 2022

Codecov Report

Merging #2530 (d0b0cb1) into devel (4a7cefe) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##            devel    #2530   +/-   ##
=======================================
  Coverage   91.56%   91.56%           
=======================================
  Files         183      183           
  Lines        7558     7558           
=======================================
  Hits         6920     6920           
  Misses        638      638           

@mikecrowe
Copy link
Contributor Author

These changes are being improved based on review comments in mesonbuild/wrapdb#643 . Once that review is complete I'll update this PR.

@horenmar
Copy link
Member

Why should the build be part of this project, rather than just a recipe in wrapdb?

@mikecrowe
Copy link
Contributor Author

Why should the build be part of this project, rather than just a recipe in wrapdb?

I hoped that it would be more likely to stay up to date if it was included in Catch2 itself, just like the BUILD.bazel file is. However, if you're not interested in that then it can stay separate.

@eli-schwartz
Copy link

It's indeed more trusted (all content from the original project), easier to use (vs. patching in a secondary source), more likely to remain updated, and works better as a git submodule, or when updating to arbitrary commit checkpoints as the wrapdb will never add support for those.

If, as implied by e.g. the bazel support, the Catch2 project is open to hosting integrations directly, that's the superior solution and the externally patched-in overlay can be dropped from the wrapdb (which may still host a metadata-only record).

@horenmar
Copy link
Member

I have two issues with keeping Meson build support in-repo.

  1. I don't use Meson, so if it breaks I will have to go and learn new build tool
  2. Because it uses explicit file lists, it adds another place to edit when adding another file.

Neither of these are deal breakers, but they are not ideal.

The positive side is that the configuration can be done sanely (unlike Bazel), and that there will be few CI jobs to keep the build functional.

@eli-schwartz
Copy link

Speaking with my @mesonbuild core committer hat on, you are more than welcome to ping me and ask for help at any time.

Duplicating file lists across build systems isn't particularly fun, but one possible option is to have a text file with one source filename per line, and read it into each build system. For meson this would be something like:

fs = import('fs')

sources = files(
    fs.read('srclist.txt').split()
)

(Meson will automatically reconfigure if that file list changes, because it's treated as a build definition file.)

@horenmar
Copy link
Member

Speaking with my https://github.com/mesonbuild core committer hat on, you are more than welcome to ping me and ask for help at any time.

Very well.

@horenmar
Copy link
Member

@mikecrowe Is this ready for review?

@mikecrowe mikecrowe marked this pull request as ready for review September 27, 2022 19:52
@mikecrowe
Copy link
Contributor Author

@mikecrowe Is this ready for review?

I think so. Would you like me to squash it down to a single commit first?

meson.build Outdated Show resolved Hide resolved
tests/meson.build Outdated Show resolved Hide resolved
The Meson[1] build system makes it easier incorporate third-party
libaries into a project if they also build using Meson.

Let's add a minimal Meson build that's compatible with the CMake build,
along with a GitHub workflow to check that it builds and that at least
the simplest SelfTest runs.

The handling of catch_user_config.hpp is inspired by BUILD.bazel and
doesn't attempt to support any configuratons options. Such features
could be added later.

Meson strongly discourages using wildcards to specify sources, so the
source and header lists are copied from CMakeLists.txt.

Add a new test workflow to test the Meson builds. I was unable to get
these tests to pass with Ubuntu 20.04, so they use Ubuntu 22.04.

I'm neither a CMake nor a Meson expert, but the results seem to work for
me.

[1] https://mesonbuild.com/
Incorporate improvements suggested by Meson maintainer in
mesonbuild/wrapdb#643 .
CMakeLists.txt calls the SelfTest binary SelfTest, so we should do so
too.
meson.build Show resolved Hide resolved
@horenmar horenmar added the Building and Packaging Issues affecting build/packaging scripts and utilities label Oct 1, 2022
@horenmar horenmar merged commit 4db8b50 into catchorg:devel Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Building and Packaging Issues affecting build/packaging scripts and utilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants