File: FindVRPN.cmake

package info (click to toggle)
freespace2 24.0.2%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 43,188 kB
  • sloc: cpp: 583,107; ansic: 21,729; python: 1,174; sh: 464; makefile: 248; xml: 181
file content (156 lines) | stat: -rw-r--r-- 3,545 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# - try to find VRPN library
#
# Cache Variables:
#  VRPN_LIBRARY
#  VRPN_SERVER_LIBRARY
#  VRPN_INCLUDE_DIR
#
# Non-cache variables you might use in your CMakeLists.txt:
#  VRPN_FOUND
#  VRPN_SERVER_LIBRARIES - server libraries
#  VRPN_LIBRARIES - client libraries
#  VRPN_CLIENT_DEFINITIONS - definitions if you only use the client library
#  VRPN_DEFINITIONS - Client-only definition if all we found was the client library.
#  VRPN_INCLUDE_DIRS
#
# VRPN_ROOT_DIR is searched preferentially for these files
#
# Requires these CMake modules:
#  FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2012 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

set(VRPN_ROOT_DIR
	"${VRPN_ROOT_DIR}"
	CACHE
	PATH
	"Root directory to search for VRPN")

if("${CMAKE_SIZEOF_VOID_P}" MATCHES "8")
	set(_libsuffixes lib64 lib)

	# 64-bit dir: only set on win64
	file(TO_CMAKE_PATH "$ENV{ProgramW6432}" _progfiles)
else()
	set(_libsuffixes lib)
	set(_PF86 "ProgramFiles(x86)")
	if(NOT "$ENV{${_PF86}}" STREQUAL "")
		# 32-bit dir: only set on win64
		file(TO_CMAKE_PATH "$ENV{${_PF86}}" _progfiles)
	else()
		# 32-bit dir on win32, useless to us on win64
		file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _progfiles)
	endif()
endif()

set(_vrpn_quiet)
if(VRPN_FIND_QUIETLY)
	set(_vrpn_quiet QUIET)
endif()

###
# Configure VRPN
###

find_path(VRPN_INCLUDE_DIR
	NAMES
	vrpn_Connection.h
	PATH_SUFFIXES
	include
	include/vrpn
	HINTS
	"${VRPN_ROOT_DIR}"
	PATHS
	"${_progfiles}/VRPN"
	C:/usr/local
	/usr/local)

find_library(VRPN_LIBRARY
	NAMES
	vrpn
	PATH_SUFFIXES
	${_libsuffixes}
	HINTS
	"${VRPN_ROOT_DIR}"
	PATHS
	"${_progfiles}/VRPN"
	C:/usr/local
	/usr/local)

find_library(VRPN_SERVER_LIBRARY
	NAMES
	vrpnserver
	PATH_SUFFIXES
	${_libsuffixes}
	HINTS
	"${VRPN_ROOT_DIR}"
	PATHS
	"${_progfiles}/VRPN"
	C:/usr/local
	/usr/local)

###
# Dependencies
###
set(_deps_libs)
set(_deps_includes)
set(_deps_check)

find_package(quatlib ${_vrpn_quiet})
list(APPEND _deps_libs ${QUATLIB_LIBRARIES})
list(APPEND _deps_includes ${QUATLIB_INCLUDE_DIRS})
list(APPEND _deps_check QUATLIB_FOUND)

if(NOT WIN32)
	find_package(Threads ${_vrpn_quiet})
	list(APPEND _deps_libs ${CMAKE_THREAD_LIBS_INIT})
	list(APPEND _deps_check CMAKE_HAVE_THREADS_LIBRARY)
endif()

if(WIN32)
	find_package(Libusb1 QUIET)
	if(LIBUSB1_FOUND)
		list(APPEND _deps_libs ${LIBUSB1_LIBRARIES})
		list(APPEND _deps_includes ${LIBUSB1_INCLUDE_DIRS})
	endif()
endif()


# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VRPN
	DEFAULT_MSG
	VRPN_LIBRARY
	VRPN_INCLUDE_DIR
	${_deps_check})

if(VRPN_FOUND)
	set(VRPN_INCLUDE_DIRS "${VRPN_INCLUDE_DIR}" ${_deps_includes})
	set(VRPN_LIBRARIES "${VRPN_LIBRARY}" ${_deps_libs})
	set(VRPN_SERVER_LIBRARIES "${VRPN_SERVER_LIBRARY}" ${_deps_libs})

	if(VRPN_LIBRARY)
		set(VRPN_CLIENT_DEFINITIONS -DVRPN_CLIENT_ONLY)
	else()
		unset(VRPN_CLIENT_DEFINITIONS)
	endif()

	if(VRPN_LIBRARY AND NOT VRPN_SERVER_LIBRARY)
		set(VRPN_DEFINITIONS -DVRPN_CLIENT_ONLY)
	else()
		unset(VRPN_DEFINITIONS)
	endif()

	mark_as_advanced(VRPN_ROOT_DIR)
endif()

mark_as_advanced(VRPN_LIBRARY VRPN_SERVER_LIBRARY VRPN_INCLUDE_DIR)