detect_openni2.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # --- OpenNI2 ---
  2. if(NOT HAVE_OPENNI2)
  3. set(paths "${OPENNI2_DIR}")
  4. if(MSVC AND X86_64)
  5. list(APPEND paths ENV OPENNI2_INCLUDE64 ENV OPENNI2_LIB64 ENV OPENNI2_REDIST64)
  6. else()
  7. list(APPEND paths ENV OPENNI2_INCLUDE ENV OPENNI2_LIB ENV OPENNI2_REDIST)
  8. endif()
  9. # From SDK
  10. find_path(OPENNI2_INCLUDE "OpenNI.h"
  11. PATHS ${paths}
  12. PATH_SUFFIXES "Include"
  13. NO_DEFAULT_PATH)
  14. find_library(OPENNI2_LIBRARY "OpenNI2"
  15. PATHS ${paths}
  16. PATH_SUFFIXES "Redist" "Lib"
  17. NO_DEFAULT_PATH)
  18. if(OPENNI2_LIBRARY AND OPENNI2_INCLUDE)
  19. set(HAVE_OPENNI2 TRUE)
  20. set(OPENNI2_INCLUDE_DIRS "${OPENNI2_INCLUDE}")
  21. set(OPENNI2_LIBRARIES "${OPENNI2_LIBRARY}")
  22. endif()
  23. endif()
  24. if(NOT HAVE_OPENNI2)
  25. # From system
  26. find_path(OPENNI2_SYS_INCLUDE "OpenNI.h" PATH_SUFFIXES "openni2" "ni2")
  27. find_library(OPENNI2_SYS_LIBRARY "OpenNI2")
  28. if(OPENNI2_SYS_LIBRARY AND OPENNI2_SYS_INCLUDE)
  29. set(HAVE_OPENNI2 TRUE)
  30. set(OPENNI2_INCLUDE_DIRS "${OPENNI2_SYS_INCLUDE}")
  31. set(OPENNI2_LIBRARIES "${OPENNI2_SYS_LIBRARY}")
  32. endif()
  33. endif()
  34. if(HAVE_OPENNI2)
  35. file(STRINGS "${OPENNI2_INCLUDE_DIRS}/OniVersion.h" ver_strings REGEX "#define +ONI_VERSION_(MAJOR|MINOR|MAINTENANCE|BUILD).*")
  36. string(REGEX REPLACE ".*ONI_VERSION_MAJOR[^0-9]+([0-9]+).*" "\\1" ver_major "${ver_strings}")
  37. string(REGEX REPLACE ".*ONI_VERSION_MINOR[^0-9]+([0-9]+).*" "\\1" ver_minor "${ver_strings}")
  38. string(REGEX REPLACE ".*ONI_VERSION_MAINTENANCE[^0-9]+([0-9]+).*" "\\1" ver_maint "${ver_strings}")
  39. set(OPENNI2_VERSION "${ver_major}.${ver_minor}.${ver_maint}") # informational
  40. ocv_add_external_target(openni2 "${OPENNI2_INCLUDE_DIRS}" "${OPENNI2_LIBRARIES}" "HAVE_OPENNI2")
  41. endif()