diff --git a/modules/cudaarithm/CMakeLists.txt b/modules/cudaarithm/CMakeLists.txt index fa9c9194163..34863ce2b07 100644 --- a/modules/cudaarithm/CMakeLists.txt +++ b/modules/cudaarithm/CMakeLists.txt @@ -7,38 +7,41 @@ set(the_description "CUDA-accelerated Operations on Matrices") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow) set(extra_dependencies "") -set(optional_dependencies "") if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) if(UNIX AND NOT BUILD_SHARED_LIBS AND CUDA_VERSION_STRING VERSION_GREATER_EQUAL 9.2 AND CUDA_VERSION_STRING VERSION_LESS 13.0 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.23) set(CUDA_FFT_LIB_EXT "_static_nocallback") endif() - list(APPEND extra_dependencies CUDA::cudart_static CUDA::nppial${CUDA_LIB_EXT} CUDA::nppc${CUDA_LIB_EXT} CUDA::nppitc${CUDA_LIB_EXT} CUDA::nppig${CUDA_LIB_EXT} CUDA::nppist${CUDA_LIB_EXT} CUDA::nppidei${CUDA_LIB_EXT}) + list(APPEND extra_dependencies CUDA::cudart${CUDA_LIB_EXT} CUDA::nppial${CUDA_LIB_EXT} CUDA::nppc${CUDA_LIB_EXT} CUDA::nppitc${CUDA_LIB_EXT} CUDA::nppig${CUDA_LIB_EXT} CUDA::nppist${CUDA_LIB_EXT} CUDA::nppidei${CUDA_LIB_EXT}) if(HAVE_CUBLAS) - list(APPEND optional_dependencies CUDA::cublas${CUDA_LIB_EXT}) + list(APPEND extra_dependencies CUDA::cublas${CUDA_LIB_EXT}) if(NOT CUDA_VERSION VERSION_LESS 10.1) - list(APPEND optional_dependencies CUDA::cublasLt${CUDA_LIB_EXT}) + list(APPEND extra_dependencies CUDA::cublasLt${CUDA_LIB_EXT}) endif() endif() if(HAVE_CUFFT) # static version requires seperable compilation which is incompatible with opencv's current library structure # the cufft_static_nocallback variant does not requires seperable compilation. callbacks are currently not used. - list(APPEND optional_dependencies CUDA::cufft${CUDA_FFT_LIB_EXT}) + list(APPEND extra_dependencies CUDA::cufft${CUDA_FFT_LIB_EXT}) endif() else() if(HAVE_CUBLAS) - list(APPEND optional_dependencies ${CUDA_cublas_LIBRARY}) + list(APPEND extra_dependencies ${CUDA_cublas_LIBRARY}) endif() if(HAVE_CUFFT) - list(APPEND optional_dependencies ${CUDA_cufft_LIBRARY}) + list(APPEND extra_dependencies ${CUDA_cufft_LIBRARY}) endif() endif() -ocv_add_module(cudaarithm opencv_core ${extra_dependencies} OPTIONAL opencv_cudev ${optional_dependencies} WRAP python) +ocv_add_module(cudaarithm opencv_core OPTIONAL opencv_cudev WRAP python) ocv_module_include_directories() ocv_glob_module_sources() -ocv_create_module() +ocv_create_module(${extra_dependencies}) -ocv_add_accuracy_tests(DEPENDS_ON opencv_imgproc) +set(test_libs "") +if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) + list(APPEND test_libs CUDA::cudart${CUDA_LIB_EXT}) +endif() +ocv_add_accuracy_tests(${test_libs} DEPENDS_ON opencv_imgproc) ocv_add_perf_tests(DEPENDS_ON opencv_imgproc) diff --git a/modules/cudabgsegm/CMakeLists.txt b/modules/cudabgsegm/CMakeLists.txt index 1d2ef64d154..d833241d29f 100644 --- a/modules/cudabgsegm/CMakeLists.txt +++ b/modules/cudabgsegm/CMakeLists.txt @@ -5,7 +5,9 @@ endif() set(the_description "CUDA-accelerated Background Segmentation") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow) + +ocv_define_module(cudabgsegm opencv_video WRAP python) + if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - ocv_module_include_directories(${CUDAToolkit_INCLUDE_DIRS}) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT}) endif() -ocv_define_module(cudabgsegm opencv_video WRAP python) diff --git a/modules/cudacodec/CMakeLists.txt b/modules/cudacodec/CMakeLists.txt index a2dd450423f..eeda57149f8 100644 --- a/modules/cudacodec/CMakeLists.txt +++ b/modules/cudacodec/CMakeLists.txt @@ -32,7 +32,7 @@ endif() if(HAVE_NVCUVID OR HAVE_NVCUVENC) if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - list(APPEND extra_libs CUDA::cuda_driver) + list(APPEND extra_libs CUDA::cuda_driver CUDA::cudart${CUDA_LIB_EXT}) else() list(APPEND extra_libs ${CUDA_CUDA_LIBRARY}) endif() diff --git a/modules/cudafeatures2d/CMakeLists.txt b/modules/cudafeatures2d/CMakeLists.txt index 2b6023c0b66..68f4e2d61a8 100644 --- a/modules/cudafeatures2d/CMakeLists.txt +++ b/modules/cudafeatures2d/CMakeLists.txt @@ -5,7 +5,17 @@ endif() set(the_description "CUDA-accelerated Feature Detection and Description") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4100 /wd4324 /wd4512 /wd4515 -Wundef -Wmissing-declarations -Wshadow -Wunused-parameter -Wshadow) + +ocv_add_module(cudafeatures2d opencv_features2d opencv_cudafilters opencv_cudawarping WRAP python) + +ocv_module_include_directories() +ocv_glob_module_sources() + +set(extra_libs "") if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - ocv_module_include_directories(${CUDAToolkit_INCLUDE_DIRS}) + list(APPEND extra_libs CUDA::cudart${CUDA_LIB_EXT}) endif() -ocv_define_module(cudafeatures2d opencv_features2d opencv_cudafilters opencv_cudawarping WRAP python) +ocv_create_module(${extra_libs}) + +ocv_add_accuracy_tests(${extra_libs}) +ocv_add_perf_tests(${extra_libs}) diff --git a/modules/cudafilters/CMakeLists.txt b/modules/cudafilters/CMakeLists.txt index 75ff3b26718..c0eeb920e39 100644 --- a/modules/cudafilters/CMakeLists.txt +++ b/modules/cudafilters/CMakeLists.txt @@ -5,8 +5,21 @@ endif() set(the_description "CUDA-accelerated Image Filtering") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow) -set(extra_libs "") + +ocv_add_module(cudafilters opencv_imgproc opencv_cudaarithm WRAP python) + +ocv_module_include_directories() +ocv_glob_module_sources() + +set(build_libs "") +if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) + list(APPEND build_libs CUDA::cudart${CUDA_LIB_EXT} CUDA::nppif${CUDA_LIB_EXT} CUDA::nppim${CUDA_LIB_EXT}) +endif() +ocv_create_module(${build_libs}) + +set(test_libs "") if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - set(extra_libs CUDA::nppif${CUDA_LIB_EXT} CUDA::nppim${CUDA_LIB_EXT}) + list(APPEND test_libs CUDA::cudart${CUDA_LIB_EXT}) endif() -ocv_define_module(cudafilters opencv_imgproc opencv_cudaarithm ${extra_libs} WRAP python) +ocv_add_accuracy_tests(${test_libs}) +ocv_add_perf_tests() diff --git a/modules/cudaimgproc/CMakeLists.txt b/modules/cudaimgproc/CMakeLists.txt index de818f6a8b3..e70abca13e4 100644 --- a/modules/cudaimgproc/CMakeLists.txt +++ b/modules/cudaimgproc/CMakeLists.txt @@ -5,8 +5,9 @@ endif() set(the_description "CUDA-accelerated Image Processing") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4100 /wd4324 /wd4512 /wd4515 -Wundef -Wmissing-declarations -Wshadow -Wunused-parameter) -set(extra_libs "") + +ocv_define_module(cudaimgproc opencv_imgproc OPTIONAL opencv_cudev opencv_cudaarithm opencv_cudafilters WRAP python) + if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - set(extra_libs CUDA::nppial${CUDA_LIB_EXT} CUDA::nppist${CUDA_LIB_EXT} CUDA::nppicc${CUDA_LIB_EXT} CUDA::nppidei${CUDA_LIB_EXT}) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT} CUDA::nppial${CUDA_LIB_EXT} CUDA::nppist${CUDA_LIB_EXT} CUDA::nppicc${CUDA_LIB_EXT} CUDA::nppidei${CUDA_LIB_EXT}) endif() -ocv_define_module(cudaimgproc opencv_imgproc ${extra_libs} OPTIONAL opencv_cudev opencv_cudaarithm opencv_cudafilters WRAP python) diff --git a/modules/cudalegacy/CMakeLists.txt b/modules/cudalegacy/CMakeLists.txt index f3ebfeafde7..ba3f73510dc 100644 --- a/modules/cudalegacy/CMakeLists.txt +++ b/modules/cudalegacy/CMakeLists.txt @@ -5,8 +5,17 @@ endif() set(the_description "CUDA-accelerated Computer Vision (legacy)") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4130 /wd4324 /wd4512 /wd4310 -Wundef -Wmissing-declarations -Wuninitialized -Wshadow -Wdeprecated-declarations -Wstrict-aliasing -Wtautological-compare) + +ocv_add_module(cudalegacy opencv_core opencv_video OPTIONAL opencv_objdetect opencv_imgproc opencv_calib3d opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc) + +ocv_module_include_directories() +ocv_glob_module_sources() + +set(extra_libs "") if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - ocv_module_include_directories(${CUDAToolkit_INCLUDE_DIRS}) + list(APPEND extra_libs CUDA::cudart${CUDA_LIB_EXT}) endif() -ocv_define_module(cudalegacy opencv_core opencv_video - OPTIONAL opencv_objdetect opencv_imgproc opencv_calib3d opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc) +ocv_create_module(${extra_libs}) + +ocv_add_accuracy_tests(${extra_libs}) +ocv_add_perf_tests(${extra_libs}) diff --git a/modules/cudaobjdetect/CMakeLists.txt b/modules/cudaobjdetect/CMakeLists.txt index a3f565ff0ab..8329f84a5a5 100644 --- a/modules/cudaobjdetect/CMakeLists.txt +++ b/modules/cudaobjdetect/CMakeLists.txt @@ -7,3 +7,7 @@ set(the_description "CUDA-accelerated Object Detection") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow -Wstrict-aliasing) ocv_define_module(cudaobjdetect opencv_objdetect opencv_cudaarithm opencv_cudawarping OPTIONAL opencv_cudalegacy WRAP python) + +if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT}) +endif() diff --git a/modules/cudaoptflow/CMakeLists.txt b/modules/cudaoptflow/CMakeLists.txt index d6ae902637d..b3af2a0bc8b 100644 --- a/modules/cudaoptflow/CMakeLists.txt +++ b/modules/cudaoptflow/CMakeLists.txt @@ -8,6 +8,10 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-d ocv_define_module(cudaoptflow opencv_video opencv_optflow opencv_cudaarithm opencv_cudawarping opencv_cudaimgproc OPTIONAL opencv_cudalegacy WRAP python) +if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT}) +endif() + if(NOT CUDA_VERSION VERSION_LESS "10.0") set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_COMMIT "edb50da3cf849840d680249aa6dbef248ebce2ca") set(NVIDIA_OPTICAL_FLOW_2_0_HEADERS_MD5 "a73cd48b18dcc0cc8933b30796074191") diff --git a/modules/cudastereo/CMakeLists.txt b/modules/cudastereo/CMakeLists.txt index d129536e903..631e70aad19 100644 --- a/modules/cudastereo/CMakeLists.txt +++ b/modules/cudastereo/CMakeLists.txt @@ -5,7 +5,9 @@ endif() set(the_description "CUDA-accelerated Stereo Correspondence") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow) + +ocv_define_module(cudastereo opencv_calib3d OPTIONAL opencv_cudev WRAP python) + if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - ocv_module_include_directories(${CUDAToolkit_INCLUDE_DIRS}) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT}) endif() -ocv_define_module(cudastereo opencv_calib3d OPTIONAL opencv_cudev WRAP python) diff --git a/modules/cudawarping/CMakeLists.txt b/modules/cudawarping/CMakeLists.txt index 67b4a1d6a62..403121f659e 100644 --- a/modules/cudawarping/CMakeLists.txt +++ b/modules/cudawarping/CMakeLists.txt @@ -5,8 +5,22 @@ endif() set(the_description "CUDA-accelerated Image Warping") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow) -set(extra_libs "") + +set(build_libs "") +if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) + list(APPEND build_libs CUDA::cudart${CUDA_LIB_EXT} CUDA::nppial${CUDA_LIB_EXT} CUDA::nppig${CUDA_LIB_EXT}) +endif() + +ocv_add_module(cudawarping opencv_core opencv_imgproc OPTIONAL opencv_cudev WRAP python) + +ocv_module_include_directories() +ocv_glob_module_sources() + +ocv_create_module(${build_libs}) + +set(test_libs "") if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE) - set(extra_libs CUDA::nppial${CUDA_LIB_EXT} CUDA::nppig${CUDA_LIB_EXT}) + list(APPEND test_libs CUDA::cudart${CUDA_LIB_EXT}) endif() -ocv_define_module(cudawarping opencv_core opencv_imgproc ${extra_libs} OPTIONAL opencv_cudev WRAP python) +ocv_add_accuracy_tests(${test_libs}) +ocv_add_perf_tests() diff --git a/modules/superres/CMakeLists.txt b/modules/superres/CMakeLists.txt index 2979ef0fb87..e5f455a3b83 100644 --- a/modules/superres/CMakeLists.txt +++ b/modules/superres/CMakeLists.txt @@ -9,3 +9,7 @@ endif() ocv_define_module(superres opencv_imgproc opencv_video opencv_optflow OPTIONAL opencv_videoio opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc opencv_cudaoptflow opencv_cudacodec WRAP python) + +if(HAVE_CUDA AND ENABLE_CUDA_FIRST_CLASS_LANGUAGE AND HAVE_opencv_cudaarithm AND HAVE_opencv_cudawarping AND HAVE_opencv_cudafilters) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT}) +endif() diff --git a/modules/superres/src/precomp.hpp b/modules/superres/src/precomp.hpp index 9f12c248d6c..92370068799 100644 --- a/modules/superres/src/precomp.hpp +++ b/modules/superres/src/precomp.hpp @@ -54,9 +54,12 @@ #include "opencv2/imgproc.hpp" #include "opencv2/video/tracking.hpp" #include "opencv2/core/private.hpp" - -#include "opencv2/core/private.cuda.hpp" #include "opencv2/core/ocl.hpp" +#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_CUDAARITHM) || !defined(HAVE_OPENCV_CUDAWARPING) || !defined(HAVE_OPENCV_CUDAFILTERS) +#include "opencv2/core/private/cuda_stubs.hpp" +#else +#include "opencv2/core/private.cuda.hpp" +#endif #ifdef HAVE_OPENCV_CUDAARITHM # include "opencv2/cudaarithm.hpp" diff --git a/modules/videostab/CMakeLists.txt b/modules/videostab/CMakeLists.txt index c31fcfceb5f..def66625d0f 100644 --- a/modules/videostab/CMakeLists.txt +++ b/modules/videostab/CMakeLists.txt @@ -10,3 +10,7 @@ endif() ocv_define_module(videostab opencv_imgproc opencv_features2d opencv_video opencv_photo opencv_calib3d OPTIONAL opencv_cudawarping opencv_cudaoptflow opencv_videoio WRAP python) + +if(HAVE_CUDA AND ENABLE_CUDA_FIRST_CLASS_LANGUAGE AND ((HAVE_opencv_cudaimgproc AND HAVE_opencv_cudaoptflow) OR HAVE_opencv_cudawarping)) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT}) +endif() diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index eb42d6954d6..58363c911b7 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -47,7 +47,13 @@ #include "opencv2/opencv_modules.hpp" #include "clp.hpp" +#if defined(HAVE_OPENCV_CUDAIMGPROC) && defined(HAVE_OPENCV_CUDAOPTFLOW) +#if !defined HAVE_CUDA || defined(CUDA_DISABLER) +#include "opencv2/core/private/cuda_stubs.hpp" +#else #include "opencv2/core/private.cuda.hpp" +#endif +#endif #if defined(HAVE_OPENCV_CUDAIMGPROC) && defined(HAVE_OPENCV_CUDAOPTFLOW) #if !defined HAVE_CUDA || defined(CUDA_DISABLER) diff --git a/modules/videostab/src/wobble_suppression.cpp b/modules/videostab/src/wobble_suppression.cpp index 079c511b5d8..961ca5f4a29 100644 --- a/modules/videostab/src/wobble_suppression.cpp +++ b/modules/videostab/src/wobble_suppression.cpp @@ -44,10 +44,13 @@ #include "opencv2/videostab/wobble_suppression.hpp" #include "opencv2/videostab/ring_buffer.hpp" -#include "opencv2/core/private.cuda.hpp" - #ifdef HAVE_OPENCV_CUDAWARPING -# include "opencv2/cudawarping.hpp" +#include "opencv2/cudawarping.hpp" +#if !defined HAVE_CUDA || defined(CUDA_DISABLER) +#include "opencv2/core/private/cuda_stubs.hpp" +#else +#include "opencv2/core/private.cuda.hpp" +#endif #endif #if defined(HAVE_OPENCV_CUDAWARPING) diff --git a/modules/xfeatures2d/CMakeLists.txt b/modules/xfeatures2d/CMakeLists.txt index f30d2ed8c21..bafd4c59bac 100644 --- a/modules/xfeatures2d/CMakeLists.txt +++ b/modules/xfeatures2d/CMakeLists.txt @@ -5,6 +5,10 @@ if(HAVE_CUDA) endif() ocv_define_module(xfeatures2d opencv_core opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_shape opencv_ml opencv_cudaarithm WRAP python java objc) +if(HAVE_CUDA AND ENABLE_CUDA_FIRST_CLASS_LANGUAGE AND HAVE_opencv_cudaarithm) + ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT}) +endif() + if(NOT OPENCV_SKIP_FEATURES2D_DOWNLOADING) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_vgg.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_boostdesc.cmake) diff --git a/modules/xfeatures2d/src/precomp.hpp b/modules/xfeatures2d/src/precomp.hpp index 376999600bc..88c295eaa98 100644 --- a/modules/xfeatures2d/src/precomp.hpp +++ b/modules/xfeatures2d/src/precomp.hpp @@ -50,7 +50,11 @@ #include "opencv2/core/utility.hpp" #include "opencv2/core/private.hpp" +#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_CUDAARITHM) +#include "opencv2/core/private/cuda_stubs.hpp" +#else #include "opencv2/core/private.cuda.hpp" +#endif #include "opencv2/core/ocl.hpp" #include "opencv2/opencv_modules.hpp"