meson: Add -Wl,-rpath,${libdir} on macOS
authorNirbheek Chauhan <nirbheek@centricular.com>
Mon, 18 Apr 2022 10:14:47 +0000 (15:44 +0530)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 19 Apr 2022 12:11:17 +0000 (12:11 +0000)
We made the gstreamer installation prefix relocatable by picking up
plugins relative to the location of libgstreamer-1.0.dylib, similar to
how it's done for Windows:

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1627

This had a lot of side-effects:

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1051
https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/363
https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/371
https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/362

A partial fix for the cerbero side of these was:

https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/807

However, this relied on the consumers knowing that they need to add
`LC_RPATH` entries to the libdir of the prefix. This is done
automatically by build systems like Meson, but not by others, such as
Autotools, CMake, Cargo, XCode, etc. For those, we need to add the
RPATH entries to the gstreamer-1.0.pc file.

This also has the side-effect of fixing the loading of gstreamer rust
plugins on macOS:

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1159

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1149

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2218>

subprojects/gst-plugins-base/gst-libs/gst/sdp/meson.build
subprojects/gstreamer/gst/meson.build
subprojects/gstreamer/meson.build

index 4841d61..c8d3851 100644 (file)
@@ -24,6 +24,7 @@ library_def = {'lib': gstsdp}
 pkg_name = 'gstreamer-sdp-1.0'
 sdp_gen_sources  = []
 pkgconfig.generate(gstsdp,
+  libraries : [gst_dep],
   variables : pkgconfig_variables,
   subdirs : pkgconfig_subdirs,
   name : pkg_name,
index 2692e19..e1e8b6c 100644 (file)
@@ -259,7 +259,7 @@ libgst = library('gstreamer-1.0', gst_sources,
 pkg_name = 'gstreamer-1.0'
 library_def = {'lib': libgst}
 pkgconfig.generate(libgst,
-  libraries : [glib_dep, gobject_dep],
+  libraries : [glib_dep, gobject_dep] + pkgconfig_libs,
   variables : pkgconfig_variables,
   uninstalled_variables: pkgconfig_uninstalled_variables,
   subdirs : pkgconfig_subdirs,
index 17c7e17..a293e43 100644 (file)
@@ -616,6 +616,10 @@ pkgconfig_uninstalled_variables = ['exec_prefix=${prefix}',
     'bashhelpersdir=${gstreamerdir}/data/bash-completion/helpers',
     'helpersdir=${gstreamerdir}/libs/gst/helpers']
 pkgconfig_subdirs = ['gstreamer-1.0']
+pkgconfig_libs = []
+if host_system == 'darwin'
+  pkgconfig_libs = ['-Wl,-rpath,${libdir}']
+endif
 
 static_build = get_option('default_library') == 'static'
 libraries = []