Prevent cudacodec libs locations being reset when cmake is re-run#22880
Prevent cudacodec libs locations being reset when cmake is re-run#22880asmorkalov merged 1 commit intoopencv:4.xfrom
Conversation
|
@cudawarped Thanks for the contribution. I suspect that you just need to remove WIN32 condition here: https://github.com/opencv/opencv/blob/4.x/cmake/FindCUDA.cmake#L792 without extra changes in cmake. |
|
@asmorkalov Unless an old version of Cmake is used or the behaviour is overidden OpenCV use CMake's internal version of FindCUDA which we can't alter. Inside CMake's version the problem appears to be a result of
This is not an issue if the libraries are in a location which FindCUDA searches as they can be picked up again but it is a issue if they were supplied at the command line ( My initial fix was to set Should we instead make changes to the OpenCV version of FindCUDA and force it to be used here |
|
@alalek What is your opinion? The proposed solution with |
cmake/OpenCVDetectCUDA.cmake
Outdated
| ocv_cuda_SEARCH_NVCUVID_HEADER("nvcuvid.h" HAVE_NVCUVID_HEADER) | ||
| ocv_cuda_SEARCH_NVCUVID_HEADER("dynlink_nvcuvid.h" HAVE_DYNLINK_NVCUVID_HEADER) | ||
| if(DEFINED CUDA_nvcuvid_LIBRARY_INTERNAL) | ||
| set(CUDA_nvcuvid_LIBRARY ${CUDA_nvcuvid_LIBRARY_INTERNAL} CACHE FILEPATH "\"nvcuvid\" library" FORCE) |
There was a problem hiding this comment.
calls to FindCUDA can reset
Should we check for the empty value then?
There was a problem hiding this comment.
@alalek I agree but I've just noticed this issue was fixed in CMake 6 months ago https://gitlab.kitware.com/cmake/cmake/-/commit/a7758394afc2717bb31a47826e62c1ba86a63c41. I suggest for compatibility with older versions of CMake we could apply the same fix as mentioned there.
…when cmake is re-run and add log info when the libs/headers cannot be found.
0bd756f to
b1288da
Compare
If cmake is run a second time then the location of the Nvidia Video Codec SDK libs are reset due to the implementation of FindCUDA.cmake. This was observerd in opencv/opencv_contrib#3195 (comment).
This PR also forces
WITH_NVCUVIDandWITH_NVCUVENCto default toONso that if the libs are present decoding and/or encoding support is added to cudacodec without the user having to manually specify it. This mirrors the way in which the DNN module is built with cuDNN if the cuDNN libs are present without the user having to specifyWITH_CUDNN=ON.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.