Skip to content

Commit eb6678e

Browse files
authored
Merge pull request opencv#17699 from alalek:build_core_cuda
* core(cuda): fix build - MSVS 19.25.28612.0 - CUDA release 11.0, V11.0.167 * cmake(cuda): backport workaround for CUDA 11 * cmake(cuda): call CUDA_BUILD_CLEAN_TARGET() on finalize * cmake(cuda): use CMAKE_SUPPRESS_REGENERATION with MSVS
1 parent d62e0a3 commit eb6678e

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,10 @@ if(ENABLE_CONFIG_VERIFICATION)
16521652
ocv_verify_config()
16531653
endif()
16541654

1655+
if(HAVE_CUDA AND COMMAND CUDA_BUILD_CLEAN_TARGET)
1656+
CUDA_BUILD_CLEAN_TARGET()
1657+
endif()
1658+
16551659
ocv_cmake_hook(POST_FINALIZE)
16561660

16571661
# ----------------------------------------------------------------------------

cmake/OpenCVDetectCUDA.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ endif()
2828

2929
if(CUDA_FOUND)
3030
set(HAVE_CUDA 1)
31+
if(NOT CUDA_VERSION VERSION_LESS 11.0)
32+
# CUDA 11.0 removes nppicom
33+
ocv_list_filterout(CUDA_nppi_LIBRARY "nppicom")
34+
ocv_list_filterout(CUDA_npp_LIBRARY "nppicom")
35+
endif()
3136

3237
if(WITH_CUFFT)
3338
set(HAVE_CUFFT 1)
@@ -370,4 +375,11 @@ if(HAVE_CUDA)
370375
set(CUDA_cufft_LIBRARY_ABS ${CUDA_cufft_LIBRARY})
371376
ocv_convert_to_lib_name(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
372377
endif()
378+
379+
if(CMAKE_GENERATOR MATCHES "Visual Studio"
380+
AND NOT OPENCV_SKIP_CUDA_CMAKE_SUPPRESS_REGENERATION
381+
)
382+
message(WARNING "CUDA with MSVS generator is detected. Disabling CMake re-run checks (CMAKE_SUPPRESS_REGENERATION=ON). You need to run CMake manually if updates are required.")
383+
set(CMAKE_SUPPRESS_REGENERATION ON)
384+
endif()
373385
endif()

modules/core/include/opencv2/core/cuda_types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ namespace cv
106106

107107
size_t step;
108108

109-
__CV_CUDA_HOST_DEVICE__ T* ptr(int y = 0) { return ( T*)( ( char*)DevPtr<T>::data + y * step); }
110-
__CV_CUDA_HOST_DEVICE__ const T* ptr(int y = 0) const { return (const T*)( (const char*)DevPtr<T>::data + y * step); }
109+
__CV_CUDA_HOST_DEVICE__ T* ptr(int y = 0) { return ( T*)( ( char*)(((DevPtr<T>*)this)->data) + y * step); }
110+
__CV_CUDA_HOST_DEVICE__ const T* ptr(int y = 0) const { return (const T*)( (const char*)(((DevPtr<T>*)this)->data) + y * step); }
111111

112112
__CV_CUDA_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; }
113113
__CV_CUDA_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; }

0 commit comments

Comments
 (0)