forked from rpavlik/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindOpenHaptics.cmake
481 lines (431 loc) · 9.73 KB
/
FindOpenHaptics.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# - try to find OpenHaptics libraries
#
# Cache Variables: (probably not for direct use in your scripts)
# HDAPI_INCLUDE_DIR
# HDAPI_LIBRARY
# HDAPI_LIBRARY_RELEASE
# HDAPI_LIBRARY_DEBUG
# HDAPI_HDU_INCLUDE_DIR
# HDAPI_HDU_LIBRARY
# HDAPI_HDU_LIBRARY_RELEASE
# HDAPI_HDU_LIBRARY_DEBUG
# HLAPI_INCLUDE_DIR
# HLAPI_LIBRARY
# HLAPI_LIBRARY_RELEASE
# HLAPI_LIBRARY_DEBUG
# HLAPI_HLU_INCLUDE_DIR
# HLAPI_HLU_LIBRARY
# HLAPI_HLU_LIBRARY_RELEASE
# HLAPI_HLU_LIBRARY_DEBUG
#
# Non-cache variables you might use in your CMakeLists.txt:
# OPENHAPTICS_FOUND
# HDAPI_INCLUDE_DIRS
# HDAPI_LIBRARIES
# HDAPI_HDU_INCLUDE_DIRS
# HDAPI_HDU_LIBRARIES
# HLAPI_INCLUDE_DIRS
# HLAPI_LIBRARIES
# HLAPI_HLU_INCLUDE_DIRS
# HLAPI_HLU_LIBRARIES
# OPENHAPTICS_LIBRARIES - includes HD, HDU, HL, HLU
# OPENHAPTICS_RUNTIME_LIBRARY_DIRS
# OPENHAPTICS_ENVIRONMENT
# OPENHAPTICS_LIBRARY_DIRS
# OPENHAPTICS_INCLUDE_DIRS
#
# Requires these CMake modules:
# CleanDirectoryList
# CleanLibraryList
# ListCombinations
# ProgramFilesGlob
# SelectLibraryConfigurations (included with CMake >=2.8.0)
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
# CMake 2.6.3 (uses "unset")
#
# Original Author:
# 2009-2012 Ryan Pavlik <[email protected]> <[email protected]>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# 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)
cmake_minimum_required(VERSION 2.6.3)
set(OPENHAPTICS_ROOT_DIR
"${OPENHAPTICS_ROOT_DIR}"
CACHE
PATH
"Path to search for OpenHaptics")
option(OPENHAPTICS_NESTED_TARGETS
"Whether we should compile HDU and HLU, if needed, as a part of the solution"
ON)
mark_as_advanced(OPENHAPTICS_NESTED_TARGETS)
###
# Configure OpenHaptics
###
include(SelectLibraryConfigurations)
include(ListCombinations)
include(CleanDirectoryList)
include(CleanLibraryList)
include(ProgramFilesGlob)
set(_nest_targets)
set(_incsearchdirs)
set(_libsearchdirs)
set(OPENHAPTICS_ENVIRONMENT)
set(OPENHAPTICS_RUNTIME_LIBRARY_DIRS)
set(_dirs)
if(NOT "$ENV{OH_SDK_BASE}" STREQUAL "")
list(APPEND _dirs "$ENV{OH_SDK_BASE}")
elseif(NOT "$ENV{3DTOUCH_BASE}" STREQUAL "")
list(APPEND _dirs "$ENV{3DTOUCH_BASE}")
endif()
if(WIN32)
program_files_fallback_glob(_pfdirs "/Sensable/3DTouch*/")
foreach(_OH_DEFAULT_LOCATION "C:/OpenHaptics/3.1" "C:/OpenHaptics/Academic/3.1")
if(EXISTS "${_OH_DEFAULT_LOCATION}")
list(APPEND _dirs "${_OH_DEFAULT_LOCATION}")
endif()
endforeach()
set(_dirs "${_dirs};${_pfdirs}")
if(MSVC60)
set(_vc "vc6")
elseif(MSVC70 OR MSVC71)
set(_vc "vc7")
elseif(MSVC80)
set(_vc "vc8")
endif()
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
# 64-bit
list_combinations(_libsearch
PREFIXES
"${OPENHAPTICS_ROOT_DIR}"
${_dirs}
SUFFIXES
"/lib/x64")
list_combinations(_libsearch2
PREFIXES
"${OPENHAPTICS_ROOT_DIR}"
${_dirs}
SUFFIXES
"/utilities/lib/x64")
else()
# 32-bit
list_combinations(_libsearch
PREFIXES
"${OPENHAPTICS_ROOT_DIR}"
${_dirs}
SUFFIXES
"/lib"
"/lib/win32")
list_combinations(_libsearch2
PREFIXES
"${OPENHAPTICS_ROOT_DIR}"
${_dirs}
SUFFIXES
"/utilities/lib/Win32"
"/utilities/lib"
"/utilities/lib/${_vc}")
endif()
clean_directory_list(_libsearchdirs ${_libsearch} ${_libsearch2})
endif()
list_combinations(_incsearch
PREFIXES
"${OPENHAPTICS_ROOT_DIR}"
${_dirs}
SUFFIXES
"/include")
list_combinations(_incsearch2
PREFIXES
"${OPENHAPTICS_ROOT_DIR}"
${_dirs}
SUFFIXES
"/utilities/include")
clean_directory_list(_incsearchdirs ${_incsearch} ${_incsearch2})
set(_deps_check)
set(_deps_libs)
###
# HDAPI: HD
###
if(UNIX)
find_library(HDAPI_PHANToMIO_LIBRARY
NAMES
PHANToMIO
HINTS
${_libsearchdirs})
mark_as_advanced(HDAPI_PHANToMIO_LIBRARY)
list(APPEND _deps_check HDAPI_PHANToMIO_LIBRARY)
list(APPEND _deps_libs "${HDAPI_PHANToMIO_LIBRARY}")
endif()
find_path(HDAPI_INCLUDE_DIR
NAMES
HD/hd.h
HINTS
${_incsearchdirs})
find_library(HDAPI_LIBRARY_RELEASE
NAMES
HD
PATH_SUFFIXES
ReleaseAcademicEdition
Release
HINTS
${_libsearchdirs})
find_library(HDAPI_LIBRARY_DEBUG
NAMES
HD
PATH_SUFFIXES
DebugAcademicEdition
Debug
HINTS
${_libsearchdirs})
select_library_configurations(HDAPI)
###
# HDAPI: HDU
###
find_path(HDAPI_HDU_INCLUDE_DIR
NAMES
HDU/hdu.h
HINTS
${_incsearchdirs})
find_library(HDAPI_HDU_LIBRARY_RELEASE
NAMES
HDU
PATH_SUFFIXES
ReleaseAcademicEdition
Release
HINTS
${_libsearchdirs})
find_library(HDAPI_HDU_LIBRARY_DEBUG
NAMES
HDU
PATH_SUFFIXES
DebugAcademicEdition
Debug
HINTS
${_libsearchdirs})
# Fallback
find_library(HDAPI_HDU_LIBRARY_DEBUG
NAMES
HDUD
PATH_SUFFIXES
DebugAcademicEdition
Debug
HINTS
${_libsearchdirs})
select_library_configurations(HDAPI_HDU)
if(OPENHAPTICS_NESTED_TARGETS OR NOT HDAPI_HDU_LIBRARY)
if(HDAPI_HDU_SOURCE_DIR AND NOT EXISTS "${HDAPI_HDU_SOURCE_DIR}/hdu.cpp")
unset(HDAPI_HDU_SOURCE_DIR)
endif()
find_path(HDAPI_HDU_SOURCE_DIR
NAMES
hdu.cpp
PATH_SUFFIXES
src
src/HDU
src/HDU/src
libsrc/HDU
HINTS
"${HDAPI_HDU_INCLUDE_DIR}/.."
"${HDAPI_HDU_INCLUDE_DIR}/../share/3DTouch")
list(APPEND _deps_check HDAPI_HDU_SOURCE_DIR)
if(HDAPI_HDU_SOURCE_DIR)
mark_as_advanced(HDAPI_HDU_SOURCE_DIR)
set(_nest_targets YES)
set(HDAPI_HDU_LIBRARY
"openhaptics_hdu_nested_target"
CACHE
STRING
"We will build the OpenHaptics HDU lib."
FORCE)
set(HDAPI_HDU_LIBRARIES ${HDAPI_HDU_LIBRARY})
endif()
endif()
###
# HLAPI: HL
###
find_path(HLAPI_INCLUDE_DIR
NAMES
HL/hl.h
HINTS
${_incsearchdirs})
find_library(HLAPI_LIBRARY_RELEASE
NAMES
HL
PATH_SUFFIXES
ReleaseAcademicEdition
Release
HINTS
${_libsearchdirs})
find_library(HLAPI_LIBRARY_DEBUG
NAMES
HL
PATH_SUFFIXES
DebugAcademicEdition
Debug
HINTS
${_libsearchdirs})
select_library_configurations(HLAPI)
###
# HLAPI: HLU
###
find_path(HLAPI_HLU_INCLUDE_DIR
NAMES
HLU/hlu.h
HINTS
${_incsearchdirs})
find_library(HLAPI_HLU_LIBRARY_RELEASE
NAMES
HLU
PATH_SUFFIXES
ReleaseAcademicEdition
Release
HINTS
${_libsearchdirs})
find_library(HLAPI_HLU_LIBRARY_DEBUG
NAMES
HLU
PATH_SUFFIXES
DebugAcademicEdition
Debug
HINTS
${_libsearchdirs})
# fallback
find_library(HLAPI_HLU_LIBRARY_DEBUG
NAMES
HLUD
PATH_SUFFIXES
DebugAcademicEdition
Debug
HINTS
${_libsearchdirs})
select_library_configurations(HLAPI_HLU)
if(OPENHAPTICS_NESTED_TARGETS OR NOT HLAPI_HLU_LIBRARY)
if(HLAPI_HLU_SOURCE_DIR AND NOT EXISTS "${HLAPI_HLU_SOURCE_DIR}/hlu.cpp")
unset(HLAPI_HLU_SOURCE_DIR)
endif()
find_path(HLAPI_HLU_SOURCE_DIR
NAMES
hlu.cpp
PATH_SUFFIXES
src
src/HLU
src/HLU/src
libsrc/HLU
HINTS
"${HLAPI_HLU_INCLUDE_DIR}/.."
"${HLAPI_HLU_INCLUDE_DIR}/../share/3DTouch")
list(APPEND _deps_check HLAPI_HLU_SOURCE_DIR)
if(HLAPI_HLU_SOURCE_DIR)
mark_as_advanced(HLAPI_HLU_SOURCE_DIR)
set(_nest_targets YES)
set(HLAPI_HLU_LIBRARY
"openhaptics_hlu_nested_target"
CACHE
STRING
"We will build the OpenHaptics HLU lib."
FORCE)
set(HLAPI_HLU_LIBRARIES ${HLAPI_HLU_LIBRARY})
endif()
endif()
###
# Add dependencies: Libraries
###
set(HDAPI_LIBRARIES "${HDAPI_LIBRARY}" ${_deps_libs})
if(HDAPI_HDU_LIBRARIES AND HDAPI_LIBRARIES)
list(APPEND HDAPI_HDU_LIBRARIES ${HDAPI_LIBRARIES})
else()
set(HDAPI_HDU_LIBRARIES)
endif()
if(HLAPI_LIBRARY AND HDAPI_LIBRARIES)
set(HLAPI_LIBRARIES ${HLAPI_LIBRARY} ${HDAPI_LIBRARIES})
else()
set(HLAPI_LIBRARIES)
endif()
if(HLAPI_HLU_LIBRARIES AND HLAPI_LIBRARIES)
list(APPEND HLAPI_HLU_LIBRARIES ${HLAPI_LIBRARIES})
else()
set(HLAPI_HLU_LIBRARIES)
endif()
###
# Add dependencies: Include dirs
###
if(HDAPI_INCLUDE_DIR)
set(HDAPI_INCLUDE_DIRS ${HDAPI_INCLUDE_DIR})
if(HDAPI_HDU_INCLUDE_DIR)
set(HDAPI_HDU_INCLUDE_DIRS
${HDAPI_INCLUDE_DIRS}
${HDAPI_HDU_INCLUDE_DIR})
if(HDAPI_HDU_INCLUDE_DIR)
set(HLAPI_INCLUDE_DIRS ${HDAPI_INCLUDE_DIRS} ${HLAPI_INCLUDE_DIR})
if(HLAPI_HLU_INCLUDE_DIR)
set(HLAPI_HLU_INCLUDE_DIRS
${HLAPI_INCLUDE_DIRS}
${HLAPI_HLU_INCLUDE_DIR})
endif()
endif()
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(OpenHaptics
DEFAULT_MSG
HDAPI_LIBRARY
HDAPI_INCLUDE_DIR
HDAPI_HDU_INCLUDE_DIR
HDAPI_HDU_LIBRARY
HLAPI_INCLUDE_DIR
HLAPI_LIBRARY
HLAPI_HLU_INCLUDE_DIR
HLAPI_HLU_LIBRARY
${_deps_check})
if(OPENHAPTICS_FOUND)
# Recurse into the nested targets subdirectory if needed
if(_nest_targets)
get_filename_component(_moddir "${CMAKE_CURRENT_LIST_FILE}" PATH)
add_subdirectory("${_moddir}/nested_targets/OpenHaptics" "OpenHapticsNestedTargets")
endif()
set(OPENHAPTICS_LIBRARIES
${HDAPI_LIBRARY}
${HDAPI_HDU_LIBRARY}
${HLAPI_LIBRARY}
${HLAPI_HLU_LIBRARY})
set(OPENHAPTICS_LIBRARY_DIRS)
foreach(_lib
${_deps_check}
HDAPI_LIBRARY_RELEASE
HDAPI_LIBRARY_DEBUG
HDAPI_HDU_LIBRARY_RELEASE
HDAPI_HDU_LIBRARY_DEBUG
HLAPI_LIBRARY_RELEASE
HLAPI_LIBRARY_DEBUG
HLAPI_HLU_LIBRARY_RELEASE
HLAPI_HLU_LIBRARY_DEBUG)
get_filename_component(_libdir ${${_lib}} PATH)
list(APPEND OPENHAPTICS_LIBRARY_DIRS ${_libdir})
endforeach()
set(OPENHAPTICS_INCLUDE_DIRS
${HLAPI_HLU_INCLUDE_DIRS}
${HDAPI_HDU_INCLUDE_DIRS})
clean_directory_list(OPENHAPTICS_LIBRARY_DIRS)
clean_directory_list(OPENHAPTICS_INCLUDE_DIRS)
list(APPEND
OPENHAPTICS_RUNTIME_LIBRARY_DIRS
${OPENHAPTICS_LIBRARY_DIRS})
clean_library_list(OPENHAPTICS_LIBRARIES)
mark_as_advanced(OPENHAPTICS_ROOT_DIR)
endif()
mark_as_advanced(HDAPI_INCLUDE_DIR
HDAPI_LIBRARY_RELEASE
HDAPI_LIBRARY_DEBUG
HDAPI_HDU_INCLUDE_DIR
HDAPI_HDU_LIBRARY_RELEASE
HDAPI_HDU_LIBRARY_DEBUG
HLAPI_INCLUDE_DIR
HLAPI_LIBRARY_RELEASE
HLAPI_LIBRARY_DEBUG
HLAPI_HLU_INCLUDE_DIR
HLAPI_HLU_LIBRARY_RELEASE
HLAPI_HLU_LIBRARY_DEBUG)