How would I fetch a dependency from GitHub in meson? I am trying to convert the following cmake snippet into meson
FetchContent_Declare(
some_dep
GIT_REPOSITORY https://github.com/some/repo
GIT_TAG sometag
SOURCE_SUBDIR src
)
FetchContent_MakeAvailable(some_dep)
Note that this dependency may not be using meson as its build system.
The meson equivalent is subprojects and the wrap dependency system. Here a simple example:
subprojects/fmt.wrap
:meson.build
:main.cpp
:This will search
libfmt
on your system and fallback to downloading it as specified in the wrap file. Thesubproject()
function requires ameson.build
file in the root directory, similar to howFetchContent
expects aCMakeLists.txt
. If the respective project does not have meson build files, you can provide patches through thepatch_*
ordiff_files
properties in the wrap file. This is e.g. the case for libfmt does not have meson build files. You can also use[wrap-git]
instead of[wrap-file]
to specify a git repository instead of a release tarball. Please refer to the documentation.Tip: The meson developers maintain the Wrap DB, where you can find wrap files for some common libraries/projects.