Files
libwiiuse/FindOpenHaptics.cmake
Ryan Pavlik 6481cc3d75 Squashed 'cmake/' changes from 813d030..8647ab0
8647ab0 update help
8c434a7 have luatargets.cmake actually try building (parsing) the lua scripts
abbbe59 update rendered help
4226520 remove unnecessary whitespace
fce2353 fix some leftover juggler 2.2 bits in the juggler 3.0 finder
072dda4 fix libusb finder on windows
3bf666c be sure to find all needed boost libraries for juggler 3.0
3e0d529 handle windows names for juggler 3.0 libraries
6cb00f4 handle config types in dashboard scripts
449fe46 Improve vrpn/quatlib finders to find the default locations on Windows
450a051 improve launcher templates
e8e1aee Fix the gdb finder
099d79f Fix finding OSG in some cases
2d5319f Update help files
9567cf8 Improve glove5dt finder
73d4de3 Find git.cmd on windows
cef7140 Silly bug in simpler juggler finder
5706470 Improve juggler finder
2f6f3ef Fix gdb finder
ae37c1a Clean up juggler finding
9416490 Improve gdb finder
d30789e Merge changes from finding juggler 2.2 into 3.0
00d407e Don't force juggler into debug mode
6668496 No more nspr on windows
737b8e2 Fix boost finding in VPR 2.2
c530fa3 Don't need a separate cppdom module for juggler 30
c10441c Merge branch 'master' of https://github.com/bnewendorp/cmake-modules into bnewendorp-master
0485c6c Update rendered help
c4c1ea8 Improve formatting of copyright notice when rendered to html
58ba978 Add reference to help in the readme
2052efb Generate text too, and rename
e3a0f3f Add help files and aboutthesemodules dummy module
dab6182 GetGitRevisionDescription: Fix HEAD hash finding in case of a detached HEAD checkout
278658c Fix a wee bug in the gdb finder
f0ac2bc Launchers now check version of GDB before throwing options at it. Fixes --debugger option on Macs.
6e66227 find gdb
1cbceb8 rename luatargets to filecopytargets, and forward calls from the old name
0bdd129 add the upcoming boost 1.46
86cfbb4 make boost test targets succeed on macs with homebrew
c290bbe Merge boost fix from pre-2.8.4
cc24a0d Improve dcubed finder and use nested targets
69b25b4 Clean up parasolid nested target
f467bb0 Don't force juggler into debug mode
250c5f0 Find boost 1.45
b15faa5 Add HIDAPI and libusb1
7236f4f Add OptionRequires module
7032b46 Improvements to cutil
9f0e966 Tweak to boost test
c60a1ea Added Juggler 3.0 files

git-subtree-dir: cmake
git-subtree-split: 8647ab061587c8c0fd7343b77b3e3bd367da0180
2011-02-01 10:29:35 -06:00

487 lines
9.9 KiB
CMake

# - try to find OpenHaptics libraries
#
# Cache Variables: (probably not for direct use in your scripts)
# HDAPI_INCLUDE_DIR
# HDAPI_LIBRARY
# HDAPI_HDU_INCLUDE_DIR
# HDAPI_HDU_LIBRARY
# HDAPI_HDU_LIBRARY_RELEASE
# HDAPI_HDU_LIBRARY_DEBUG
# HLAPI_INCLUDE_DIR
# HLAPI_LIBRARY
# 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-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# 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)
if(WIN32)
program_files_fallback_glob(_dirs "/Sensable/3DTouch*/")
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
NAMES
HD
HINTS
${_libsearchdirs})
###
# 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)
endif()
endif()
###
# HLAPI: HL
###
find_path(HLAPI_INCLUDE_DIR
NAMES
HL/hl.h
HINTS
${_incsearchdirs})
find_library(HLAPI_LIBRARY
NAMES
HL
HINTS
${_libsearchdirs})
###
# 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)
endif()
endif()
###
# Unix: check stdc++ version
###
if(UNIX
AND
HDAPI_LIBRARY
AND
HDAPI_PHANToMIO_LIBRARY
AND
HDAPI_INCLUDE_DIR)
find_file(OPENHAPTICS_LINKTEST_FILE
FindOpenHaptics.cpp
PATHS
${CMAKE_MODULE_PATH})
mark_as_advanced(OPENHAPTICS_LINKTEST_FILE)
try_compile(_result
${CMAKE_CURRENT_BINARY_DIR}/FindOpenHaptics
"${OPENHAPTICS_LINKTEST_FILE}"
CMAKE_FLAGS
"-DLINK_LIBRARIES=${HDAPI_LIBRARY}\;${HDAPI_PHANToMIO_LIBRARY} -DINCLUDE_DIRECTORIES=${HDAPI_INCLUDE_DIR}")
if(NOT _result)
set(OPENHAPTICS_LIBSTDCPP_DIR
"${OPENHAPTICS_LIBSTDCPP_DIR}"
CACHE
PATH
"The path to search for a libstdc++ with GLIBCXX_3.4.9 defined.")
if(OPENHAPTICS_LIBSTDCPP_DIR)
mark_as_advanced(OPENHAPTICS_LIBSTDCPP_DIR)
endif()
find_library(OPENHAPTICS_LIBSTDCPP_LIBRARY
libstdc++
PATHS
${OPENHAPTICS_LIBSTDCPP_DIR}
NO_DEFAULT_PATH)
if(OPENHAPTICS_LIBSTDCPP_LIBRARY)
mark_as_advanced(OPENHAPTICS_LIBSTDCPP_LIBRARY)
endif()
list(APPEND _deps_check OPENHAPTICS_LIBSTDCPP_LIBRARY)
list(APPEND _deps_libs "${OPENHAPTICS_LIBSTDCPP_LIBRARY}")
get_filename_component(_stdcppdir
"${OPENHAPTICS_LIBSTDCPP_LIBRARY}"
PATH)
list(APPEND
OPENHAPTICS_ENVIRONMENT
"LD_LIBRARY_PATH=${_stdcppdir}:$LD_LIBRARY_PATH")
list(APPEND OPENHAPTICS_RUNTIME_LIBRARY_DIRS "${_stdcppdir}")
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")
endif()
set(OPENHAPTICS_LIBRARIES
${HDAPI_LIBRARY}
${HDAPI_HDU_LIBRARY}
${HLAPI_LIBRARY}
${HLAPI_HLU_LIBRARY})
set(OPENHAPTICS_LIBRARY_DIRS)
foreach(_lib
${_deps_check}
HDAPI_LIBRARY
HDAPI_HDU_LIBRARY_RELEASE
HDAPI_HDU_LIBRARY_DEBUG
HLAPI_LIBRARY
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
HDAPI_HDU_INCLUDE_DIR
HDAPI_HDU_LIBRARY_RELEASE
HDAPI_HDU_LIBRARY_DEBUG
HLAPI_INCLUDE_DIR
HLAPI_LIBRARY
HLAPI_HLU_INCLUDE_DIR
HLAPI_HLU_LIBRARY_RELEASE
HLAPI_HLU_LIBRARY_DEBUG)