Include Meson project with CMake FetchContent

I’m trying to move to using the bleeding branch, which comes with Meson build system instead of CMake. Does anyone have any advice on how to add this as a dependency using FetchContent? I’ve tried the following, but no luck:

FetchContent_Declare(criterion
        GIT_REPOSITORY https://github.com/Snaipe/Criterion.git
        GIT_TAG bleeding
        GIT_SUBMODULES_RECURSE TRUE
        CONFIGURE_COMMAND "meson build"
        BUILD_COMMAND "ninja -C build"
        )
FetchContent_MakeAvailable(criterion)

Please could someone suggest how to configure this?

Do you need to build this project from source?

When using projects with alternative build systems it’s worth considering using pre-built libraries.

I’d prefer to make it available with the source of my project. It allows me to use different versions between projects.

1 Like

FetchContent doesn’t support custom configure and build commands (this is explicitly mentioned in its docs). It can only bring in CMake projects to the main build. For dependencies that use a different build system, ExternalProject is what you should be using instead.

3 Likes

Yes I think one would want to consider a superbuild-like structure to allow building and selecting version of the external library