CMakeLists.txt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. set(test_deps opencv_cudev opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui opencv_ts ${OPENCV_MODULE_opencv_ts_DEPS})
  2. ocv_check_dependencies(${test_deps})
  3. if(OCV_DEPENDENCIES_FOUND)
  4. set(the_target "opencv_test_${name}")
  5. ocv_module_include_directories("${test_deps}" "${the_module}")
  6. file(GLOB test_srcs "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.cu")
  7. file(GLOB test_hdrs "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
  8. source_group("Src" FILES ${test_srcs})
  9. source_group("Include" FILES ${test_hdrs})
  10. set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
  11. ocv_cuda_filter_options()
  12. if(CUDA_VERSION VERSION_LESS "11.0")
  13. ocv_update(OPENCV_CUDA_OPTIONS_opencv_test_cudev "-std=c++11")
  14. else()
  15. ocv_update(OPENCV_CUDA_OPTIONS_opencv_test_cudev "-std=c++14")
  16. ocv_warnings_disable(CMAKE_CXX_FLAGS -Wdeprecated-declarations)
  17. endif()
  18. CUDA_ADD_EXECUTABLE(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} OPTIONS ${OPENCV_CUDA_OPTIONS_opencv_test_cudev})
  19. ocv_target_link_libraries(${the_target} PRIVATE
  20. ${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES}
  21. )
  22. add_dependencies(opencv_tests ${the_target})
  23. set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL}")
  24. set_source_files_properties(${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch}
  25. PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};AccuracyTest")
  26. # Additional target properties
  27. set_target_properties(${the_target} PROPERTIES
  28. DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
  29. RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
  30. )
  31. if(ENABLE_SOLUTION_FOLDERS)
  32. set_target_properties(${the_target} PROPERTIES FOLDER "tests accuracy")
  33. endif()
  34. ocv_add_test_from_target("${the_target}" "Accuracy" "${the_target}")
  35. if(INSTALL_TESTS)
  36. install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
  37. endif()
  38. endif()