cmake: Fix DirectX detection in mingw#22462
cmake: Fix DirectX detection in mingw#22462alalek merged 3 commits intoopencv:4.xfrom Biswa96:fix-directx-check
Conversation
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.
| #include <windows.h> | ||
|
|
||
| #include <d3d11.h> | ||
| #pragma comment (lib, "d3d11.lib") |
There was a problem hiding this comment.
There is still several places in OpenCV codebase which use this approach (and they don't use LINK_LIBRARIES).
Fix should be complete and not introduce mess.
Try cmake -DBUILD_EXAMPLES=ON ...
There was a problem hiding this comment.
Understood. I have already built those. But I thought those will require a separate PR according to the guidelines. I shall add another commit here.
There was a problem hiding this comment.
Question. The samples/opengl/opengl_interop.cpp file contains pragma comment directive but it is not compiled for Windows platform because X11_FOUND is false. Would you like to take look at it?
There was a problem hiding this comment.
I have added the required changes. Please review.
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.
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.
|
@alalek please take a look. |
|
|
Those can not be compiled with mingw-w64 toolchain yet. missing symbols, compiler error etc. |
alalek
left a comment
There was a problem hiding this comment.
LGTM 👍
Thank you for contribution!
* 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.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.