From 4c6a0b655d767c21cad1ed09a8a9c66fcba7b5bd Mon Sep 17 00:00:00 2001
From: Jan Schmidt <jan@centricular.com>
Date: Fri, 23 May 2025 09:33:35 +0200
Subject: [PATCH] meson: Add build_rpath for qt6 plugin on macOS

This is the same fix for qt6 that was done for the qt5 plugin
in gstreamer/gstreamer!3708

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9059>
---
 subprojects/gst-plugins-good/ext/qt6/meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/subprojects/gst-plugins-good/ext/qt6/meson.build b/subprojects/gst-plugins-good/ext/qt6/meson.build
index 19dc84182e..79987d8f0f 100644
--- a/subprojects/gst-plugins-good/ext/qt6/meson.build
+++ b/subprojects/gst-plugins-good/ext/qt6/meson.build
@@ -223,9 +223,18 @@ if qt6_option.require(have_qt_windowing, error_message: 'No windowing, enable on
   resource_file = configure_file(input: 'resources.qrc', output: 'resources.qrc', copy: true)
   qresources = qt6_mod.compile_resources(sources: resource_file, method: qt6_method)
 
+  qml6gl_kwargs = {}
+  if host_system == 'darwin'
+    fs = import('fs')
+    qt_bindir = fs.parent(find_program('qmake6').full_path())
+    qt_libdir = fs.parent(qt_bindir) / 'lib'
+    qml6gl_kwargs += {'build_rpath': qt_libdir}
+  endif
+
   gstqml6gl = library('gstqml6', qt6_sources, moc_files, qresources,
     cpp_args : gst_plugins_good_args + qt_defines,
     link_args : noseh_link_args,
+    kwargs: qml6gl_kwargs,
     include_directories: [configinc, libsinc],
     dependencies : [gst_dep, gstvideo_dep, gstgl_dep, gstglproto_dep, qt6qml_dep, optional_deps],
     override_options : ['cpp_std=c++17'],