From 604c8d5232eba961ca34c9e98de8d5454cd5ab5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 8 Jan 2019 13:30:29 +0100 Subject: [PATCH] msdk: meson: use libmfx pkg-config if available Refactoring to bail out early if MediaSDK is not found. based on the patches provided by Haihao Xiang --- sys/msdk/meson.build | 79 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/sys/msdk/meson.build b/sys/msdk/meson.build index 3e2b923..b9f9425 100644 --- a/sys/msdk/meson.build +++ b/sys/msdk/meson.build @@ -39,42 +39,53 @@ if msdk_option.disabled() subdir_done() endif -msdk_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))').stdout().strip() - -if msdk_root == '' and msdk_option.enabled() - error('msdk plugin enabled but Intel Media SDK not found: neither INTELMEDIASDKROOT nor MFX_HOME were set') -endif +mfx_dep = dependency('libmfx', required: false) +if mfx_dep.found() + mfx_incdir = mfx_dep.get_pkgconfig_variable('includedir') +else + # Old versions of MediaSDK don't provide a pkg-config file + mfx_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))').stdout().strip() -if msdk_root != '' - msdk_libdir = [msdk_root + '/lib/lin_x64', msdk_root + '/lib/x64', msdk_root + '/lib64', msdk_root + '/lib'] - msdk_incdir = include_directories(msdk_root + '/include') - if cxx.has_header('mfx/mfxdefs.h', args: '-I' + msdk_root + '/include') - cdata.set('HAVE_MFX_MFXDEFS_H', 1) - endif - msdk_lib = cxx.find_library('mfx', dirs: msdk_libdir, required: msdk_option) - if host_machine.system() == 'windows' - legacy_stdio_dep = cc.find_library('legacy_stdio_definitions', required: msdk_option) - d3d11_dep = cc.find_library('d3d11', required: msdk_option) - msdk_dep = declare_dependency(include_directories: msdk_incdir, dependencies: [msdk_lib, d3d11_dep, legacy_stdio_dep]) - msdk_dep_found = msdk_lib.found() and d3d11_dep.found() and legacy_stdio_dep.found() and cc.get_id() == 'msvc' + if mfx_root != '' + mfx_libdir = [mfx_root + '/lib/lin_x64', mfx_root + '/lib/x64', mfx_root + '/lib64', mfx_root + '/lib'] + mfx_incdir = join_paths([mfx_root, 'include']) + mfx_lib = cxx.find_library('mfx', dirs: mfx_libdir, required: mfx_option) + mfx_inc = include_directories(mfx_incdir) + mfx_dep = declare_dependency(include_directories: mfx_inc, dependencies: mfx_lib) + elif msdk_option.enabled() + error('msdk plugin enabled but Intel Media SDK not found: consider setting PKG_CONFIG_PATH, INTELMEDIASDKROOT or MFX_HOME') else - libva_dep = dependency('libva-drm', required: msdk_option) - libdl_dep = cc.find_library('dl', required: msdk_option) - libgudev_dep = dependency('gudev-1.0', required: msdk_option) - msdk_dep = declare_dependency(include_directories: msdk_incdir, dependencies: [msdk_lib, libva_dep, libdl_dep, libgudev_dep]) - msdk_dep_found = msdk_lib.found() and libva_dep.found() and libdl_dep.found() and libgudev_dep.found() + subdir_done() endif +endif - if msdk_dep_found - gstmsdktag = library('gstmsdk', - msdk_sources, - c_args : gst_plugins_bad_args, - include_directories : [configinc], - dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstallocators_dep, msdk_dep], - install : true, - install_dir : plugins_install_dir, - ) - pkgconfig.generate(gstmsdktag, install_dir : plugins_pkgconfig_install_dir) - have_msdk = true - endif +# Old versions of MediaSDK don't have the 'mfx' directory prefix +if cxx.has_header('mfx/mfxdefs.h', args: '-I' + mfx_incdir) + cdata.set('HAVE_MFX_MFXDEFS_H', 1) +endif + +if host_machine.system() == 'windows' + legacy_stdio_dep = cc.find_library('legacy_stdio_definitions', required: true) + d3d11_dep = cc.find_library('d3d11', required: true) + msdk_deps = declare_dependency(dependencies: [d3d11_dep, legacy_stdio_dep]) + msdk_deps_found = d3d11_dep.found() and legacy_stdio_dep.found() and cc.get_id() == 'msvc' +else + libva_dep = dependency('libva-drm', required: true) + libdl_dep = cc.find_library('dl', required: true) + libgudev_dep = dependency('gudev-1.0', required: true) + msdk_deps = declare_dependency(dependencies: [libva_dep, libdl_dep, libgudev_dep]) + msdk_deps_found = libva_dep.found() and libdl_dep.found() and libgudev_dep.found() +endif + +if msdk_deps_found + gstmsdktag = library('gstmsdk', + msdk_sources, + c_args : gst_plugins_bad_args, + include_directories : [configinc], + dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstallocators_dep, mfx_dep, msdk_deps], + install : true, + install_dir : plugins_install_dir, + ) + pkgconfig.generate(gstmsdktag, install_dir : plugins_pkgconfig_install_dir) + have_msdk = true endif -- 2.7.4