FindOpenVR.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Note that OpenVR lacks a useful install tree. This should work if
  2. # `OpenVR_ROOT` is set to the source directory of OpenVR.
  3. # TODO: fails for universal builds
  4. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  5. set(_openvr_bitness 64)
  6. else ()
  7. set(_openvr_bitness 32)
  8. endif ()
  9. set(_openvr_platform_base)
  10. if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  11. set(_openvr_platform_base osx)
  12. # SteamVR only supports 32-bit on OS X
  13. set(OpenVR_PLATFORM osx32)
  14. else ()
  15. if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  16. set(_openvr_platform_base linux)
  17. elseif (WIN32)
  18. set(_openvr_platform_base win)
  19. endif ()
  20. set(OpenVR_PLATFORM ${_openvr_platform_base}${_openvr_bitness})
  21. endif ()
  22. find_path(OpenVR_INCLUDE_DIR
  23. NAMES
  24. openvr_driver.h
  25. PATH_SUFFIXES
  26. headers
  27. public/headers
  28. steam
  29. public/steam
  30. DOC "OpenVR include directory")
  31. mark_as_advanced(OpenVR_INCLUDE_DIR)
  32. find_library(OpenVR_LIBRARY
  33. NAMES openvr_api
  34. PATH_SUFFIXES
  35. "${OpenVR_PLATFORM}"
  36. "bin/${OpenVR_PLATFORM}"
  37. DOC "OpenVR API library")
  38. mark_as_advanced(OpenVR_LIBRARY)
  39. include(FindPackageHandleStandardArgs)
  40. find_package_handle_standard_args(OpenVR
  41. REQUIRED_VARS OpenVR_LIBRARY OpenVR_INCLUDE_DIR)
  42. if (OpenVR_FOUND)
  43. set(OpenVR_INCLUDE_DIRS "${OpenVR_INCLUDE_DIR}")
  44. set(OpenVR_LIBRARIES "${OpenVR_LIBRARY}")
  45. if (NOT TARGET OpenVR::OpenVR)
  46. add_library(OpenVR::OpenVR UNKNOWN IMPORTED)
  47. set_target_properties(OpenVR::OpenVR PROPERTIES
  48. IMPORTED_LOCATION "${OpenVR_LIBRARY}"
  49. INTERFACE_INCLUDE_DIRECTORIES "${OpenVR_INCLUDE_DIR}")
  50. endif ()
  51. endif ()
  52. unset(_openvr_bitness)
  53. unset(_openvr_platform_base)