-
Notifications
You must be signed in to change notification settings - Fork 213
/
FindGlove5DT.cmake
206 lines (176 loc) · 4.33 KB
/
FindGlove5DT.cmake
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# - try to find Glove5DT libraries
#
# Cache Variables: (probably not for direct use in your scripts)
# GLOVE5DT_INCLUDE_DIR
# GLOVE5DT_LIBRARY
# GLOVE5DT_LIBRARY_RELEASE
# GLOVE5DT_LIBRARY_DEBUG
# GLOVE5DT_RUNTIME_LIBRARY_RELEASE
# GLOVE5DT_RUNTIME_LIBRARY_DEBUG
#
# Non-cache variables you might use in your CMakeLists.txt:
# GLOVE5DT_FOUND
# GLOVE5DT_INCLUDE_DIRS
# GLOVE5DT_LIBRARIES
# GLOVE5DT_RUNTIME_LIBRARY_DIRS
#
# Requires these CMake modules:
# CleanDirectoryList
# CleanLibraryList
# ListCombinations
# ProgramFilesGlob
# SelectLibraryConfigurations (included with CMake >=2.8.0)
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2010 Rylie Pavlik <[email protected]>
# https://ryliepavlik.com/
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2009-2010, Iowa State University
#
# 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)
#
# SPDX-License-Identifier: BSL-1.0
set(GLOVE5DT_ROOT_DIR
"${GLOVE5DT_ROOT_DIR}"
CACHE
PATH
"Path to search for Glove5DT SDK")
###
# Configure Glove5DT
###
include(SelectLibraryConfigurations)
include(ListCombinations)
include(CleanDirectoryList)
include(ProgramFilesGlob)
if(WIN32)
# Data Glove 5 and 16 use these directories for includes, lib, and runtime
program_files_glob(_dirs516 "/5DT/*/Driver")
set(_dirs516
"${GLOVE5DT_ROOT_DIR}/Driver"
"${GLOVE5DT_ROOT_DIR}"
${_dirs516})
# Data Glove Ultra uses this directory as the base for a dll, inc, and lib directory
program_files_glob(_dirsultra "/5DT/*/SDK")
list_combinations(_libsearchultra
PREFIXES
"${GLOVE5DT_ROOT_DIR}"
"${_dirsultra}"
SUFFIXES
"/lib")
list_combinations(_incsearchultra
PREFIXES
"${GLOVE5DT_ROOT_DIR}"
"${_dirsultra}"
SUFFIXES
"/inc")
list_combinations(_dllsearchultra
PREFIXES
"${GLOVE5DT_ROOT_DIR}"
"${_dirsultra}"
SUFFIXES
"/dll")
endif()
###
# First search for the Ultra (2.0) SDK
###
find_path(GLOVE5DT_INCLUDE_DIR
NAMES
fglove.h
HINTS
${_incsearchultra}
${GLOVE5DT_ROOT_DIR})
find_library(GLOVE5DT_LIBRARY_RELEASE
NAMES
fglove
HINTS
${_libsearchultra}
${GLOVE5DT_ROOT_DIR})
find_library(GLOVE5DT_LIBRARY_DEBUG
NAMES
fgloved
HINTS
${_libsearchultra}
${GLOVE5DT_ROOT_DIR})
select_library_configurations(GLOVE5DT)
# As a post condition, either both LIBRARY_RELEASE and LIBRARY_DEBUG are set, or
# neither is.
###
# Ultra (2.0) SDK Runtime Libraries
###
if(WIN32)
find_file(GLOVE5DT_RUNTIME_LIBRARY_RELEASE
NAMES
fglove.dll
HINTS
${_dllsearchultra})
find_file(GLOVE5DT_RUNTIME_LIBRARY_DEBUG
NAMES
fgloved.dll
HINTS
${_dllsearchultra})
else()
# the library is the runtime library
set(GLOVE5DT_RUNTIME_LIBRARY_RELEASE "${GLOVE5DT_LIBRARY_RELEASE}")
set(GLOVE5DT_RUNTIME_LIBRARY_DEBUG "${GLOVE5DT_LIBRARY_DEBUG}")
endif()
select_library_configurations(GLOVE5DT_RUNTIME)
###
# Fallback to the 5/16 (1.0) SDK
###
find_path(GLOVE5DT_INCLUDE_DIR
NAMES
fglove.h
HINTS
${_dirs516})
find_library(GLOVE5DT_LIBRARY_RELEASE
NAMES
fglove
HINTS
${_dirs516})
select_library_configurations(GLOVE5DT)
###
# 5/16 (1.0) SDK Runtime Libraries
###
if(WIN32)
find_file(GLOVE5DT_RUNTIME_LIBRARY_RELEASE
NAMES
fglove.dll
HINTS
${_dirs516})
else()
# the library is the runtime library
set(GLOVE5DT_RUNTIME_LIBRARY_RELEASE "${GLOVE5DT_LIBRARY_RELEASE}")
endif()
select_library_configurations(GLOVE5DT_RUNTIME)
# 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(Glove5DT
DEFAULT_MSG
GLOVE5DT_LIBRARY_RELEASE
GLOVE5DT_RUNTIME_LIBRARY_RELEASE
GLOVE5DT_INCLUDE_DIR)
if(GLOVE5DT_FOUND)
set(GLOVE5DT_RUNTIME_LIBRARY_DIRS)
foreach(_lib
GLOVE5DT_RUNTIME_LIBRARY_RELEASE
GLOVE5DT_RUNTIME_LIBRARY_DEBUG)
if(${_lib})
get_filename_component(_libdir ${${_lib}} PATH)
list(APPEND GLOVE5DT_RUNTIME_LIBRARY_DIRS "${_libdir}")
endif()
endforeach()
clean_directory_list(GLOVE5DT_RUNTIME_LIBRARY_DIRS)
set(GLOVE5DT_INCLUDE_DIRS "${GLOVE5DT_INCLUDE_DIR}")
set(GLOVE5DT_LIBRARIES ${GLOVE5DT_LIBRARY})
mark_as_advanced(GLOVE5DT_ROOT_DIR)
endif()
mark_as_advanced(GLOVE5DT_INCLUDE_DIR
GLOVE5DT_LIBRARY_RELEASE
GLOVE5DT_LIBRARY_DEBUG
GLOVE5DT_RUNTIME_LIBRARY_RELEASE
GLOVE5DT_RUNTIME_LIBRARY_DEBUG)