cmake,obs-ffmpeg: Refactor Libva finder

This refactor adds Libva DRM, required for obs-ffmpeg

(cherry picked from commit ee144377dc)
This commit is contained in:
tytan652
2023-01-31 16:08:40 -08:00
committed by Jim
parent c55ce029af
commit 3c6aaeb142
2 changed files with 38 additions and 12 deletions
+37 -11
View File
@@ -1,9 +1,10 @@
# * Try to find Libva, once done this will define
#
# * LIBVA_FOUND - system has Libva
# * LIBVA_INCLUDE_DIRS - the Libva include directory
# * LIBVA_LIBRARIES - the libraries needed to use Libva
# * LIBVA_DEFINITIONS - Compiler switches required for using Libva
# This module defines the following variables:
#
# * LIBVA_FOUND - The component was found
# * LIBVA_INCLUDE_DIRS - The component include directory
# * LIBVA_LIBRARIES - The component library Libva
# * LIBVA_DRM_LIBRARIES - The component library Libva DRM
# Use pkg-config to get the directories and then use these values in the
# find_path() and find_library() calls
@@ -11,14 +12,14 @@
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(_LIBVA libva)
pkg_check_modules(_LIBVA_DRM libva-drm)
endif()
find_path(
LIBVA_INCLUDE_DIR
NAMES va.h
NAMES va/va.h va/va_drm.h
HINTS ${_LIBVA_INCLUDE_DIRS}
PATHS /usr/include /usr/local/include /opt/local/include
PATH_SUFFIXES va/)
PATHS /usr/include /usr/local/include /opt/local/include)
find_library(
LIBVA_LIB
@@ -26,14 +27,21 @@ find_library(
HINTS ${_LIBVA_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib /opt/local/lib)
find_library(
LIBVA_DRM_LIB
NAMES ${_LIBVA_DRM_LIBRARIES} libva-drm
HINTS ${_LIBVA_DRM_LIBRARY_DIRS}
PATHS /usr/lib /usr/local/lib /opt/local/lib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libva REQUIRED_VARS LIBVA_LIB
LIBVA_INCLUDE_DIR)
mark_as_advanced(LIBVA_INCLUDE_DIR LIBVA_LIB)
find_package_handle_standard_args(Libva REQUIRED_VARS LIBVA_INCLUDE_DIR
LIBVA_LIB LIBVA_DRM_LIB)
mark_as_advanced(LIBVA_INCLUDE_DIR LIBVA_LIB LIBVA_DRM_LIB)
if(LIBVA_FOUND)
set(LIBVA_INCLUDE_DIRS ${LIBVA_INCLUDE_DIR})
set(LIBVA_LIBRARIES ${LIBVA_LIB})
set(LIBVA_DRM_LIBRARIES ${LIBVA_DRM_LIB})
if(NOT TARGET Libva::va)
if(IS_ABSOLUTE "${LIBVA_LIBRARIES}")
@@ -45,5 +53,23 @@ if(LIBVA_FOUND)
set_target_properties(Libva::va PROPERTIES IMPORTED_LIBNAME
"${LIBVA_LIBRARIES}")
endif()
set_target_properties(Libva::va PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${LIBVA_INCLUDE_DIRS}")
endif()
if(NOT TARGET Libva::drm)
if(IS_ABSOLUTE "${LIBVA_DRM_LIBRARIES}")
add_library(Libva::drm UNKNOWN IMPORTED)
set_target_properties(Libva::drm PROPERTIES IMPORTED_LOCATION
"${LIBVA_DRM_LIBRARIES}")
else()
add_library(Libva::drm INTERFACE IMPORTED)
set_target_properties(Libva::drm PROPERTIES IMPORTED_LIBNAME
"${LIBVA_DRM_LIBRARIES}")
endif()
set_target_properties(Libva::drm PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${LIBVA_INCLUDE_DIRS}")
endif()
endif()
+1 -1
View File
@@ -123,7 +123,7 @@ elseif(OS_POSIX AND NOT OS_MACOS)
find_package(Libpci REQUIRED)
target_sources(obs-ffmpeg PRIVATE obs-ffmpeg-vaapi.c vaapi-utils.c
vaapi-utils.h)
target_link_libraries(obs-ffmpeg PRIVATE Libva::va LIBPCI::LIBPCI)
target_link_libraries(obs-ffmpeg PRIVATE Libva::va Libva::drm LIBPCI::LIBPCI)
endif()
setup_plugin_target(obs-ffmpeg)