detect_realsense.cmake 1.4 KB

12345678910111213141516171819202122232425262728
  1. # --- Intel librealsense ---
  2. if(NOT HAVE_LIBREALSENSE)
  3. find_package(realsense2 QUIET)
  4. if(realsense2_FOUND)
  5. set(HAVE_LIBREALSENSE TRUE)
  6. set(LIBREALSENSE_VERSION "${realsense2_VERSION}") # informational
  7. ocv_add_external_target(librealsense "" "${realsense2_LIBRARY}" "HAVE_LIBREALSENSE")
  8. endif()
  9. endif()
  10. if(NOT HAVE_LIBREALSENSE)
  11. find_path(LIBREALSENSE_INCLUDE_DIR "librealsense2/rs.hpp"
  12. PATHS "${LIBREALSENSE_INCLUDE}" ENV LIBREALSENSE_INCLUDE)
  13. find_library(LIBREALSENSE_LIBRARIES "realsense2"
  14. PATHS "${LIBREALSENSE_LIB}" ENV LIBREALSENSE_LIB)
  15. if(LIBREALSENSE_INCLUDE_DIR AND LIBREALSENSE_LIBRARIES)
  16. set(HAVE_LIBREALSENSE TRUE)
  17. file(STRINGS "${LIBREALSENSE_INCLUDE_DIR}/librealsense2/rs.h" ver_strings REGEX "#define +RS2_API_(MAJOR|MINOR|PATCH|BUILD)_VERSION.*")
  18. string(REGEX REPLACE ".*RS2_API_MAJOR_VERSION[^0-9]+([0-9]+).*" "\\1" ver_major "${ver_strings}")
  19. string(REGEX REPLACE ".*RS2_API_MINOR_VERSION[^0-9]+([0-9]+).*" "\\1" ver_minor "${ver_strings}")
  20. string(REGEX REPLACE ".*RS2_API_PATCH_VERSION[^0-9]+([0-9]+).*" "\\1" ver_patch "${ver_strings}")
  21. set(LIBREALSENSE_VERSION "${ver_major}.${ver_minor}.${ver_patch}") # informational
  22. ocv_add_external_target(librealsense "${LIBREALSENSE_INCLUDE_DIR}" "${LIBREALSENSE_LIBRARIES}" "HAVE_LIBREALSENSE")
  23. endif()
  24. endif()
  25. set(HAVE_LIBREALSENSE ${HAVE_LIBREALSENSE} PARENT_SCOPE)