meson: cmake subproject dependencies not working
Describe the bug DOSBox Staging is transitioning to meson. We depend on FluidSynth (2.x, a CMake project), which in turn depends on Glib-2.0 (a Meson project), both of which aren’t guaranteed to exist on all our supported platforms - so we’ve written Meson wraps for them.
When both FluidSynth and Glib do not exist on a system, the fluidsynth
subproject is not being provided the glib-2.0
dependencies generated from the glib
subproject.
Here’s how it plays out sequentially if Glib doesn’t exist:
glib_dep = dependency('glib-2.0', fallback : ['glib'])
gthread_dep = dependency('gthread-2.0', fallback : ['glib'])
All goes well – Meson falls back to the glib
subproject wrap and reports the dependencies are found:
Run-time dependency glib-2.0 found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency glib-2.0
|Executing subproject glib method meson
|Project name: glib
|Project version: 2.67.1
...
Dependency glib-2.0 found: YES 2.67.1 (overridden)
Dependency gthread-2.0 found: YES 2.67.1 (overridden)
Great - so Meson is taking care of that for us. Onto FluidSynth…
Executing subproject fluidsynth method cmake
||Configuring the build directory with CMake version 3.16.3
||-- Checking for modules 'glib-2.0>=2.6.5;gthread-2.0>=2.6.5'
||-- No package 'glib-2.0' found
||-- Package 'glib-2.0', required by 'gthread-2.0', not found
|| A required package was not found
So despite Meson telling us it has control of glib-2.0 found: YES 2.67.1
and gthread-2.0 found: YES 2.67.1
, it’s unable to provide them to the cmake subproject, despite FluidSynth being configured it with these dependencies:
fluidsynth_proj = cmake.subproject('fluidsynth')
fluidsynth_proj.dependency('glib-2.0', fallback: ['glib'])
fluidsynth_proj.dependency('gthread-2.0', fallback: ['glib'])
fluidsynth_dep = fluidsynth_proj.dependency(
'fluidsynth',
version : '>=2',
fallback: ['fluidsynth'],
dependencies: ['glib-2.0', 'gthread-2.0']
)
To Reproduce
See attached tarball consisting of tiny 19-line meson.build
and two wraps to reproduce the issue.
Note: To have Meson fallback to using the Glib subproject, you will need to hide your system’s existing Glib library. You can do this temporarily by moving glib’s pkg-config
(.pc) file, such as:
cd /usr/lib/x86_64-linux-gnu/pkgconfig && sudo mv glib-2.0.pc glib-2.0.pc-bak
Expected behavior
If Meson says it has a given dependency (via system discovery or subproject fallback), then subsequently using that dependency (such as in other subprojects) should “just work”.
I guess this means that Meson doesn’t know how to provide dependencies to cmake.subproject
s?
system parameters
- Native Ubuntu 20.10 installation
- Python 3.8.6
- Meson 0.56.0
- Ninja 1.10.0.git.kitware.jobserver-1
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 1
- Comments: 26 (17 by maintainers)
Commits related to this issue
- chore: Update Meson build subproject dependencies Webkit2GTK (cmake configured) is still commented out, as it doesn't find libsoup3 dependency, being a meson configured project. See: https://github.c... — committed to dvergeylen/yamdown by dvergeylen 3 years ago
- chore: added WebkitGtk as dependency Because the WebkitGTK is a cmake project, we can't make it a hard dependency (compiled if not found). This is unfortunate but seems to be a limitation of meson/cm... — committed to dvergeylen/yamdown by dvergeylen 3 years ago
OK, I managed to get
-uninstalled.pc
files to work with #8104. However, the project still has some minor issues (somehow the include path for<gmodule.h>
is missing + a tricky bug involving generated source files):Yes please 😃 Otherwise we’ll be wrapping meson in shell script to do this.
Ideally we could describe the dependencies of a cmake.subproject, something like:
Where meson has previously been told how to resolve those dependencies:
meson-uninstalled
directory for the respective dependency to the respective cmake-subproject’spkg_config_path
Indeed…
Nice. So, cmake can depend on a meson project as long as they both use pkg-config for an interchange format.
Maybe it would make sense to automatically add the meson-uninstalled directory to the pkg_config_path for at least cmake subprojects. Less manual intervention for the user trying to do the build.
Did you try exporting PKG_CONFIG_PATH yourself, before running meson configure? Did it work?