From 8f7a1c5591e27681f294ae5edf0f32689198abff Mon Sep 17 00:00:00 2001
From: Andrey Zhizhikin <andrey.z@gmail.com>
Date: Mon, 27 Jan 2020 10:22:35 +0000
Subject: [PATCH] opencv: resolve missing opencv data dir in yocto build

When Yocto build is performed, opencv searches for data dir using simple
'test' command, this fails because pkg-config provides an absolute
path on the target which needs to be prepended by PKG_CONFIG_SYSROOT_DIR
in order for the 'test' utility to pick up the absolute path.

Upstream-Status: Inappropriate [OE-specific]

Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
Signed-off-by: Jose Quaresma <quaresma.jose@gmail.com>
---
 gst-libs/gst/opencv/meson.build | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gst-libs/gst/opencv/meson.build b/gst-libs/gst/opencv/meson.build
index 64e913e..42a0958 100644
--- a/gst-libs/gst/opencv/meson.build
+++ b/gst-libs/gst/opencv/meson.build
@@ -61,6 +61,9 @@ gstopencv_cargs += ['-DOPENCV_PREFIX="' + opencv_prefix + '"']
 # /usr/include/opencv4/opencv2/flann/logger.h:83:36: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
 gstopencv_cargs += cxx.get_supported_arguments(['-Wno-missing-include-dirs', '-Wno-format-nonliteral'])
 
+pkgconf_sysroot = run_command(python3, '-c', 'import os; print(os.environ.get("PKG_CONFIG_SYSROOT_DIR"))').stdout().strip()
+opencv_prefix = pkgconf_sysroot + opencv_prefix
+
 # Check the data dir used by opencv for its xml data files
 # Use prefix from pkg-config to be compatible with cross-compilation
 fsmod = import('fs')
