vcpkg/ports/opencv2/0005-fix-cuda.patch
Stefano Sinigardi f6601ee2e4
[OpenCV] update to v4.5.4 and v3.4.16 (#20658)
* Make gtk4.4 build.

* Update baseline for gtk

* Fix vcpkg version.

* Fix vcpkg version.

* [gtk] Fix macos build.

* [gtk] Fix linux build.

* [gtk] Add patches.

* [gtk] Bump versions - again

* Fix macos patch.

* Bump versions.

* [OpenCV] update to v4.5.4 and v3.4.16

* fix patches

* [OpenCV] fix references

* fix patches

* update references

* add gstreamer support

* fix references

* fixes

* update references

* Install xdamage.

* Bump versions.

* [fontconfig] disable doc building which is failing on bare linux

* fix references

* [opencv] use qt6

* [opencv2] use newer approach to downstream dependency handling

* fix references

* Add merged patch from upstream.

* [gtk] Bump version.

* [OpenCV] restore using qt5

* [opencv] force qt5

* update references

* use a different strategy to find qt5 dependency for downstream projects

* fix references

* use a different strategy to find qt5 dependency for downstream projects also for opencv2

* fix references

* [opencv2] fix patches

* fix references

* Update ports/fontconfig/vcpkg.json

Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>

* fix references

* fix references, again

* add gtk to linux default features

* fix references

* [OpenCV2] fix cuda patch for newer cuda versions

* fix references

* [OpenCV2] add GTK feature

* fix references

* [opencv2] bump port version

* [opencv2] fix references

* Delete duplicate install of libxdamage-dev

* [fontconfig] bump version

* fix references

* [fontconfig] bump version

* fix references

* move vcpkg-ci-opencv to manifest

Co-authored-by: Berrysoft <Strawberry_Str@hotmail.com>
Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com>
Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
2021-12-01 19:11:01 -08:00

141 lines
5.0 KiB
Diff

--- 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()
# ==============================================================