OpenCVDetectHalide.cmake 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. cmake_minimum_required(VERSION ${MIN_VER_CMAKE})
  2. if(" ${HALIDE_ROOT_DIR}" STREQUAL " ")
  3. unset(HALIDE_ROOT_DIR CACHE)
  4. endif()
  5. ocv_check_environment_variables(HALIDE_ROOT_DIR)
  6. set(HALIDE_ROOT_DIR "${HALIDE_ROOT_DIR}" CACHE PATH "Halide root directory")
  7. if(NOT HAVE_HALIDE)
  8. find_package(Halide QUIET) # Try CMake-based config files
  9. if(Halide_FOUND)
  10. if(TARGET Halide::Halide) # modern Halide scripts defines imported target
  11. set(HALIDE_INCLUDE_DIRS "")
  12. set(HALIDE_LIBRARIES "Halide::Halide")
  13. set(HAVE_HALIDE TRUE)
  14. else()
  15. # using HALIDE_INCLUDE_DIRS / Halide_LIBRARIES
  16. set(HAVE_HALIDE TRUE)
  17. endif()
  18. endif()
  19. endif()
  20. if(NOT HAVE_HALIDE AND HALIDE_ROOT_DIR)
  21. # Try manual search
  22. find_library(HALIDE_LIBRARY
  23. NAMES Halide
  24. HINTS ${HALIDE_ROOT_DIR}/lib # Unix
  25. HINTS ${HALIDE_ROOT_DIR}/lib/Release # Win32
  26. )
  27. find_path(HALIDE_INCLUDE_DIR
  28. NAMES Halide.h HalideRuntime.h
  29. HINTS ${HALIDE_ROOT_DIR}/include
  30. )
  31. if(HALIDE_LIBRARY AND HALIDE_INCLUDE_DIR)
  32. # TODO try_compile
  33. set(HALIDE_INCLUDE_DIRS "${HALIDE_INCLUDE_DIR}")
  34. set(HALIDE_LIBRARIES "${HALIDE_LIBRARY}")
  35. set(HAVE_HALIDE TRUE)
  36. endif()
  37. endif()
  38. if(HAVE_HALIDE)
  39. if(HALIDE_INCLUDE_DIRS)
  40. include_directories(${HALIDE_INCLUDE_DIRS})
  41. endif()
  42. list(APPEND OPENCV_LINKER_LIBS ${HALIDE_LIBRARIES})
  43. endif()