mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Update OpenCVDetectCUDA.cmake
Adds the option to enable delay loading of CUDA DLLs on Windows. This is particularly useful to use the same binary on systems with and without CUDA support without distributing the CUDA DLLs to systems that cannot use them at all due to missing CUDA-supported hardware. Resolves #13509
This commit is contained in:
parent
e80b443cd9
commit
332ff4bf1c
@ -342,6 +342,8 @@ if(CUDA_FOUND)
|
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)
|
||||
endif()
|
||||
|
||||
OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
|
||||
|
||||
mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD CUDA_SDK_ROOT_DIR)
|
||||
|
||||
macro(ocv_cuda_filter_options)
|
||||
@ -537,4 +539,15 @@ if(HAVE_CUDA)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}${p})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(MSVC AND CUDA_ENABLE_DELAYLOAD)
|
||||
file(GLOB CUDA_DLLS "${CUDA_TOOLKIT_ROOT_DIR}/bin/*.dll")
|
||||
foreach(d ${CUDA_DLLS})
|
||||
cmake_path(GET "d" FILENAME DLL_NAME)
|
||||
if(NOT ${DLL_NAME} MATCHES "cudart")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:${DLL_NAME}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /IGNORE:4199")
|
||||
endif()
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user