UseOpenCL.cmake 849 B

12345678910111213141516171819
  1. function(eth_apply TARGET REQUIRED)
  2. find_package (OpenCL)
  3. eth_show_dependency(OpenCL OpenCL)
  4. if (OpenCL_FOUND)
  5. target_include_directories(${TARGET} SYSTEM PUBLIC ${OpenCL_INCLUDE_DIRS})
  6. target_link_libraries(${TARGET} ${OpenCL_LIBRARIES})
  7. eth_copy_dlls(${TARGET} OpenCL_DLLS)
  8. # as per this comment: http://cmake.3232098.n2.nabble.com/Scope-of-find-package-inside-a-function-block-tp6821980p6822888.html
  9. # It seems that calling find_package() inside a cmake function will only set the found
  10. # and libs variables only for the local scope. We need to set it with a cached (global)
  11. # scope here in order to be visible outside the eth_use(${TARGET} ${REQUIRED} OpenCL) call
  12. set(OpenCL_FOUND 1 CACHE INTERNAL "")
  13. elseif (NOT ${REQUIRED} STREQUAL "OPTIONAL")
  14. message(FATAL_ERROR "OpenCL library not found")
  15. endif()
  16. endfunction()