mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #22462 from Biswa96:fix-directx-check
* cmake: Fix DirectX detection in mingw The pragma comment directive is valid for MSVC only. So, the DirectX detection fails in mingw. The failure is fixed by adding the required linking library (here d3d11) in the try_compile() function in OpenCVDetectDirectX.cmake file. Also add a message if the first DirectX check fails. * gapi: Fix compilation with mingw These changes remove MSVC specific pragma directive. The compilation fails at linking time due to absence of proper linking library. The required libraries are added in corresponding CMakeLists.txt file. * samples: Fix compilation with mingw These changes remove MSVC specific pragma directive. The compilation fails at linking time due to absence of proper linking library. The required libraries are added in corresponding CMakeLists.txt file.
This commit is contained in:
parent
1646a21197
commit
6cf0910842
@ -2,15 +2,18 @@ if(WIN32)
|
|||||||
try_compile(__VALID_DIRECTX
|
try_compile(__VALID_DIRECTX
|
||||||
"${OpenCV_BINARY_DIR}"
|
"${OpenCV_BINARY_DIR}"
|
||||||
"${OpenCV_SOURCE_DIR}/cmake/checks/directx.cpp"
|
"${OpenCV_SOURCE_DIR}/cmake/checks/directx.cpp"
|
||||||
|
LINK_LIBRARIES d3d11
|
||||||
OUTPUT_VARIABLE TRY_OUT
|
OUTPUT_VARIABLE TRY_OUT
|
||||||
)
|
)
|
||||||
if(NOT __VALID_DIRECTX)
|
if(NOT __VALID_DIRECTX)
|
||||||
|
message(STATUS "No support for DirectX (install Windows 8 SDK)")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
try_compile(__VALID_DIRECTX_NV12
|
try_compile(__VALID_DIRECTX_NV12
|
||||||
"${OpenCV_BINARY_DIR}"
|
"${OpenCV_BINARY_DIR}"
|
||||||
"${OpenCV_SOURCE_DIR}/cmake/checks/directx.cpp"
|
"${OpenCV_SOURCE_DIR}/cmake/checks/directx.cpp"
|
||||||
COMPILE_DEFINITIONS "-DCHECK_NV12"
|
COMPILE_DEFINITIONS "-DCHECK_NV12"
|
||||||
|
LINK_LIBRARIES d3d11
|
||||||
OUTPUT_VARIABLE TRY_OUT
|
OUTPUT_VARIABLE TRY_OUT
|
||||||
)
|
)
|
||||||
if(__VALID_DIRECTX_NV12)
|
if(__VALID_DIRECTX_NV12)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#pragma comment (lib, "d3d11.lib")
|
|
||||||
|
|
||||||
HINSTANCE g_hInst = NULL;
|
HINSTANCE g_hInst = NULL;
|
||||||
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
|
D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
|
||||||
|
@ -317,6 +317,12 @@ if(HAVE_GAPI_ONEVPL)
|
|||||||
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_ONEVPL)
|
ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_ONEVPL)
|
||||||
ocv_target_link_libraries(${the_module} PRIVATE ${VPL_IMPORTED_TARGETS})
|
ocv_target_link_libraries(${the_module} PRIVATE ${VPL_IMPORTED_TARGETS})
|
||||||
|
|
||||||
|
if(HAVE_DIRECTX AND HAVE_D3D11)
|
||||||
|
ocv_target_link_libraries(${the_module} PRIVATE d3d11 dxgi)
|
||||||
|
endif()
|
||||||
|
if(WIN32)
|
||||||
|
ocv_target_link_libraries(${the_module} PRIVATE mf mfuuid mfplat shlwapi mfreadwrite)
|
||||||
|
endif()
|
||||||
if(HAVE_D3D11 AND HAVE_OPENCL)
|
if(HAVE_D3D11 AND HAVE_OPENCL)
|
||||||
ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
|
ocv_target_include_directories(${the_module} SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
@ -369,6 +375,9 @@ if(TARGET example_gapi_onevpl_infer_single_roi)
|
|||||||
if(TARGET ocv.3rdparty.openvino AND OPENCV_GAPI_WITH_OPENVINO)
|
if(TARGET ocv.3rdparty.openvino AND OPENCV_GAPI_WITH_OPENVINO)
|
||||||
ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE ocv.3rdparty.openvino)
|
ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE ocv.3rdparty.openvino)
|
||||||
endif()
|
endif()
|
||||||
|
if(HAVE_DIRECTX AND HAVE_D3D11)
|
||||||
|
ocv_target_link_libraries(example_gapi_onevpl_infer_single_roi PRIVATE d3d11 dxgi)
|
||||||
|
endif()
|
||||||
if(HAVE_D3D11 AND HAVE_OPENCL)
|
if(HAVE_D3D11 AND HAVE_OPENCL)
|
||||||
ocv_target_include_directories(example_gapi_onevpl_infer_single_roi SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
|
ocv_target_include_directories(example_gapi_onevpl_infer_single_roi SYSTEM PRIVATE ${OPENCL_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
@ -20,13 +20,11 @@
|
|||||||
|
|
||||||
#ifdef HAVE_DIRECTX
|
#ifdef HAVE_DIRECTX
|
||||||
#ifdef HAVE_D3D11
|
#ifdef HAVE_D3D11
|
||||||
#pragma comment(lib,"d3d11.lib")
|
|
||||||
|
|
||||||
// get rid of generate macro max/min/etc from DX side
|
// get rid of generate macro max/min/etc from DX side
|
||||||
#define D3D11_NO_HELPERS
|
#define D3D11_NO_HELPERS
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#pragma comment(lib, "dxgi")
|
|
||||||
#undef NOMINMAX
|
#undef NOMINMAX
|
||||||
#undef D3D11_NO_HELPERS
|
#undef D3D11_NO_HELPERS
|
||||||
#endif // HAVE_D3D11
|
#endif // HAVE_D3D11
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
|
|
||||||
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
#if defined(HAVE_DIRECTX) && defined(HAVE_D3D11)
|
||||||
#pragma comment(lib,"d3d11.lib")
|
|
||||||
|
|
||||||
#define D3D11_NO_HELPERS
|
#define D3D11_NO_HELPERS
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_DIRECTX
|
#ifdef HAVE_DIRECTX
|
||||||
#ifdef HAVE_D3D11
|
#ifdef HAVE_D3D11
|
||||||
#pragma comment(lib,"d3d11.lib")
|
|
||||||
|
|
||||||
#define D3D11_NO_HELPERS
|
#define D3D11_NO_HELPERS
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
|
@ -17,14 +17,12 @@
|
|||||||
|
|
||||||
#ifdef HAVE_DIRECTX
|
#ifdef HAVE_DIRECTX
|
||||||
#ifdef HAVE_D3D11
|
#ifdef HAVE_D3D11
|
||||||
#pragma comment(lib,"d3d11.lib")
|
|
||||||
|
|
||||||
// get rid of generate macro max/min/etc from DX side
|
// get rid of generate macro max/min/etc from DX side
|
||||||
#define D3D11_NO_HELPERS
|
#define D3D11_NO_HELPERS
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include <d3d11_4.h>
|
#include <d3d11_4.h>
|
||||||
#pragma comment(lib, "dxgi")
|
|
||||||
#undef D3D11_NO_HELPERS
|
#undef D3D11_NO_HELPERS
|
||||||
#undef NOMINMAX
|
#undef NOMINMAX
|
||||||
#endif // HAVE_D3D11
|
#endif // HAVE_D3D11
|
||||||
|
@ -5,14 +5,6 @@
|
|||||||
// Copyright (C) 2021 Intel Corporation
|
// Copyright (C) 2021 Intel Corporation
|
||||||
#ifdef HAVE_ONEVPL
|
#ifdef HAVE_ONEVPL
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
#pragma comment(lib, "Mf.lib")
|
|
||||||
#pragma comment(lib, "Mfuuid.lib")
|
|
||||||
#pragma comment(lib, "Mfplat.lib")
|
|
||||||
#pragma comment(lib, "shlwapi.lib")
|
|
||||||
#pragma comment(lib, "mfreadwrite.lib")
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
#include <opencv2/gapi/own/assert.hpp>
|
#include <opencv2/gapi/own/assert.hpp>
|
||||||
#include "streaming/onevpl/demux/async_mfp_demux_data_provider.hpp"
|
#include "streaming/onevpl/demux/async_mfp_demux_data_provider.hpp"
|
||||||
|
@ -19,4 +19,16 @@ foreach(sample_filename ${all_samples})
|
|||||||
ocv_define_sample(tgt ${sample_filename} directx)
|
ocv_define_sample(tgt ${sample_filename} directx)
|
||||||
ocv_target_link_libraries(${tgt} PRIVATE ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
ocv_target_link_libraries(${tgt} PRIVATE ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||||
ocv_target_link_libraries(${tgt} PRIVATE "gdi32")
|
ocv_target_link_libraries(${tgt} PRIVATE "gdi32")
|
||||||
|
if(sample_filename STREQUAL "d3d9_interop.cpp")
|
||||||
|
ocv_target_link_libraries(${tgt} PRIVATE d3d9)
|
||||||
|
endif()
|
||||||
|
if(sample_filename STREQUAL "d3d9ex_interop.cpp")
|
||||||
|
ocv_target_link_libraries(${tgt} PRIVATE d3d9)
|
||||||
|
endif()
|
||||||
|
if(sample_filename STREQUAL "d3d10_interop.cpp")
|
||||||
|
ocv_target_link_libraries(${tgt} PRIVATE d3d10)
|
||||||
|
endif()
|
||||||
|
if(sample_filename STREQUAL "d3d11_interop.cpp")
|
||||||
|
ocv_target_link_libraries(${tgt} PRIVATE d3d11)
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "d3dsample.hpp"
|
#include "d3dsample.hpp"
|
||||||
|
|
||||||
#pragma comment (lib, "d3d10.lib")
|
|
||||||
|
|
||||||
class D3D10WinApp : public D3DSample
|
class D3D10WinApp : public D3DSample
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "d3dsample.hpp"
|
#include "d3dsample.hpp"
|
||||||
|
|
||||||
#pragma comment (lib, "d3d11.lib")
|
|
||||||
|
|
||||||
class D3D11WinApp : public D3DSample
|
class D3D11WinApp : public D3DSample
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "d3dsample.hpp"
|
#include "d3dsample.hpp"
|
||||||
|
|
||||||
#pragma comment (lib, "d3d9.lib")
|
|
||||||
|
|
||||||
|
|
||||||
class D3D9WinApp : public D3DSample
|
class D3D9WinApp : public D3DSample
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include "d3dsample.hpp"
|
#include "d3dsample.hpp"
|
||||||
|
|
||||||
#pragma comment (lib, "d3d9.lib")
|
|
||||||
|
|
||||||
|
|
||||||
class D3D9ExWinApp : public D3DSample
|
class D3D9ExWinApp : public D3DSample
|
||||||
|
@ -27,12 +27,6 @@
|
|||||||
|
|
||||||
#include "winapp.hpp"
|
#include "winapp.hpp"
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
# pragma comment(lib, "opengl32.lib")
|
|
||||||
# pragma comment(lib, "glu32.lib")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class GLWinApp : public WinApp
|
class GLWinApp : public WinApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user