From b3b235ebc0be024c251b1689f9f184ea2b35ec36 Mon Sep 17 00:00:00 2001 From: SergeyIvanov87 Date: Fri, 8 Jul 2022 17:15:31 +0300 Subject: [PATCH] Apply WITHA_VA option in cmake --- modules/gapi/CMakeLists.txt | 30 +++++++++---------- .../gapi/samples/onevpl_infer_single_roi.cpp | 2 -- .../onevpl/device_selector_interface.cpp | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/modules/gapi/CMakeLists.txt b/modules/gapi/CMakeLists.txt index 4e45c4432f..63373ad9c4 100644 --- a/modules/gapi/CMakeLists.txt +++ b/modules/gapi/CMakeLists.txt @@ -320,21 +320,17 @@ if(HAVE_GAPI_ONEVPL) endif() if(UNIX) - find_package(PkgConfig) - if(PkgConfig_FOUND) - pkg_check_modules(PKG_LIBVA libva>=1.2 libva-drm>=1.2) - if(PKG_LIBVA_FOUND) - set(CMAKE_THREAD_PREFER_PTHREAD TRUE) - set(THREADS_PREFER_PTHREAD_FLAG TRUE) - find_package(Threads REQUIRED) - else() - message(FATAL_ERROR "libva not found: building HAVE_GAPI_ONEVPL without libVA support is impossible on UNIX systems") + if(WITH_VA) + include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindVA.cmake") + if(VA_INCLUDE_DIR) + ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${VA_INCLUDE_DIR}) + ocv_target_include_directories(opencv_test_gapi SYSTEM PRIVATE ${VA_INCLUDE_DIR}) + ocv_target_link_libraries(${the_module} PRIVATE ${VA_LIBRARIES}) + ocv_target_link_libraries(opencv_test_gapi PRIVATE ${VA_LIBRARIES}) endif() - else() - message(FATAL_ERROR "PkgConfig not found: building HAVE_GAPI_ONEVPL without libVA support is impossible on UNIX systems") - endif() - ocv_target_link_libraries(${the_module} PRIVATE ${PKG_LIBVA_LIBRARIES} ${PKG_THREAD_LIBRARIES}) - ocv_target_link_libraries(opencv_test_gapi PRIVATE ${PKG_LIBVA_LIBRARIES} ${PKG_THREAD_LIBRARIES}) + else(WITH_VA) + message(FATAL_ERROR "libva not found: building HAVE_GAPI_ONEVPL without libVA support is impossible on UNIX systems") + endif(WITH_VA) endif() endif() @@ -374,8 +370,10 @@ if(TARGET example_gapi_onevpl_infer_single_roi) if(HAVE_D3D11 AND HAVE_OPENCL) ocv_target_include_directories(example_gapi_onevpl_infer_single_roi SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS}) endif() - if(PKG_LIBVA_FOUND) - ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE ${PKG_LIBVA_LIBRARIES} ${PKG_THREAD_LIBRARIES}) + if(WITH_VA AND UNIX) + message ("GAPI VPL samples with VAAPI") + ocv_target_include_directories(example_gapi_onevpl_infer_single_roi SYSTEM PRIVATE ${VA_INCLUDE_DIR}) + ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE ${VA_LIBRARIES}) endif() endif() diff --git a/modules/gapi/samples/onevpl_infer_single_roi.cpp b/modules/gapi/samples/onevpl_infer_single_roi.cpp index ed8c74ea8c..15f3813787 100644 --- a/modules/gapi/samples/onevpl_infer_single_roi.cpp +++ b/modules/gapi/samples/onevpl_infer_single_roi.cpp @@ -102,7 +102,6 @@ cv::util::optional parse_roi(const std::string &rc) { return cv::util::make_optional(std::move(rv)); } -#ifdef HAVE_INF_ENGINE #ifdef HAVE_DIRECTX #ifdef HAVE_D3D11 @@ -152,7 +151,6 @@ AccelParamsType create_device_with_ctx(IDXGIAdapter* adapter) { } #endif // HAVE_D3D11 #endif // HAVE_DIRECTX -#endif // HAVE_INF_ENGINE } // anonymous namespace namespace custom { diff --git a/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp b/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp index 0b374177da..ecc02cd830 100644 --- a/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp +++ b/modules/gapi/src/streaming/onevpl/device_selector_interface.cpp @@ -121,7 +121,7 @@ Context create_dx11_context(Context::Ptr ctx_ptr) { Device create_vaapi_device(Device::Ptr device_ptr, const std::string& device_name, - int file_description) { + int /*file_description*/) { return detail::DeviceContextCreator::create_entity(device_ptr, device_name, AccelType::VAAPI);