build: fix opencv_world with CUDA

This commit is contained in:
Alexander Alekhin 2016-01-14 16:59:33 +03:00
parent c3ad8af42a
commit c8ff7a4867
4 changed files with 9 additions and 19 deletions

View File

@ -253,7 +253,7 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
# OpenCV build options
# ===================================================
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS AND NOT CMAKE_CROSSCOMPILING AND NOT ((HAVE_CUDA OR WITH_CUDA) AND BUILD_opencv_world)) )
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CMAKE_COMPILER_IS_GNUCXX )

View File

@ -747,20 +747,9 @@ function(ocv_add_executable target)
endfunction()
function(ocv_add_library target)
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)
if(HAVE_CUDA AND ARGN MATCHES "\\.cu")
ocv_include_directories(${CUDA_INCLUDE_DIRS})
ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs})
endif()
ocv_cuda_compile(cuda_objs ${ARGN})
set(OPENCV_MODULE_${target}_CUDA_OBJECTS ${cuda_objs} CACHE INTERNAL "Compiled CUDA object files")
endif()
@ -771,9 +760,10 @@ function(ocv_add_library target)
AND NOT OPENCV_MODULE_${target}_CHILDREN
AND NOT OPENCV_MODULE_${target}_CLASS STREQUAL "BINDINGS"
AND NOT ${target} STREQUAL "opencv_ts"
AND (NOT BUILD_opencv_world OR NOT HAVE_CUDA)
)
set(sources ${ARGN})
ocv_list_filterout(sources "\\\\.(cl|inc)$")
ocv_list_filterout(sources "\\\\.(cl|inc|cu)$")
add_library(${target}_object OBJECT ${sources})
set_target_properties(${target}_object PROPERTIES
EXCLUDE_FROM_ALL True

View File

@ -17,6 +17,6 @@ ocv_set_module_sources(HEADERS ${lib_hdrs} SOURCES ${lib_srcs})
ocv_create_module()
if(BUILD_TESTS)
if(BUILD_TESTS AND NOT BUILD_opencv_world)
add_subdirectory(test)
endif()

View File

@ -20,13 +20,13 @@ if(NOT OPENCV_INITIAL_PASS)
foreach(m ${OPENCV_MODULES_BUILD})
if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
message(STATUS " module ${m}...")
set(CMAKE_CURRENT_SOURCE_DIR ${OPENCV_MODULE_${m}_LOCATION})
set(CMAKE_CURRENT_SOURCE_DIR "${OPENCV_MODULE_${m}_LOCATION}")
#add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" ${CMAKE_CURRENT_BINARY_DIR}/${m})
include_one_module(${m})
endif()
endforeach()
message(STATUS "Processing WORLD modules... DONE")
set(CMAKE_CURRENT_SOURCE_DIR OPENCV_MODULE_${opencv_world}_LOCATION)
set(CMAKE_CURRENT_SOURCE_DIR "${OPENCV_MODULE_opencv_world_LOCATION}")
endif()
ocv_add_module(world opencv_core)