1set(test_deps opencv_cudev opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui opencv_ts ${OPENCV_MODULE_opencv_ts_DEPS})
2
3ocv_check_dependencies(${test_deps})
4
5if(OCV_DEPENDENCIES_FOUND)
6  set(the_target "opencv_test_${name}")
7
8  ocv_module_include_directories("${test_deps}" "${the_module}")
9
10  file(GLOB test_srcs "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.cu")
11  file(GLOB test_hdrs "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
12  source_group("Src" FILES ${test_srcs})
13  source_group("Include" FILES ${test_hdrs})
14  set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
15
16  foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
17    # we remove /EHa as it generates warnings under windows
18    string(REPLACE "/EHa" "" ${var} "${${var}}")
19
20    # we remove -ggdb3 flag as it leads to preprocessor errors when compiling CUDA files (CUDA 4.1)
21    string(REPLACE "-ggdb3" "" ${var} "${${var}}")
22
23    # we remove -Wsign-promo as it generates warnings under linux
24    string(REPLACE "-Wsign-promo" "" ${var} "${${var}}")
25
26    # we remove -fvisibility-inlines-hidden because it's used for C++ compiler
27    # but NVCC uses C compiler by default
28    string(REPLACE "-fvisibility-inlines-hidden" "" ${var} "${${var}}")
29  endforeach()
30
31  CUDA_ADD_EXECUTABLE(${the_target} ${OPENCV_TEST_${the_module}_SOURCES})
32  ocv_target_link_libraries(${the_target} ${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES})
33  add_dependencies(opencv_tests ${the_target})
34
35  # Additional target properties
36  set_target_properties(${the_target} PROPERTIES
37    DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
38    RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
39  )
40
41  if(ENABLE_SOLUTION_FOLDERS)
42    set_target_properties(${the_target} PROPERTIES FOLDER "tests accuracy")
43  endif()
44
45  enable_testing()
46  get_target_property(LOC ${the_target} LOCATION)
47  add_test(${the_target} "${LOC}")
48endif()
49