CMakeLists.txt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. ocv_install_example_src(opencl *.cpp *.hpp CMakeLists.txt)
  2. # cmake 3.1 needed for find_package(OpenCL)
  3. if(CMAKE_VERSION VERSION_LESS "3.1")
  4. message(STATUS "OpenCL samples require CMakes 3.1+")
  5. return()
  6. endif()
  7. set(OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS
  8. opencv_core
  9. opencv_imgproc
  10. opencv_video
  11. opencv_imgcodecs
  12. opencv_videoio
  13. opencv_highgui)
  14. ocv_check_dependencies(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
  15. if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
  16. return()
  17. endif()
  18. find_package(OpenCL 1.2 QUIET)
  19. if(NOT OpenCL_FOUND)
  20. message(STATUS "OpenCL samples are skipped: OpenCL SDK is required")
  21. return()
  22. endif()
  23. project(opencl_samples)
  24. ocv_include_modules_recurse(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
  25. ocv_include_directories(${OpenCL_INCLUDE_DIR})
  26. file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
  27. foreach(sample_filename ${all_samples})
  28. ocv_define_sample(tgt ${sample_filename} opencl)
  29. ocv_target_link_libraries(${tgt} PRIVATE
  30. ${OPENCV_LINKER_LIBS}
  31. ${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS}
  32. ${OpenCL_LIBRARY})
  33. endforeach()