File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,18 @@ if(CUDA_FOUND)
106
106
if (OPENCV_CUDA_DETECTION_NVCC_FLAGS MATCHES "-ccbin" )
107
107
# already specified by user
108
108
elseif (CUDA_HOST_COMPILER AND EXISTS "${CUDA_HOST_COMPILER} " )
109
- LIST (APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${CUDA_HOST_COMPILER} " )
109
+ get_filename_component (c_compiler_realpath "${CMAKE_C_COMPILER} " REALPATH)
110
+ # C compiler doesn't work with --run option, forcing C++ compiler instead
111
+ if (CUDA_HOST_COMPILER STREQUAL c_compiler_realpath OR CUDA_HOST_COMPILER STREQUAL CMAKE_C_COMPILER)
112
+ if (DEFINED CMAKE_CXX_COMPILER)
113
+ get_filename_component (cxx_compiler_realpath "${CMAKE_CXX_COMPILER} " REALPATH)
114
+ LIST (APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${cxx_compiler_realpath} " )
115
+ else ()
116
+ message (STATUS "CUDA: CMAKE_CXX_COMPILER is not available. You may need to specify CUDA_HOST_COMPILER." )
117
+ endif ()
118
+ else ()
119
+ LIST (APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${CUDA_HOST_COMPILER} " )
120
+ endif ()
110
121
elseif (WIN32 AND CMAKE_LINKER) # Workaround for VS cl.exe not being in the env. path
111
122
get_filename_component (host_compiler_bindir ${CMAKE_LINKER} DIRECTORY )
112
123
LIST (APPEND OPENCV_CUDA_DETECTION_NVCC_FLAGS -ccbin "${host_compiler_bindir} " )
You can’t perform that action at this time.
0 commit comments