summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJörg Krause <joerg.krause@embedded.rocks>2019-02-27 22:20:46 +0100
committerMax Kellermann <max@musicpd.org>2019-03-18 09:12:19 +0100
commit7f87de783fb5107048f1d7b98278156c00b2f144 (patch)
tree0c77e8fced77806f446a6b1a59fd91a8fd8e0d65 /src
parentc66389a453c6acb8d78bfba86baee9b7071eb553 (diff)
src/lib/gcrypt/meson.build: use dependency() for quering linker flags
Since version 0.49.0 the Meson build system has native support for finding and using the gcrypt library using the `dependency()` function. `dependency()` has the advantage over `find_library()` as it queries the required linker flags for proper linking with external libraries, e.g. libgpg-error. As the latest released version 1.8.4 of libgcrypt does not provide a .pc file, using `libgcrypt-config` is the only way to query the required linker flags. Unfortunately, there is an issue when cross compiling mpd and the user does not define `libgcrypt-config` in the cross file. If the user sets the qobuz feature to `auto` and the target does not have libgcrypt installed, the Meson build system will falsly assume libgcrypt is available for the target as it uses the native `libgcrypt-config` on the host and pretend is has found the library. Therefore, we still rely on `find_library()` to workaround this buggy behavior. This way, if qobuz feature detection is set to `auto`, the feature is disabled in case there is no target libgcrypt available. Fixes building mpd statically with the qobuz feature enabled. Otherwise the build fails with undefined references because of the missing libgpg-error dependency: ``` /sysroot/usr/lib/libgcrypt.a(libgcrypt_la-visibility.o): In function `gcry_strerror': visibility.c:(.text+0x14): undefined reference to `gpg_strerror' ```
Diffstat (limited to 'src')
-rw-r--r--src/lib/gcrypt/meson.build13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/gcrypt/meson.build b/src/lib/gcrypt/meson.build
index 48297e279..5840bfe4d 100644
--- a/src/lib/gcrypt/meson.build
+++ b/src/lib/gcrypt/meson.build
@@ -1,4 +1,17 @@
+# Since version 0.49.0 Meson has native libgcrypt dependency support, which has
+# the advantage over find_library() as it uses libgcrypt-config to query the
+# required linker flags.
+# However, we still need to use find_library() first, to prevent Meson
+# falsly assuming a target libgcrypt is available in case there is no
+# libgcrypt-config entry in the cross file and libgcrypt is installed on the
+# host. In this case, Meson will falsly use the native libgcrypt-config and
+# will falsly assume it has found the gcrypt library for the target.
+#
+# See: https://github.com/MusicPlayerDaemon/MPD/pull/495
gcrypt_dep = c_compiler.find_library('gcrypt', required: get_option('qobuz'))
+if gcrypt_dep.found()
+ gcrypt_dep = dependency('libgcrypt')
+endif
if not gcrypt_dep.found()
subdir_done()
endif