Merge commit 'c1d65c7f1f6836d4fe961c0a54ea11ff8fdfc62d' as 'cmake'

This commit is contained in:
Ryan Pavlik
2010-11-11 10:59:10 -06:00
177 changed files with 15885 additions and 0 deletions

486
cmake/FindOpenHaptics.cmake Normal file
View File

@@ -0,0 +1,486 @@
# - 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)