Merge pull request #3098 from jet47:fix-cuda-compilation
This commit is contained in:
@@ -188,6 +188,8 @@ if(CUDA_FOUND)
|
||||
# we remove -frtti because it's used for C++ compiler
|
||||
# but NVCC uses C compiler by default
|
||||
string(REPLACE "-frtti" "" ${var} "${${var}}")
|
||||
|
||||
string(REPLACE "-fvisibility-inlines-hidden" "" ${var} "${${var}}")
|
||||
endforeach()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
|
@@ -585,25 +585,16 @@ macro(ocv_glob_module_sources)
|
||||
ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail})
|
||||
|
||||
if (exclude_cuda EQUAL -1)
|
||||
set(lib_cuda_srcs "")
|
||||
set(lib_cuda_hdrs "")
|
||||
if(HAVE_CUDA AND exclude_cuda EQUAL -1)
|
||||
file(GLOB lib_cuda_srcs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.cu"
|
||||
)
|
||||
set(cuda_objs "")
|
||||
set(lib_cuda_hdrs "")
|
||||
if(HAVE_CUDA)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
file(GLOB lib_cuda_hdrs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.hpp"
|
||||
)
|
||||
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endif()
|
||||
else()
|
||||
set(cuda_objs "")
|
||||
set(lib_cuda_srcs "")
|
||||
set(lib_cuda_hdrs "")
|
||||
file(GLOB lib_cuda_hdrs
|
||||
"${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.hpp"
|
||||
)
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endif()
|
||||
|
||||
file(GLOB cl_kernels
|
||||
@@ -622,7 +613,7 @@ macro(ocv_glob_module_sources)
|
||||
endif()
|
||||
|
||||
ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
|
||||
SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
SOURCES ${lib_srcs} ${lib_int_hdrs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endmacro()
|
||||
|
||||
# creates OpenCV module in current folder
|
||||
|
@@ -94,7 +94,7 @@ function(ocv_target_include_directories target)
|
||||
list(APPEND __params "${dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
if(HAVE_CUDA OR CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories(${__params})
|
||||
else()
|
||||
if(TARGET ${target})
|
||||
@@ -748,6 +748,22 @@ function(ocv_add_executable target)
|
||||
endfunction()
|
||||
|
||||
function(ocv_add_library target)
|
||||
add_library(${target} ${ARGN})
|
||||
set(cuda_objs "")
|
||||
if(HAVE_CUDA)
|
||||
set(cuda_srcs "")
|
||||
|
||||
foreach(var ${ARGN})
|
||||
if(var MATCHES ".cu")
|
||||
list(APPEND cuda_srcs ${var})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(cuda_srcs)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(${target} ${ARGN} ${cuda_objs})
|
||||
_ocv_append_target_includes(${target})
|
||||
endfunction()
|
||||
endfunction()
|
||||
|
Reference in New Issue
Block a user