From 6da7c50fb53edd291d709a06aad0b46c1311aac2 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 19 Dec 2013 10:27:38 +0400 Subject: [PATCH] Make dependency from CUDA explicit to prevent from fake dependedcies from CUDA runtime. --- CMakeLists.txt | 12 ------------ cmake/OpenCVModule.cmake | 3 --- modules/core/CMakeLists.txt | 6 +++++- modules/gpu/CMakeLists.txt | 3 ++- modules/superres/CMakeLists.txt | 2 +- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d49ab84..56c176453 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -459,18 +459,6 @@ if(WITH_OPENCL) include(cmake/OpenCVDetectOpenCL.cmake) endif() -# ---------------------------------------------------------------------------- -# Add CUDA libraries (needed for apps/tools, samples) -# ---------------------------------------------------------------------------- -if(HAVE_CUDA) - set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) - if(HAVE_CUBLAS) - set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cublas_LIBRARY}) - endif() - if(HAVE_CUFFT) - set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY}) - endif() -endif() # ---------------------------------------------------------------------------- # Solution folders: # ---------------------------------------------------------------------------- diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index c923aba41..d7e7c4a1c 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -537,9 +537,6 @@ macro(ocv_create_module) target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS}) target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS}) target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN}) - if (HAVE_CUDA) - target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) - endif() endif() add_dependencies(opencv_modules ${the_module}) diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index a7a997f67..07fa08925 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -33,7 +33,11 @@ macro(ocv_glob_module_sources_no_cuda) SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_hdrs}) endmacro() -ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES}) +if (DYNAMIC_CUDA_SUPPORT) + ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES}) +else() + ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) +endif() ocv_module_include_directories(${ZLIB_INCLUDE_DIR}) if(HAVE_WINRT) diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index a61659789..9171febc7 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -3,7 +3,8 @@ if(IOS) endif() set(the_description "GPU-accelerated Computer Vision") -ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_photo opencv_legacy) +ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_photo opencv_legacy + OPTIONAL ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY} ${CUDA_cublas_LIBRARY} ${CUDA_cufft_LIBRARY}) ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda") diff --git a/modules/superres/CMakeLists.txt b/modules/superres/CMakeLists.txt index 44e9dc0f3..3da8dc2c6 100644 --- a/modules/superres/CMakeLists.txt +++ b/modules/superres/CMakeLists.txt @@ -4,4 +4,4 @@ endif() set(the_description "Super Resolution") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 -Wundef) -ocv_define_module(superres opencv_imgproc opencv_video OPTIONAL opencv_gpu opencv_highgui opencv_ocl) +ocv_define_module(superres opencv_imgproc opencv_video OPTIONAL opencv_gpu opencv_highgui opencv_ocl ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})