FindVRPN.cmake 3.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
# Comments by Alexis:
# VRPN has a FindVRPN, Findquatlib, FindLibusb1, FindHIDAPI in cmake folder:
# - FindLibusb1 finds the include but not the lib. Updating it from usb-1.0 to
#   libusb-1.0 fixes the issue.
# - Findquatlib does not find lib or include. Updating lib from quat.lib/libquat.a
#   to quat and quatd resolved the library. No way to resolve the include since
#   QUATLIB_ROOT_DIR is not defined in this scope.
# - FindHIDAPI does not find lib or include. Using submodules/hidapi.cmake
#   instead would help finding the good variables but requires more includes and
#   to be in VRPN scope.
# - FindVRPN uses Findquatlib and FindLibusb1 therefore fails. It also does not
#   look for HIDAPI.

14
15
16
17
18
19
20
21
22
#-----------------------------------------------------------------------------
# Find path
#-----------------------------------------------------------------------------
find_path(VRPN_INCLUDE_DIR
  NAMES
    vrpn_Configure.h
    )
mark_as_advanced(VRPN_INCLUDE_DIR)

23
24
25
26
27
28
find_path(LIBNIFALCON_INCLUDE_DIR
  NAMES
    falcon/core/FalconDevice.h
  )
mark_as_advanced(LIBNIFALCON_INCLUDE_DIR)

29
30
31
find_path(LIBUSB1_INCLUDE_DIR
  NAMES
    libusb.h
32
    libusb-1.0/libusb.h
33
34
  )
mark_as_advanced(LIBUSB1_INCLUDE_DIR)
35
36
37
38

#-----------------------------------------------------------------------------
# Set up include dirs
#-----------------------------------------------------------------------------
39
40
41
42
list(APPEND VRPN_INCLUDE_DIRS
  ${VRPN_INCLUDE_DIR}
  ${VRPN_INCLUDE_DIR}/quat
  ${VRPN_INCLUDE_DIR}/atmellib
43
  ${LIBNIFALCON_INCLUDE_DIR}
44
45
  ${LIBUSB1_INCLUDE_DIR}
  )
46
47
48
49
50
51
52
message(STATUS "VRPN_INCLUDE_DIRS : ${VRPN_INCLUDE_DIRS}")

#-----------------------------------------------------------------------------
# Find library
#-----------------------------------------------------------------------------
find_library(VRPN_LIBRARY
  NAMES
53
54
    vrpnserver
    vrpnserverd
55
56
57
58
59
60
61
62
63
64
  )
mark_as_advanced(VRPN_LIBRARY)

find_library(QUAT_LIBRARY
  NAMES
    quat
    quatd
  )
mark_as_advanced(QUAT_LIBRARY)

65
66
67
68
69
70
71
find_library(LIBNIFALCON_LIBRARY
  NAMES
    libnifalcon
    nifalcon
  )
mark_as_advanced(LIBNIFALCON_LIBRARY)

72
73
74
75
#works on windows, but sounds like it is needed only on linux, check vrpn/submodules/hidapi.cmake
find_library(LIBUSB1_LIBRARY
  NAMES
    libusb-1.0
76
    usb-1.0
77
78
79
80
81
82
83
84
85
86
87
88
  )
mark_as_advanced(LIBUSB1_LIBRARY)

#windows only, libusb1 sounds enough on unix, check vrpn/submodules/hidapi.cmake
if(WIN32)
  find_library(HIDAPI_LIBRARY
    NAMES
      setupapi
    )
  mark_as_advanced(HIDAPI_LIBRARY)
endif()

89
90
91
92
93
94
#-----------------------------------------------------------------------------
# Set up libraries
#-----------------------------------------------------------------------------
set(VRPN_LIBRARIES
  ${VRPN_LIBRARY}
  ${QUAT_LIBRARY}
95
  ${LIBNIFALCON_LIBRARY}
96
  ${LIBUSB1_LIBRARY}
97
  ${HIDAPI_LIBRARY}
98
  )
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
message(STATUS "VRPN_LIBRARIES : ${VRPN_LIBRARIES}")

#-----------------------------------------------------------------------------
# Find package
#-----------------------------------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VRPN
  REQUIRED_VARS
    VRPN_INCLUDE_DIRS
    VRPN_LIBRARIES)

#-----------------------------------------------------------------------------
# If missing target, create it
#-----------------------------------------------------------------------------

if(VRPN_FOUND AND NOT TARGET VRPN)
  add_library(VRPN INTERFACE IMPORTED)
  set_target_properties(VRPN PROPERTIES
    INTERFACE_LINK_LIBRARIES "${VRPN_LIBRARIES}"
    INTERFACE_INCLUDE_DIRECTORIES "${VRPN_INCLUDE_DIRS}"
  )
endif()