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.

cmake-subproject-deps.tar.gz

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.subprojects?

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

Most upvoted comments

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):

project('test', ['c', 'cpp'])
glib_dep = dependency('glib-2.0', fallback : ['glib'])
gthread_dep = dependency('gthread-2.0', fallback : ['glib'])

cmake = import('cmake')

cm_opts = cmake.subproject_options()
cm_opts.add_cmake_defines({'enable-ladspa': false})

fluidsynth_proj = cmake.subproject('fluidsynth', options: cm_opts)
meson build
ninja -C build subprojects/fluidsynth/gentables-install
ninja -C build

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.

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:

subproj = cmake.subproject(
    'my_subproj',
    dependencies : [ 'glib-2.0', 'gthread-2.0'])

Where meson has previously been told how to resolve those dependencies:

glib_dep = dependency('glib-2.0', fallback : ['glib'])
gthread_dep = dependency('gthread-2.0', fallback : ['glib'])
  • If those are available in the system, then carry on.
  • If they’re provided via fallback, then add the meson-uninstalled directory for the respective dependency to the respective cmake-subproject’s pkg_config_path

Indeed…

$ PKG_CONFIG_PATH=$PWD/builddir/meson-uninstalled/ meson builddir --wrap-mode=forcefallback
Using 'PKG_CONFIG_PATH' from environment with value: '/tmp/proj/builddir/meson-uninstalled/'
Using 'PKG_CONFIG_PATH' from environment with value: '/tmp/proj/builddir/meson-uninstalled/'
The Meson build system
Version: 0.56.0
Source dir: /tmp/proj
Build dir: /tmp/proj/builddir
Build type: native build
Project name: test
Project version: undefined
C compiler for the host machine: ccache cc (gcc 10.2.0 "cc (GCC) 10.2.0")
C linker for the host machine: cc ld.bfd 2.35.1
C++ compiler for the host machine: ccache c++ (gcc 10.2.0 "c++ (GCC) 10.2.0")
C++ linker for the host machine: c++ ld.bfd 2.35.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Looking for a fallback subproject for the dependency glib-2.0 because:
Use of fallback dependencies is forced.

|Executing subproject glib method meson 
|
|Project name: glib
|Project version: 2.67.1
|C compiler for the host machine: ccache cc (gcc 10.2.0 "cc (GCC) 10.2.0")
|C linker for the host machine: cc ld.bfd 2.35.1
|C++ compiler for the host machine: ccache c++ (gcc 10.2.0 "c++ (GCC) 10.2.0")
|C++ linker for the host machine: c++ ld.bfd 2.35.1
|Compiler for C supports arguments -fno-strict-aliasing: YES 
|Checking if "GNU C visibility attributes test" compiles: YES 
|Compiler for C supports arguments -fvisibility=hidden: YES 
|Message: Enabling various debug infrastructure
|Has header "alloca.h" : YES 
|Has header "crt_externs.h" : NO 
|Has header "dirent.h" : YES 
|Has header "float.h" : YES 
|Has header "fstab.h" : YES 
|Has header "grp.h" : YES 
|Has header "inttypes.h" : YES 
|Has header "limits.h" : YES 
|Has header "linux/magic.h" : YES 
|Has header "locale.h" : YES 
|Has header "mach/mach_time.h" : NO 
|Has header "memory.h" : YES 
|Has header "mntent.h" : YES 
|Has header "poll.h" : YES 
|Has header "pwd.h" : YES 
|Has header "sched.h" : YES 
|Has header "spawn.h" : YES 
|Has header "stdint.h" : YES 
|Has header "stdlib.h" : YES 
|Has header "string.h" : YES 
|Has header "strings.h" : YES 
|Has header "sys/auxv.h" : YES 
|Has header "sys/event.h" : NO 
|Has header "sys/filio.h" : NO 
|Has header "sys/inotify.h" : YES 
|Has header "sys/mkdev.h" : NO 
|Has header "sys/mntctl.h" : NO 
|Has header "sys/mnttab.h" : NO 
|Has header "sys/mount.h" : YES 
|Has header "sys/param.h" : YES 
|Has header "sys/resource.h" : YES 
|Has header "sys/select.h" : YES 
|Has header "sys/statfs.h" : YES 
|Has header "sys/stat.h" : YES 
|Has header "sys/statvfs.h" : YES 
|Has header "sys/sysctl.h" : NO 
|Has header "sys/time.h" : YES 
|Has header "sys/times.h" : YES 
|Has header "sys/types.h" : YES 
|Has header "sys/uio.h" : YES 
|Has header "sys/vfs.h" : YES 
|Has header "sys/vfstab.h" : NO 
|Has header "sys/vmount.h" : NO 
|Has header "sys/wait.h" : YES 
|Has header "termios.h" : YES 
|Has header "unistd.h" : YES 
|Has header "values.h" : YES 
|Has header "wchar.h" : YES 
|Has header "xlocale.h" : NO 
|Checking if "malloc.h" compiles: YES 
|Has header "linux/netlink.h" : YES 
|Checking if "statx() test" compiles: YES 
|Header <locale.h> has symbol "LC_MESSAGES" : YES 
|Checking whether type "struct stat" has member "st_mtimensec" : NO 
|Checking whether type "struct stat" has member "st_mtim.tv_nsec" : YES 
|Checking whether type "struct stat" has member "st_atimensec" : NO 
|Checking whether type "struct stat" has member "st_atim.tv_nsec" : YES 
|Checking whether type "struct stat" has member "st_ctimensec" : NO 
|Checking whether type "struct stat" has member "st_ctim.tv_nsec" : YES 
|Checking whether type "struct stat" has member "st_birthtime" : NO 
|Checking whether type "struct stat" has member "st_birthtimensec" : NO 
|Checking whether type "struct stat" has member "st_birthtim" : NO 
|Checking whether type "struct stat" has member "st_birthtim.tv_nsec" : NO 
|Checking whether type "struct stat" has member "st_blksize" : YES 
|Checking whether type "struct stat" has member "st_blocks" : YES 
|Checking whether type "struct statfs" has member "f_fstypename" : NO 
|Checking whether type "struct statfs" has member "f_bavail" : YES 
|Checking whether type "struct dirent" has member "d_type" : YES 
|Checking whether type "struct statvfs" has member "f_basetype" : NO 
|Checking whether type "struct statvfs" has member "f_fstypename" : NO 
|Checking whether type "struct tm" has member "tm_gmtoff" : YES 
|Checking whether type "struct tm" has member "__tm_gmtoff" : NO 
|Compiler for C supports arguments -Wduplicated-branches: YES 
|Compiler for C supports arguments -Wimplicit-fallthrough: YES 
|Compiler for C supports arguments -Wmisleading-indentation: YES 
|Compiler for C supports arguments -Wstrict-prototypes: YES 
|Compiler for C supports arguments -Wunused: YES 
|Compiler for C supports arguments -Wno-unused-parameter: YES 
|Compiler for C supports arguments -Wno-bad-function-cast: YES 
|Compiler for C supports arguments -Wno-cast-function-type: YES 
|Compiler for C supports arguments -Wno-pedantic: YES 
|Compiler for C supports arguments -Wno-format-zero-length: YES 
|Compiler for C supports arguments -Werror=declaration-after-statement: YES 
|Compiler for C supports arguments -Werror=format=2: YES 
|Compiler for C supports arguments -Werror=implicit-function-declaration: YES 
|Compiler for C supports arguments -Werror=init-self: YES 
|Compiler for C supports arguments -Werror=missing-include-dirs: YES 
|Compiler for C supports arguments -Werror=missing-prototypes: YES 
|Compiler for C supports arguments -Werror=pointer-arith: YES 
|Compiler for C supports link arguments -Wl,-z,nodelete: YES 
|Compiler for C supports link arguments -Wl,-Bsymbolic-functions: YES 
|Checking for function "close_range" : NO 
|Checking for function "endmntent" : YES 
|Checking for function "endservent" : YES 
|Checking for function "fallocate" : YES 
|Checking for function "fchmod" : YES 
|Checking for function "fchown" : YES 
|Checking for function "fdwalk" : NO 
|Checking for function "fsync" : YES 
|Checking for function "getauxval" : YES 
|Checking for function "getc_unlocked" : YES 
|Checking for function "getfsstat" : NO 
|Checking for function "getgrgid_r" : YES 
|Checking for function "getmntent_r" : YES 
|Checking for function "getpwuid_r" : YES 
|Checking for function "getresuid" : YES 
|Checking for function "getvfsstat" : NO 
|Checking for function "gmtime_r" : YES 
|Checking for function "hasmntopt" : YES 
|Checking for function "inotify_init1" : YES 
|Checking for function "issetugid" : NO 
|Checking for function "kevent" : NO 
|Checking for function "kqueue" : NO 
|Checking for function "lchmod" : YES 
|Checking for function "lchown" : YES 
|Checking for function "link" : YES 
|Checking for function "localtime_r" : YES 
|Checking for function "lstat" : YES 
|Checking for function "mbrtowc" : YES 
|Checking for function "memalign" : YES 
|Checking for function "mmap" : YES 
|Checking for function "newlocale" : YES 
|Checking for function "pipe2" : YES 
|Checking for function "poll" : YES 
|Checking for function "prlimit" : YES 
|Checking for function "readlink" : YES 
|Checking for function "recvmmsg" : YES 
|Checking for function "sendmmsg" : YES 
|Checking for function "setenv" : YES 
|Checking for function "setmntent" : YES 
|Checking for function "strerror_r" : YES 
|Checking for function "strnlen" : YES 
|Checking for function "strsignal" : YES 
|Checking for function "strtod_l" : YES 
|Checking for function "strtoll_l" : YES 
|Checking for function "strtoull_l" : YES 
|Checking for function "symlink" : YES 
|Checking for function "timegm" : YES 
|Checking for function "unsetenv" : YES 
|Checking for function "uselocale" : YES 
|Checking for function "utimes" : YES 
|Checking for function "valloc" : YES 
|Checking for function "vasprintf" : YES 
|Checking for function "vsnprintf" : YES 
|Checking for function "wcrtomb" : YES 
|Checking for function "wcslen" : YES 
|Checking for function "wcsnlen" : YES 
|Checking for function "sysctlbyname" : NO 
|Checking for function "statvfs" : YES 
|Checking for function "statfs" : YES 
|Checking for function "if_indextoname" : YES 
|Checking for function "if_nametoindex" : YES 
|Checking for function "splice" : YES 
|Checking for function "stpcpy" : YES 
|Checking for function "posix_memalign" : YES 
|Checking for function "posix_spawn" : YES 
|Checking if "strerror_r() returns char *" compiles: YES 
|Checking for function "snprintf" : YES 
|Checking for function "strcasecmp" : YES 
|Checking for function "strncasecmp" : YES 
|Header <sys/sysmacros.h> has symbol "major" : YES 
|Header <dlfcn.h> has symbol "RTLD_LAZY" : YES 
|Header <dlfcn.h> has symbol "RTLD_NOW" : YES 
|Header <dlfcn.h> has symbol "RTLD_GLOBAL" : YES 
|Header <dlfcn.h> has symbol "RTLD_NEXT" : YES 
|Message: Checking whether to use statfs or statvfs .. statfs
|Checking for function "mkostemp" : YES 
|Checking if "futex(2) system call" links: YES 
|Checking if "eventfd(2) system call" links: YES 
|Checking if "__uint128_t available" compiles: YES 
|Checking if "clock_gettime" links: YES 
|Checking if "dlopen() and dlsym() in system libraries" links: NO 
|Checking if "dlopen() and dlsym() in libdl" links: YES 
|Library dl found: YES
|Checking if "number of arguments to statfs() (n=2)" compiles: YES 
|Checking if "open() option O_DIRECTORY" compiles: YES 
|Checking if "fcntl() option F_FULLFSYNC" compiles: NO 
|Checking if "C99 vsnprintf" runs: YES
|Checking if "C99 snprintf" runs: YES
|Checking if "Unix98 printf positional parameters" runs: YES
|Checking if "nl_langinfo and CODESET" links: YES 
|Checking if "nl_langinfo (PM_STR)" links: YES 
|Checking if "nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)" links: YES 
|Checking if "nl_langinfo (ALTMON_n)" links: YES 
|Checking if "nl_langinfo (_NL_ABALTMON_n)" links: YES 
|Checking if "signed" compiles: YES 
|Header <stddef.h> has symbol "ptrdiff_t" : YES 
|Checking if "sig_atomic_t" links: YES 
|Checking if "long long" compiles: YES 
|Checking if "long double" compiles: YES 
|Header <stddef.h> has symbol "wchar_t" : YES 
|Header <wchar.h> has symbol "wint_t" : YES 
|Checking if "uintmax_t in inttypes.h" compiles: YES 
|Checking if "uintmax_t in stdint.h" compiles: YES 
|Checking for size of "char" : 1
|Checking for size of "short" : 2
|Checking for size of "int" : 4
|Checking for size of "void*" : 8
|Checking for size of "long" : 8
|Checking for size of "long long" : 8
|Checking for size of "size_t" : 8
|Checking for size of "ssize_t" : 8
|Checking if "int64_t is long" compiles: YES 
|Checking for alignment of "char" : 1
|Checking for alignment of "short" : 2
|Checking for alignment of "int" : 4
|Checking for alignment of "void*" : 8
|Checking for alignment of "long" : 8
|Checking for alignment of "long long" : 8
|Checking for alignment of "size_t" : 8
|Checking for size of "wchar_t" : 4
|Checking if "GCC size_t typedef is long" compiles: YES 
|Checking if "GCC size_t typedef is long long" compiles: NO 
|Checking if "__va_copy check" compiles: YES 
|Checking if "va_copy check" compiles: YES 
|Checking if "va_lists can be copied as values" runs: DID NOT COMPILE
|Checking if "ISO C99 varargs macros in C" compiles: YES 
|Checking if "ISO C99 varargs macros in C++" compiles: YES 
|Checking if "GNUC varargs macros" compiles: YES 
|Has header "alloca.h" : YES (cached)
|Has header "sys/poll.h" : YES 
|Has header "sys/types.h" : YES (cached)
|Has header "winsock2.h" : NO 
|Computing int of "POLLIN" : 1
|Computing int of "POLLOUT" : 4
|Computing int of "POLLPRI" : 2
|Computing int of "POLLERR" : 8
|Computing int of "POLLHUP" : 16
|Computing int of "POLLNVAL" : 32
|Computing int of "AF_UNIX" : 1
|Computing int of "AF_INET" : 2
|Computing int of "AF_INET6" : 10
|Computing int of "MSG_OOB" : 1
|Computing int of "MSG_PEEK" : 2
|Computing int of "MSG_DONTROUTE" : 4
|Checking if "atomic ops" links: YES 
|Checking if "atomic ops define" compiles: YES 
|Run-time dependency threads found: YES
|Header <pthread.h> has symbol "pthread_attr_setstacksize" : YES 
|Header <pthread.h> has symbol "pthread_attr_setinheritsched" : YES 
|Header <pthread.h> has symbol "pthread_condattr_setclock" : YES 
|Header <pthread.h> has symbol "pthread_cond_timedwait_relative_np" : NO 
|Header <pthread.h> has symbol "pthread_getname_np" : YES 
|Header <sys/syscall.h> has symbol "SYS_sched_getattr" : YES 
|Checking if "pthread_setname_np(const char*)" with dependency threads links: NO 
|Checking if "pthread_setname_np(pthread_t, const char*)" with dependency threads links: YES 
|Checking if "stack grows check" runs: NO (1)
|Checking for function "iconv_open" : YES 
|Found pkg-config: /usr/bin/pkg-config (1.7.3)
|Using 'PKG_CONFIG_PATH' from environment with value: '/tmp/proj/builddir/meson-uninstalled/'
|Run-time dependency libpcre found: YES 8.44
|Library m found: YES
|Looking for a fallback subproject for the dependency libffi because:
|Use of fallback dependencies is forced.
|Using subprojects/glib/subprojects/libffi.wrap
|
||Executing subproject libffi method meson 
||
||Project name: libffi
||Project version: 3.2.9999
||C compiler for the host machine: ccache cc (gcc 10.2.0 "cc (GCC) 10.2.0")
||C linker for the host machine: cc ld.bfd 2.35.1
||Message: host cpu: x86_64
||Message: host cpu_family: x86_64
||Message: host system: linux
||Checking if "ASM .cfi" compiles: NO 
||Checking if "ASM x86 PCREL" compiles: YES 
||Checking if "ASM .ascii" compiles: YES 
||Checking if "ASM .string" compiles: YES 
||Checking for size of "size_t" : 8
||Checking for size of "long double" : 16
||Checking for size of "double" : 8
||Message: sizeof "long double" is greater than "double"
||Message: .eh_frame is hard-coded to not be ro
||Message: Assembler supports .unwind section type
||Checking for function "memcpy" : YES 
||Checking for function "mkostemp" : YES 
||Has header "alloca.h" : YES (cached)
||Has header "inttypes.h" : YES (cached)
||Has header "stdint.h" : YES (cached)
||Compiler for C supports function attribute visibility: YES 
||Program test-cc-supports-hidden-visibility.py found: YES (/usr/bin/python /tmp/proj/subprojects/libffi/test-cc-supports-hidden-visibility.py)
||Message: .hidden pseudo-op is available
||Program msvcc.sh found: YES (/tmp/proj/subprojects/libffi/msvcc.sh)
||Configuring ffi-x86_64.h using configuration
||Configuring ffitarget.h using configuration
||Configuring ffi.h using configuration
||Configuring fficonfig.h using configuration
||Build targets in project: 1
||Subproject libffi finished.
|
|Dependency libffi from subproject subprojects/libffi found: YES 3.2.9999
|Using 'PKG_CONFIG_PATH' from environment with value: '/tmp/proj/builddir/meson-uninstalled/'
|Run-time dependency zlib found: YES 1.2.11
|Checking for function "ngettext" : YES 
|Checking for function "bind_textdomain_codeset" : YES 
|Using 'PKG_CONFIG_PATH' from environment with value: '/tmp/proj/builddir/meson-uninstalled/'
|Run-time dependency mount found: YES 2.36.1
|Found CMake: /usr/bin/cmake (3.19.1)
|Run-time dependency libselinux found: NO (tried pkgconfig and cmake)
|Checking for function "getxattr" : YES 
|Has header "sys/xattr.h" : YES 
|Checking if "XATTR_NOFOLLOW" compiles: NO 
|Checking for function "strlcpy" : NO 
|Checking if "/proc/self/cmdline" runs: YES
|Program python3 found: YES (/usr/bin/python3)
|Program bash found: YES (/usr/bin/bash)
|Program sh found: YES (/usr/bin/sh)
|Program env found: YES (/usr/bin/env)
|Configuring glibconfig.h using configuration
|Dependency sysprof-capture-4 skipped: feature sysprof disabled
|Configuring gtester-report using configuration
|Configuring libglib-2.0.so.0.6701.0-gdb.py using configuration
|Program xmllint found: YES (/usr/bin/xmllint)
|Configuring glib-genmarshal using configuration
|Program glib-genmarshal found: YES (/tmp/proj/builddir/subprojects/glib/gobject/glib-genmarshal)
|Configuring glib-mkenums using configuration
|Program glib-mkenums found: YES (/tmp/proj/builddir/subprojects/glib/gobject/glib-mkenums)
|Configuring libgobject-2.0.so.0.6701.0-gdb.py using configuration
|Checking if "dlsym() preceding underscores" with dependency -ldl runs: NO (1)
|Checking for function "dlerror" with dependency -ldl: YES 
|Configuring gmoduleconf.h using configuration
|Checking if "C_IN in public headers (no arpa/nameser_compat.h needed)" compiles: YES 
|Checking if "res_query()" links: NO 
|Checking if "res_query() in -lresolv" links: YES 
|Library resolv found: YES
|Checking if "socket()" links: YES 
|Checking if "res_init()" links: YES 
|Checking if "res_nclose()" links: YES 
|Checking if "res_ndestroy()" links: NO 
|Checking if "res_ninit()" links: YES 
|Checking if "res_nquery()" links: YES 
|Checking for type "struct ip_mreqn" : YES 
|Checking if "ioctl with request SIOCGIFADDR" compiles: YES 
|Configuring gnetworking.h using configuration
|Configuring gdbus-codegen using configuration
|Program gdbus-codegen found: YES (/tmp/proj/builddir/subprojects/glib/gio/gdbus-2.0/codegen/gdbus-codegen)
|Configuring config.py using configuration
|Using 'PKG_CONFIG_PATH' from environment with value: '/tmp/proj/builddir/meson-uninstalled/'
|Run-time dependency libelf found: YES 0.178
|Program gengiotypefuncs.py found: YES (/usr/bin/python /tmp/proj/subprojects/glib/gio/tests/gengiotypefuncs.py)
|Using 'PKG_CONFIG_PATH' from environment with value: '/tmp/proj/builddir/meson-uninstalled/'
|Run-time dependency dbus-1 found: YES 1.12.20
|Program dbus-daemon found: YES (/usr/bin/dbus-daemon)
|Program msgfmt found: YES (/usr/bin/msgfmt)
|Configuring appinfo-test-gnome.desktop using configuration
|Configuring appinfo-test-notgnome.desktop using configuration
|Configuring appinfo-test.desktop using configuration
|Configuring appinfo-test2.desktop using configuration
|Program objcopy found: YES (/usr/bin/objcopy)
|Program ld found: YES (/usr/bin/ld)
|Configuring org.freedesktop.portal.Documents.service using configuration
|Compiler for C supports arguments -Werror=unused-function: YES 
|Library FuzzingEngine skipped: feature oss_fuzz disabled
|Program xgettext found: YES (/usr/bin/xgettext)
|Configuring glib-gettextize using configuration
|Configuring config.h using configuration
|Build targets in project: 393
|Subproject glib finished.

Dependency glib-2.0 found: YES 2.67.1 (overridden)
Dependency gthread-2.0 found: YES 2.67.1 (overridden)

|Executing subproject fluidsynth method cmake 
|
|
||Configuring the build directory with CMake version 3.19.1
||Running CMake with: -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local
||  - build directory:          /tmp/proj/builddir/subprojects/fluidsynth/__CMake_build
||  - source directory:         /tmp/proj/subprojects/fluidsynth
||  - toolchain file:           /tmp/proj/builddir/subprojects/fluidsynth/CMakeMesonToolchainFile.cmake
||  - preload file:             /tmp/proj/builddir/meson-private/data/preload.cmake
||  - trace args:               --trace-expand --trace-format=json-v1 --no-warn-unused-cli --trace-redirect=cmake_trace.txt
||  - disabled policy warnings: [CMP0025, CMP0047, CMP0056, CMP0060, CMP0065, CMP0066, CMP0067, CMP0082, CMP0089, CMP0102]
||
||Running with expanded trace output on.
||Not searching for unused variables given on the command line.
||Trace will be written to cmake_trace.txt
||-- The C compiler identification is GNU 10.2.0
||-- The CXX compiler identification is GNU 10.2.0
||-- Detecting C compiler ABI info
||-- Detecting C compiler ABI info - done
||-- Check for working C compiler: /usr/bin/cc - skipped
||-- Detecting C compile features
||-- Detecting C compile features - done
||-- Detecting CXX compiler ABI info
||-- Detecting CXX compiler ABI info - done
||-- Check for working CXX compiler: /usr/bin/c++ - skipped
||-- Detecting CXX compile features
||-- Detecting CXX compile features - done
||-- Checking whether system has ANSI C header files
||-- Looking for 8 include files dlfcn.h, ..., float.h
||-- Looking for 8 include files dlfcn.h, ..., float.h - found
||-- Performing Test memchrExists
||-- Performing Test memchrExists - Success
||-- Performing Test freeExists
||-- Performing Test freeExists - Success
||-- ANSI C header files - found
||-- Looking for include file unistd.h
||-- Looking for include file unistd.h - found
||-- Looking for DIR in sys/stat.h;sys/types.h;dirent.h
||-- Looking for DIR in sys/stat.h;sys/types.h;dirent.h - found
||-- Looking for stdio.h
||-- Looking for stdio.h - found
||-- Looking for math.h
||-- Looking for math.h - found
||-- Looking for errno.h
||-- Looking for errno.h - found
||-- Looking for stdarg.h
||-- Looking for stdarg.h - found
||-- Looking for sys/mman.h
||-- Looking for sys/mman.h - found
||-- Looking for sys/time.h
||-- Looking for sys/time.h - found
||-- Looking for fcntl.h
||-- Looking for fcntl.h - found
||-- Looking for sys/socket.h
||-- Looking for sys/socket.h - found
||-- Looking for netinet/in.h
||-- Looking for netinet/in.h - found
||-- Looking for netinet/tcp.h
||-- Looking for netinet/tcp.h - found
||-- Looking for arpa/inet.h
||-- Looking for arpa/inet.h - found
||-- Looking for limits.h
||-- Looking for limits.h - found
||-- Looking for pthread.h
||-- Looking for pthread.h - found
||-- Looking for signal.h
||-- Looking for signal.h - found
||-- Looking for getopt.h
||-- Looking for getopt.h - found
||-- Check size of long long
||-- Check size of long long - done
||-- Performing Test _have_inline
||-- Performing Test _have_inline - Success
||-- Performing Test _have_vla
||-- Performing Test _have_vla - Success
||-- Check if the system is big endian
||-- Searching 16 bit integer
||-- Check size of unsigned short
||-- Check size of unsigned short - done
||-- Searching 16 bit integer - Using unsigned short
||-- Check if the system is big endian - little endian
||-- Performing Test HAVE_INCOMPATIBLE_POINTER_TYPES
||-- Performing Test HAVE_INCOMPATIBLE_POINTER_TYPES - Success
||-- Looking for pthread.h
||-- Looking for pthread.h - found
||-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
||-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
||-- Looking for pthread_create in pthreads
||-- Looking for pthread_create in pthreads - not found
||-- Looking for pthread_create in pthread
||-- Looking for pthread_create in pthread - found
||-- Found Threads: TRUE  
||-- Looking for inet_ntop
||-- Looking for inet_ntop - found
||-- Found PkgConfig: /usr/bin/pkg-config (found version "1.7.3") 
||-- Checking for modules 'glib-2.0>=2.6.5;gthread-2.0>=2.6.5'
||--   Found glib-2.0, version 2.67.1
||--   Found gthread-2.0, version 2.67.1
||-- Checking for module 'sndfile>=1.0.0'
||--   Found sndfile, version 1.0.28
||-- Checking for module 'sndfile>=1.0.18'
||--   Found sndfile, version 1.0.28
||-- Checking for module 'libpulse-simple>=0.9.8'
||--   Found libpulse-simple, version 14.0
||-- Checking for module 'alsa>=0.9.1'
||--   Found alsa, version 1.2.4
||-- Checking for module 'jack'
||--   Found jack, version 0.125.0
||-- Checking for module 'lash-1.0>=0.3'
||--   Package 'lash-1.0', required by 'virtual:world', not found
||-- Checking for module 'libsystemd'
||--   Found libsystemd, version 247
||-- Checking for module 'dbus-1>=1.0.0'
||--   Found dbus-1, version 1.12.20
||-- Looking for ladspa.h
||-- Looking for ladspa.h - not found
||-- Checking for module 'libinstpatch-1.0>=1.1.0'
||--   Package 'libinstpatch-1.0', required by 'virtual:world', not found
||-- Checking for module 'sdl2'
||--   Found sdl2, version 2.0.12
||-- Checking for module 'readline'
||--   Found readline, version 8.1
||-- Found OpenMP 201511
||-- Looking for sinf
||-- Looking for sinf - not found
||-- Looking for cosf
||-- Looking for cosf - not found
||-- Looking for fabsf
||-- Looking for fabsf - not found
||-- Looking for powf
||-- Looking for powf - not found
||-- Looking for sqrtf
||-- Looking for sqrtf - not found
||-- Looking for logf
||-- Looking for logf - not found
||-- Found Doxygen: /usr/bin/doxygen (found version "1.8.20") found components: doxygen dot 
||-- Found LibXslt: /usr/lib/libxslt.so (found version "1.1.34") 
||-- 
||**************************************************************
||Build Summary:
||Build type:            RelWithDebInfo
||Install Prefix:        /usr/local
||
||Audio / MIDI driver support:
||  ALSA:                  yes
||  CoreAudio:             no
||  CoreMIDI:              no
||  DSound:                no
||  JACK:                  yes
||  MidiShare:             no
||  Oboe:                  no
||  OpenSLES:              no
||  OS/2 DART:             no
||  OSS:                   yes
||  PortAudio:             no
||  PulseAudio:            yes
||  SDL2:                  yes
||  WaveOut:               no
||  WinMidi:               no
||
||Support for SF3 files:   yes
||Support for DLS files:   no (libinstpatch not found)
||
||Audio to file rendering: yes
||  libsndfile:            yes
||
||Miscellaneous support:
||  D-Bus:                 yes
||  LADSPA support:        no
||  LASH support:          no
||  NETWORK Support:       yes
||    IPV6 Support:        yes
||  Readline:              yes (NOTE: GPL library)
||  systemd:               yes
||  getopt:                yes
||
||Developer nerds info:
||  Samples type:          double
||  Multithread rendering: yes
||  OpenMP 4.0:            yes
||  Profiling:             no
||  Debug Build:           no
||  Trap on FPE (debug):   no
||  Check FPE (debug):     no
||  UBSan (debug):         no
||
||**************************************************************
||
||
||-- Configuring done
||-- Generating done
||-- Build files have been written to: /tmp/proj/builddir/subprojects/fluidsynth/__CMake_build
|
|CMake configuration: SUCCEEDED
|WARNING: Unknown c_std "gnu90" -> Ignoring. Try setting the project-level c_std if build errors occur. Known c_stds are: none c89 c99 c11 c17 c18 c2x gnu89 gnu99 gnu11 gnu17 gnu18 gnu2x
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mesonbuild/mesonmain.py", line 140, in run
    return options.run_func(options)
  File "/usr/lib/python3.9/site-packages/mesonbuild/msetup.py", line 253, in run
    app.generate()
  File "/usr/lib/python3.9/site-packages/mesonbuild/msetup.py", line 161, in generate
    self._generate(env)
  File "/usr/lib/python3.9/site-packages/mesonbuild/msetup.py", line 200, in _generate
    intr.run()
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreter.py", line 4703, in run
    super().run()
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 519, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 544, in evaluate_codeblock
    raise e
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 537, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 552, in evaluate_statement
    self.assignment(cur)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 1219, in assignment
    value = self.evaluate_statement(node.value)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 554, in evaluate_statement
    return self.method_call(cur)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 951, in method_call
    return obj.method_call(method_name, args, kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreter.py", line 1833, in method_call
    value = fn(self.interpreter, state, args, kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 301, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 393, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 393, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 228, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreterbase.py", line 197, in wrapped
    return f(*wrapped_args, **wrapped_kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/modules/cmake.py", line 389, in subproject
    subp = interpreter.do_subproject(dirname, 'cmake', kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreter.py", line 2942, in do_subproject
    raise e
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreter.py", line 2928, in do_subproject
    return self._do_subproject_cmake(subp_name, subdir, subdir_abs, default_options, kwargs)
  File "/usr/lib/python3.9/site-packages/mesonbuild/interpreter.py", line 2996, in _do_subproject_cmake
    cm_int.analyse()
  File "/usr/lib/python3.9/site-packages/mesonbuild/cmake/interpreter.py", line 1005, in analyse
    tgt.postprocess(self.output_target_map, self.src_dir, self.subdir, self.install_prefix, self.trace)
  File "/usr/lib/python3.9/site-packages/mesonbuild/cmake/interpreter.py", line 465, in postprocess
    self.includes = list(OrderedSet([rel_path(x, True, False) for x in OrderedSet(self.includes)] + [build_dir_rel]))
  File "/usr/lib/python3.9/site-packages/mesonbuild/cmake/interpreter.py", line 465, in <listcomp>
    self.includes = list(OrderedSet([rel_path(x, True, False) for x in OrderedSet(self.includes)] + [build_dir_rel]))
  File "/usr/lib/python3.9/site-packages/mesonbuild/cmake/interpreter.py", line 458, in rel_path
    return x.relative_to(Path(self.env.get_build_dir()) / subdir)
  File "/usr/lib/python3.9/pathlib.py", line 928, in relative_to
    raise ValueError("{!r} is not in the subpath of {!r}"
ValueError: '/tmp/proj/builddir/subprojects/glib/glib' is not in the subpath of '/tmp/proj/builddir/subprojects/fluidsynth' OR one path is relative and the other is absolute.

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?