pineapple-src/externals/vcpkg/ports/opencv2/0005-fix-cuda.patch
2022-07-23 03:01:36 +02:00

141 lines
5.0 KiB
Diff
Executable File

--- a/cmake/OpenCVDetectCUDA.cmake
+++ b/cmake/OpenCVDetectCUDA.cmake
@@ -51,7 +51,6 @@ if(CUDA_FOUND)
message(STATUS "CUDA detected: " ${CUDA_VERSION})
- set(_generations "Fermi" "Kepler")
if(NOT CMAKE_CROSSCOMPILING)
list(APPEND _generations "Auto")
endif()
@@ -69,48 +68,8 @@ if(CUDA_FOUND)
unset(CUDA_ARCH_PTX CACHE)
endif()
- set(__cuda_arch_ptx "")
- if(CUDA_GENERATION STREQUAL "Fermi")
- set(__cuda_arch_bin "2.0 2.1(2.0)")
- elseif(CUDA_GENERATION STREQUAL "Kepler")
- if(${CUDA_VERSION} VERSION_LESS "5.0")
- set(__cuda_arch_bin "3.0")
- else()
- set(__cuda_arch_bin "3.0 3.5")
- endif()
- elseif(CUDA_GENERATION STREQUAL "Auto")
- execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run"
- WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
- RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
- ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(NOT _nvcc_res EQUAL 0)
- message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.")
- else()
- set(__cuda_arch_bin "${_nvcc_out}")
- string(REPLACE "2.1" "2.1(2.0)" __cuda_arch_bin "${__cuda_arch_bin}")
- endif()
- endif()
-
- if(NOT DEFINED __cuda_arch_bin)
- if(ANDROID)
- if (ARM)
- set(__cuda_arch_bin "3.2")
- set(__cuda_arch_ptx "")
- elseif(AARCH64)
- set(__cuda_arch_bin "5.3")
- set(__cuda_arch_ptx "")
- endif()
- else()
- if(${CUDA_VERSION} VERSION_LESS "5.0")
- set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0")
- elseif(${CUDA_VERSION} VERSION_GREATER "6.5")
- set(__cuda_arch_bin "2.0 2.1(2.0) 3.0 3.5")
- else()
- set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0 3.5")
- endif()
- set(__cuda_arch_ptx "3.0")
- endif()
- endif()
+ set(__cuda_arch_ptx "5.0")
+ set(__cuda_arch_bin "5.0")
set(CUDA_ARCH_BIN ${__cuda_arch_bin} CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
set(CUDA_ARCH_PTX ${__cuda_arch_ptx} CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
@@ -229,18 +188,40 @@ else()
endif()
if(HAVE_CUDA)
+ set(CUDA_LIBS_PATH "")
+ foreach(p ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
+ get_filename_component(_tmp ${p} PATH)
+ list(APPEND CUDA_LIBS_PATH ${_tmp})
+ endforeach()
+
+ if(HAVE_CUBLAS)
+ foreach(p ${CUDA_cublas_LIBRARY})
+ get_filename_component(_tmp ${p} PATH)
+ list(APPEND CUDA_LIBS_PATH ${_tmp})
+ endforeach()
+ endif()
+
+ if(HAVE_CUFFT)
+ foreach(p ${CUDA_cufft_LIBRARY})
+ get_filename_component(_tmp ${p} PATH)
+ list(APPEND CUDA_LIBS_PATH ${_tmp})
+ endforeach()
+ endif()
+
+ list(REMOVE_DUPLICATES CUDA_LIBS_PATH)
+ link_directories(${CUDA_LIBS_PATH})
+
set(CUDA_LIBRARIES_ABS ${CUDA_LIBRARIES})
- ocv_create_imported_targets(CUDA_LIBRARIES ${CUDA_LIBRARIES})
+ ocv_convert_to_lib_name(CUDA_LIBRARIES ${CUDA_LIBRARIES})
set(CUDA_npp_LIBRARY_ABS ${CUDA_npp_LIBRARY})
- ocv_create_imported_targets(CUDA_npp_LIBRARY ${CUDA_npp_LIBRARY})
-
+ ocv_convert_to_lib_name(CUDA_npp_LIBRARY ${CUDA_npp_LIBRARY})
if(HAVE_CUBLAS)
set(CUDA_cublas_LIBRARY_ABS ${CUDA_cublas_LIBRARY})
- ocv_create_imported_targets(CUDA_cublas_LIBRARY ${CUDA_cublas_LIBRARY})
+ ocv_convert_to_lib_name(CUDA_cublas_LIBRARY ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUFFT)
set(CUDA_cufft_LIBRARY_ABS ${CUDA_cufft_LIBRARY})
- ocv_create_imported_targets(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
+ ocv_convert_to_lib_name(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
endif()
endif()
--- a/cmake/templates/OpenCVConfig.cmake.in
+++ b/cmake/templates/OpenCVConfig.cmake.in
@@ -256,7 +256,7 @@ if(OpenCV_CUDA_VERSION)
set(OpenCV_CUDA_LIBS_ABSPATH ${CUDA_LIBRARIES})
- if(${CUDA_VERSION} VERSION_LESS "5.5")
+ if(CUDA_VERSION VERSION_LESS "5.5")
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_npp_LIBRARY})
else()
find_cuda_helper_libs(nppc)
@@ -281,14 +281,16 @@ if(OpenCV_CUDA_VERSION)
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvenc_LIBRARIES})
endif()
+ set(OpenCV_CUDA_LIBS_RELPATH "")
foreach(l ${OpenCV_CUDA_LIBS_ABSPATH})
- get_filename_component(_tmp "${l}" NAME_WE)
- string(REGEX REPLACE "^lib" "" _tmp "${_tmp}")
- if(NOT TARGET "opencv_dep_${_tmp}") # protect against repeated inclusions
- add_library("opencv_dep_${_tmp}" UNKNOWN IMPORTED)
- set_target_properties("opencv_dep_${_tmp}" PROPERTIES IMPORTED_LOCATION "${l}")
+ get_filename_component(_tmp ${l} PATH)
+ if(NOT ${_tmp} MATCHES "-Wl.*")
+ list(APPEND OpenCV_CUDA_LIBS_RELPATH ${_tmp})
endif()
endforeach()
+
+ list(REMOVE_DUPLICATES OpenCV_CUDA_LIBS_RELPATH)
+ link_directories(${OpenCV_CUDA_LIBS_RELPATH})
endif()
# ==============================================================