diff --git a/.gitignore b/.gitignore index 4176dcc652..6e6b69cb66 100644 --- a/.gitignore +++ b/.gitignore @@ -28,31 +28,9 @@ DerivedData *.hmap -# ignore oculus -interface/external/oculus/* -!interface/external/oculus/readme.txt - -# Ignore Sixense -interface/external/sixense/* -!interface/external/sixense/readme.txt - -# Ignore Visage -interface/external/visage/* -!interface/external/visage/readme.txt -interface/resources/visage/* -!interface/resources/visage/tracker.cfg - -# Ignore Faceplus -interface/external/faceplus/* -!interface/external/faceplus/readme.txt - -# Ignore PrioVR -interface/external/priovr/* -!interface/external/priovr/readme.txt - -# Ignore RtMidi -interface/external/rtmidi/* -!interface/external/rtmidi/readme.txt +# ignore interface optional externals +interface/external/*/* +!interface/external/*/readme.txt # Ignore interfaceCache for Linux users interface/interfaceCache/ diff --git a/BUILD.md b/BUILD.md index 43c3ca7a09..159d9101fa 100644 --- a/BUILD.md +++ b/BUILD.md @@ -2,25 +2,25 @@ Dependencies === * [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2 * [Qt](http://qt-project.org/downloads) ~> 5.2.0 -* [zLib](http://www.zlib.net/) ~> 1.2.8 * [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.2 -* [qxmpp](https://github.com/qxmpp-project/qxmpp/) ~> 0.7.6 * [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g * IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability. #####Linux only * [freeglut](http://freeglut.sourceforge.net/) ~> 2.8.0 +* [zLib](http://www.zlib.net/) ~> 1.2.8 #####Windows only * [GLEW](http://glew.sourceforge.net/) ~> 1.10.0 * [freeglut MSVC](http://www.transmissionzero.co.uk/software/freeglut-devel/) ~> 2.8.1 +* [zLib](http://www.zlib.net/) ~> 1.2.8 CMake === Hifi uses CMake to generate build files and project files for your platform. ####Qt -In order for CMake to find the Qt5 find modules, you will need to set an ENV variable pointing to your CMake installation. +In order for CMake to find the Qt5 find modules, you will need to set an ENV variable pointing to your Qt installation. For example, a Qt5 5.2.0 installation to /usr/local/qt5 would require that QT_CMAKE_PREFIX_PATH be set with the following command. This can either be entered directly into your shell session before you build or in your shell profile (e.g.: ~/.bash_profile, ~/.bashrc, ~/.zshrc - this depends on your shell and environment). @@ -70,9 +70,8 @@ Should you choose not to install Qt5 via a package manager that handles dependen brew install cmake glm openssl brew install highfidelity/formulas/qt5 brew link qt5 --force - brew install highfidelity/formulas/qxmpp -We have a [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas) that you can use/tap to install some of the dependencies. In the code block above qt5 and qxmpp are installed from formulas in this repository. +We have a [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas) that you can use/tap to install some of the dependencies. In the code block above qt5 is installed from a formula in this repository. *Our [qt5 homebrew formula](https://raw.github.com/highfidelity/homebrew-formulas/master/qt5.rb) is for a patched version of Qt 5.2.0 stable that removes wireless network scanning that can reduce real-time audio performance. We recommended you use this formula to install Qt.* @@ -150,13 +149,10 @@ The recommended route for CMake to find the external dependencies is to place al -> glm -> glm -> glm.hpp - -> gnutls + -> openssl -> bin -> include -> lib - -> qxmpp - -> include - -> lib -> zlib -> include -> lib @@ -218,21 +214,6 @@ This package contains only headers, so there's nothing to add to the PATH. Be careful with glm. For the folder other libraries would normally call 'include', the folder containing the headers, glm opts to use 'glm'. You will have a glm folder nested inside the top-level glm folder. -#### qxmpp - -Download a source-code release from the [qxmpp GitHub page](https://github.com/qxmpp-project/qxmpp/releases). - -Start a Visual Studio Command Prompt. - - mkdir %HIFI_LIB_DIR%\build - tar xfz qxmpp-0.7.6.tar.gz -C %HIFI_LIB_DIR%\build - cd %HIFI_LIB_DIR%\build\qxmpp-0.7.6 - qmake PREFIX=%HIFI_LIB_DIR%\qxmpp # This creates "Makefile" - nmake - nmake install - -Add to the PATH: `%HIFI_LIB_DIR%\qxmpp\lib` - #### Build High Fidelity using Visual Studio Follow the same build steps from the CMake section, but pass a different generator to CMake. @@ -250,7 +231,16 @@ If you need to debug Interface, you can run interface from within Visual Studio * Set the "Working Directory" for the Interface debugging sessions to the Debug output directory so that your application can load resources. Do this: right click interface and click Properties, choose Debugging from Configuration Properties, set Working Directory to .\Debug * Now you can run and debug interface through Visual Studio +Optional Components +=== + +####QXmpp + +You can find QXmpp [here](https://github.com/qxmpp-project/qxmpp). The inclusion of the QXmpp enables text chat in the Interface client. + +OS X users who tap our [homebrew formulas repository](https://github.com/highfidelity/homebrew-formulas) can install QXmpp via homebrew - `brew install highfidelity/formulas/qxmpp`. + #### Devices -You can support external input/output devices such as Leap Motion, Faceplus, Faceshift PrioVR, RTmidi, SixSense and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in /hifi/interface/external/ for the detailed explanation of the requirements to use the device. +You can support external input/output devices such as Leap Motion, Faceplus, Faceshift, PrioVR, MIDI, Razr Hydra and more by adding each individual SDK in the visible building path. Refer to the readme file available in each device folder in [interface/external/](interface/external) for the detailed explanation of the requirements to use the device. diff --git a/cmake/modules/FindFaceplus.cmake b/cmake/modules/FindFaceplus.cmake index 2a2083d6e4..1050493c69 100644 --- a/cmake/modules/FindFaceplus.cmake +++ b/cmake/modules/FindFaceplus.cmake @@ -12,31 +12,13 @@ # Copyright (c) 2014 High Fidelity # -if (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS) - # in cache already - set(FACEPLUS_FOUND TRUE) -else (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS) - find_path(FACEPLUS_INCLUDE_DIRS faceplus.h ${FACEPLUS_ROOT_DIR}/include) +find_path(FACEPLUS_INCLUDE_DIRS faceplus.h ${FACEPLUS_ROOT_DIR}/include) - if (WIN32) - find_library(FACEPLUS_LIBRARIES faceplus.lib ${FACEPLUS_ROOT_DIR}/win32/) - endif (WIN32) - - if (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES) - set(FACEPLUS_FOUND TRUE) - endif (FACEPLUS_INCLUDE_DIRS AND FACEPLUS_LIBRARIES) +if (WIN32) + find_library(FACEPLUS_LIBRARIES faceplus.lib ${FACEPLUS_ROOT_DIR}/win32/) +endif (WIN32) - if (FACEPLUS_FOUND) - if (NOT FACEPLUS_FIND_QUIETLY) - message(STATUS "Found Faceplus... ${FACEPLUS_LIBRARIES}") - endif (NOT FACEPLUS_FIND_QUIETLY) - else () - if (FACEPLUS_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Faceplus") - endif (FACEPLUS_FIND_REQUIRED) - endif () +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FACEPLUS DEFAULT_MSG FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES) - # show the FACEPLUS_INCLUDE_DIRS and FACEPLUS_LIBRARIES variables only in the advanced view - mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES) - -endif (FACEPLUS_LIBRARIES AND FACEPLUS_INCLUDE_DIRS) +mark_as_advanced(FACEPLUS_INCLUDE_DIRS FACEPLUS_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindFaceshift.cmake b/cmake/modules/FindFaceshift.cmake index faf556e06c..e11c21cd3f 100644 --- a/cmake/modules/FindFaceshift.cmake +++ b/cmake/modules/FindFaceshift.cmake @@ -18,47 +18,27 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (FACESHIFT_LIBRARIES AND FACESHIFT_INCLUDE_DIRS) - # in cache already - set(FACESHIFT_FOUND TRUE) -else () - find_path(FACESHIFT_INCLUDE_DIRS fsbinarystream.h ${FACESHIFT_ROOT_DIR}/include) +set(FACESHIFT_SEARCH_DIRS "${FACESHIFT_ROOT_DIR}" "$ENV{FACESHIFT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/faceshift") - if (APPLE) - find_library(FACESHIFT_LIBRARIES libfaceshift.a ${FACESHIFT_ROOT_DIR}/lib/MacOS/) - elseif (UNIX) - find_library(FACESHIFT_LIBRARIES libfaceshift.a ${FACESHIFT_ROOT_DIR}/lib/UNIX/) - elseif (WIN32) - # For windows, we're going to build the faceshift sources directly into the interface build - # and not link to a prebuilt library. This is because the VS2010 linker doesn't like cross-linking - # between release and debug libraries. If we change that in the future we can make win32 more - # like the other platforms - #find_library(FACESHIFT_LIBRARIES faceshift.lib ${FACESHIFT_ROOT_DIR}/lib/WIN32/) - endif () - - if (WIN32) - # Windows only cares about the headers - if (FACESHIFT_INCLUDE_DIRS) - set(FACESHIFT_FOUND TRUE) - endif (FACESHIFT_INCLUDE_DIRS) - else () - # Mac and Unix requires libraries - if (FACESHIFT_INCLUDE_DIRS AND FACESHIFT_LIBRARIES) - set(FACESHIFT_FOUND TRUE) - endif (FACESHIFT_INCLUDE_DIRS AND FACESHIFT_LIBRARIES) - endif () - - if (FACESHIFT_FOUND) - if (NOT FACESHIFT_FIND_QUIETLY) - message(STATUS "Found Faceshift... ${FACESHIFT_LIBRARIES}") - endif (NOT FACESHIFT_FIND_QUIETLY) - else () - if (FACESHIFT_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Faceshift") - endif (FACESHIFT_FIND_REQUIRED) - endif () - - # show the FACESHIFT_INCLUDE_DIRS and FACESHIFT_LIBRARIES variables only in the advanced view - mark_as_advanced(FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) +find_path(FACESHIFT_INCLUDE_DIRS fsbinarystream.h PATH_SUFFIXES include HINTS ${FACESHIFT_SEARCH_DIRS}) +if (APPLE) + set(ARCH_DIR "MacOS") +elseif (UNIX) + set(ARCH_DIR "UNIX") +elseif (WIN32) + set(ARCH_DIR "Win32") endif () + +find_library(FACESHIFT_LIBRARY_RELEASE NAME faceshift PATH_SUFFIXES lib/${ARCH_DIR} HINTS ${FACESHIFT_SEARCH_DIRS}) +find_library(FACESHIFT_LIBRARY_DEBUG NAME faceshiftd PATH_SUFFIXES lib/${ARCH_DIR} HINTS ${FACESHIFT_SEARCH_DIRS}) + +include(SelectLibraryConfigurations) +select_library_configurations(FACESHIFT) + +set(FACESHIFT_LIBRARIES ${FACESHIFT_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FACESHIFT DEFAULT_MSG FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) + +mark_as_advanced(FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindGLEW.cmake b/cmake/modules/FindGLEW.cmake index b621756885..59927dc468 100644 --- a/cmake/modules/FindGLEW.cmake +++ b/cmake/modules/FindGLEW.cmake @@ -6,7 +6,7 @@ # # GLEW_FOUND # GLEW_INCLUDE_DIRS -# GLEW_LIBRARY +# GLEW_LIBRARIES # # Created on 2/6/2014 by Stephen Birarda # Copyright 2014 High Fidelity, Inc. @@ -18,27 +18,21 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (GLEW_INCLUDE_DIRS AND GLEW_LIBRARY) - set(GLEW_FOUND TRUE) -else () - if (WIN32) - set(WIN_GLEW_SEARCH_DIRS "${GLEW_ROOT_DIR}" "$ENV{GLEW_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glew") - - find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS}) - - find_library(GLEW_LIBRARY glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS}) - endif () - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARY) +if (WIN32) + set(WIN_GLEW_SEARCH_DIRS "${GLEW_ROOT_DIR}" "$ENV{GLEW_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glew") + + find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS}) - if (GLEW_FOUND) - if (NOT GLEW_FIND_QUIETLY) - message(STATUS "Found GLEW: ${GLEW_LIBRARY}") - endif () - else () - if (GLEW_FIND_REQUIRED) - message(FATAL_ERROR "Could not find GLEW") - endif () - endif () -endif () \ No newline at end of file + find_library(GLEW_LIBRARY_RELEASE glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS}) + find_library(GLEW_LIBRARY_DEBUG glew32s PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS}) + + include(SelectLibraryConfigurations) + select_library_configurations(GLEW) +endif () + +set(GLEW_LIBRARIES "${GLEW_LIBRARY}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES) + +mark_as_advanced(GLEW_INCLUDE_DIRS GLEW_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake index 1bd1239193..04bc252796 100644 --- a/cmake/modules/FindGLM.cmake +++ b/cmake/modules/FindGLM.cmake @@ -1,67 +1,26 @@ -# FindGLM - attempts to locate the glm matrix/vector library. # -# This module defines the following variables (on success): -# GLM_INCLUDE_DIRS - where to find glm/glm.hpp -# GLM_FOUND - if the library was successfully located -# -# It is trying a few standard installation locations, but can be customized -# with the following variables: -# GLM_ROOT_DIR - root directory of a glm installation -# Headers are expected to be found in either: -# /glm/glm.hpp OR -# /include/glm/glm.hpp -# This variable can either be a cmake or environment -# variable. Note however that changing the value -# of the environment varible will NOT result in -# re-running the header search and therefore NOT -# adjust the variables set by this module. - -# This is a modified version of the FindGLM module included with CMake. -# Copyright 2014 High Fidelity +# FindGLM.cmake # -#============================================================================= -# Copyright 2012 Carsten Neumann +# Try to find GLM include path. +# Once done this will define # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) +# GLM_INCLUDE_DIRS +# +# Created on 7/17/2014 by Stephen Birarda +# Copyright 2014 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# -if (GLM_INCLUDE_DIR) - set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") - set(GLM_FOUND TRUE) -else () - # default search dirs - set(_glm_HEADER_SEARCH_DIRS "$ENV{HIFI_LIB_DIR}/glm" "/usr/include" "/usr/local/include") +# setup hints for GLM search +set(GLM_HEADER_SEARCH_HINTS "${GLM_ROOT_DIR}" "$ENV{GLM_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glm") - # check environment variable - set(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}") +# locate header +find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_HEADER_SEARCH_HINTS}) +set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") - if (NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) - set(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}") - endif () +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS) - # put user specified location at beginning of search - if (GLM_ROOT_DIR) - set(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}" "${GLM_ROOT_DIR}/include" "$ENV{HIFI_LIB_DIR}/glm" ${_glm_HEADER_SEARCH_DIRS}) - ENDIF() - - # locate header - find_path(GLM_INCLUDE_DIR "glm/glm.hpp" PATHS ${_glm_HEADER_SEARCH_DIRS}) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIR) - - if (GLM_FOUND) - set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") - - if (NOT GLM_FIND_QUIETLY) - MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") - endif (NOT GLM_FIND_QUIETLY) - endif () -endif () \ No newline at end of file +mark_as_advanced(GLM_INCLUDE_DIRS) \ No newline at end of file diff --git a/cmake/modules/FindGLUT.cmake b/cmake/modules/FindGLUT.cmake index 280a6ac6db..881e649ecd 100644 --- a/cmake/modules/FindGLUT.cmake +++ b/cmake/modules/FindGLUT.cmake @@ -5,9 +5,8 @@ # Once done this will define # # GLUT_FOUND -# GLUT_INCLUDE_DIR +# GLUT_INCLUDE_DIRS # GLUT_LIBRARIES -# GLUT_DLL_PATH - Optionally defined for Win32, if not in path # # Created on 2/6/2014 by Stephen Birarda # Copyright 2014 High Fidelity, Inc. @@ -19,73 +18,29 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (GLUT_INCLUDE_DIR AND GLUT_LIBRARIES) - set(GLUT_FOUND TRUE) -else () - if (WIN32) - set(WIN_GLUT_SEARCH_DIRS "${GLUT_ROOT_DIR}" "$ENV{GLUT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/freeglut" "${OPENGL_INCLUDE_DIR}") - find_path(GLUT_INCLUDE_DIR GL/glut.h PATH_SUFFIXES include HINTS ${WIN_GLUT_SEARCH_DIRS}) +set(GLUT_HINT_DIRS "${GLUT_ROOT_DIR}" "$ENV{GLUT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/freeglut") - find_library(GLUT_glut_LIBRARY freeglut PATH_SUFFIXES lib HINTS ${WIN_GLUT_SEARCH_DIRS}) - else () - find_path(GLUT_INCLUDE_DIR GL/glut.h - "${GLUT_LOCATION}/include" - "$ENV{GLUT_LOCATION}/include" - /usr/include - /usr/include/GL - /usr/local/include - /usr/openwin/share/include - /usr/openwin/include - /usr/X11R6/include - /usr/include/X11 - /opt/graphics/OpenGL/include - /opt/graphics/OpenGL/contrib/libglut - ) - find_library(GLUT_glut_LIBRARY glut - "${GLUT_LOCATION}/lib" - "$ENV{GLUT_LOCATION}/lib" - /usr/lib - /usr/local/lib - /usr/openwin/lib - /usr/X11R6/lib - ) - find_library(GLUT_Xi_LIBRARY Xi - "${GLUT_LOCATION}/lib" - "$ENV{GLUT_LOCATION}/lib" - /usr/lib - /usr/local/lib - /usr/openwin/lib - /usr/X11R6/lib - ) - find_library(GLUT_Xmu_LIBRARY Xmu - "${GLUT_LOCATION}/lib" - "$ENV{GLUT_LOCATION}/lib" - /usr/lib - /usr/local/lib - /usr/openwin/lib - /usr/X11R6/lib - ) - endif () - - if (GLUT_INCLUDE_DIR AND GLUT_glut_LIBRARY) - # Is -lXi and -lXmu required on all platforms that have it? - # If not, we need some way to figure out what platform we are on. - set(GLUT_LIBRARIES ${GLUT_glut_LIBRARY} ${GLUT_Xmu_LIBRARY} ${GLUT_Xi_LIBRARY}) - endif () - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIR GLUT_LIBRARIES) +if (WIN32) + set(GLUT_HINT_DIRS "${GLUT_HINT_DIRS}" "${OPENGL_INCLUDE_DIR}") - if (GLUT_FOUND) - if (NOT GLUT_FIND_QUIETLY) - message(STATUS "Found GLUT: ${GLUT_LIBRARIES}") - endif () - else () - if (GLUT_FIND_REQUIRED) - message(FATAL_ERROR "Could not find GLUT") - endif () - endif () + find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${GLUT_HINT_DIRS}) + find_library(GLUT_LIBRARY freeglut PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) +else () + find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${GLUT_HINT_DIRS}) + find_library(GLUT_LIBRARY glut PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) +endif () - mark_as_advanced(GLUT_glut_LIBRARY GLUT_Xmu_LIBRARY GLUT_Xi_LIBRARY) +include(FindPackageHandleStandardArgs) -endif () \ No newline at end of file +set(GLUT_LIBRARIES "${GLUT_LIBRARY}" "${XMU_LIBRARY}" "${XI_LIBRARY}") + +if (UNIX) + find_library(XI_LIBRARY Xi PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) + find_library(XMU_LIBRARY Xmu PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) + + find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES XI_LIBRARY XMU_LIBRARY) +else () + find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES) +endif () + +mark_as_advanced(GLUT_INCLUDE_DIRS GLUT_LIBRARIES GLUT_LIBRARY XI_LIBRARY XMU_LIBRARY) \ No newline at end of file diff --git a/cmake/modules/FindLeapMotion.cmake b/cmake/modules/FindLeapMotion.cmake index 40958ece95..91ac080c30 100644 --- a/cmake/modules/FindLeapMotion.cmake +++ b/cmake/modules/FindLeapMotion.cmake @@ -12,36 +12,24 @@ # Copyright (c) 2014 High Fidelity # -if (LEAPMOTION_LIBRARIES AND LEAPMOTION_INCLUDE_DIRS) - # in cache already - set(LEAPMOTION_FOUND TRUE) -else (LEAPMOTION_LIBRARIES AND LEAPMOTION_INCLUDE_DIRS) - set(LEAPMOTION_SEARCH_DIRS "${LEAPMOTION_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/leapmotion") +set(LEAPMOTION_SEARCH_DIRS "${LEAPMOTION_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/leapmotion") - find_path(LEAPMOTION_INCLUDE_DIRS Leap.h PATH_SUFFIXES include HINTS ${LEAPMOTION_SEARCH_DIRS}) +find_path(LEAPMOTION_INCLUDE_DIRS Leap.h PATH_SUFFIXES include HINTS ${LEAPMOTION_SEARCH_DIRS}) - if (WIN32) - find_library(LEAPMOTION_LIBRARIES "lib/x86/Leap.lib" HINTS ${LEAPMOTION_SEARCH_DIRS}) - endif (WIN32) - if (APPLE) - find_library(LEAPMOTION_LIBRARIES "lib/libLeap.dylib" HINTS ${LEAPMOTION_SEARCH_DIRS}) - endif (APPLE) - - if (LEAPMOTION_INCLUDE_DIRS AND LEAPMOTION_LIBRARIES) - set(LEAPMOTION_FOUND TRUE) - endif (LEAPMOTION_INCLUDE_DIRS AND LEAPMOTION_LIBRARIES) +if (WIN32) + find_library(LEAPMOTION_LIBRARY_DEBUG "lib/x86/Leapd.lib" HINTS ${LEAPMOTION_SEARCH_DIRS}) + find_library(LEAPMOTION_LIBRARY_RELEASE "lib/x86/Leap.lib" HINTS ${LEAPMOTION_SEARCH_DIRS}) +endif (WIN32) +if (APPLE) + find_library(LEAPMOTION_LIBRARY_RELEASE "lib/libLeap.dylib" HINTS ${LEAPMOTION_SEARCH_DIRS}) +endif (APPLE) - if (LEAPMOTION_FOUND) - if (NOT LEAPMOTION_FIND_QUIETLY) - message(STATUS "Found LEAPMOTION... ${LEAPMOTION_LIBRARIES}") - endif (NOT LEAPMOTION_FIND_QUIETLY) - else () - if (LEAPMOTION_FIND_REQUIRED) - message(FATAL_ERROR "Could not find LEAPMOTION") - endif (LEAPMOTION_FIND_REQUIRED) - endif () +include(SelectLibraryConfigurations) +select_library_configurations(LEAPMOTION) - # show the LEAPMOTION_INCLUDE_DIRS and LEAPMOTION_LIBRARIES variables only in the advanced view - mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) +set(LEAPMOTION_LIBRARIES "${LEAPMOTION_LIBARIES}") -endif (LEAPMOTION_LIBRARIES AND LEAPMOTION_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LEAPMOTION DEFAULT_MSG LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) + +mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 91714e8a59..738a30519c 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -18,52 +18,49 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS) - # in cache already - set(LIBOVR_FOUND TRUE) -else (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS) - set(LIBOVR_SEARCH_DIRS "${LIBOVR_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/oculus") +set(LIBOVR_SEARCH_DIRS "${LIBOVR_ROOT_DIR}" "$ENV{LIBOVR_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/oculus") + +find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS}) +find_path(LIBOVR_UTIL_INCLUDE_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${LIBOVR_SEARCH_DIRS}) + +# add the util include dir to the general include dirs +set(LIBOVR_INCLUDE_DIRS "${LIBOVR_INCLUDE_DIRS}" "${LIBOVR_UTIL_INCLUDE_DIR}") + +include(SelectLibraryConfigurations) + +if (APPLE) + find_library(LIBOVR_LIBRARY_DEBUG "Lib/MacOS/Debug/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE "Lib/MacOS/Release/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) +elseif (UNIX) + find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/) + find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/) - find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS}) + if (CMAKE_CL_64) + set(LINUX_ARCH_DIR "i386") + else() + set(LINUX_ARCH_DIR "x86_64") + endif() - if (APPLE) - find_library(LIBOVR_LIBRARIES "Lib/MacOS/Release/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) - elseif (UNIX) - find_library(UDEV_LIBRARY libudev.a /usr/lib/x86_64-linux-gnu/) - find_library(XINERAMA_LIBRARY libXinerama.a /usr/lib/x86_64-linux-gnu/) - - if (CMAKE_CL_64) - set(LINUX_ARCH_DIR "i386") - else() - set(LINUX_ARCH_DIR "x86_64") - endif() - - find_library(OVR_LIBRARY "Lib/Linux/${CMAKE_BUILD_TYPE}/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) - if (UDEV_LIBRARY AND XINERAMA_LIBRARY AND OVR_LIBRARY) - set(LIBOVR_LIBRARIES "${OVR_LIBRARY};${UDEV_LIBRARY};${XINERAMA_LIBRARY}" CACHE INTERNAL "Oculus libraries") - endif (UDEV_LIBRARY AND XINERAMA_LIBRARY AND OVR_LIBRARY) - elseif (WIN32) - find_library(LIBOVR_RELEASE_LIBRARIES "Lib/Win32/libovr.lib" HINTS ${LIBOVR_SEARCH_DIRS}) - find_library(LIBOVR_DEBUG_LIBRARIES "Lib/Win32/libovrd.lib" HINTS ${LIBOVR_SEARCH_DIRS}) - - set(LIBOVR_LIBRARIES "${LIBOVR_RELEASE_LIBRARIES} ${LIBOVR_DEBUG_LIBRARIES}") - endif () + find_library(LIBOVR_LIBRARY_DEBUG "Lib/Linux/Debug/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE "Lib/Linux/Release/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) + + select_library_configurations(UDEV) + select_library_configurations(XINERAMA) + +elseif (WIN32) + find_library(LIBOVR_LIBRARY_DEBUG "Lib/Win32/libovrd.lib" HINTS ${LIBOVR_SEARCH_DIRS}) + find_library(LIBOVR_LIBRARY_RELEASE "Lib/Win32/libovr.lib" HINTS ${LIBOVR_SEARCH_DIRS}) +endif () - if (LIBOVR_INCLUDE_DIRS AND LIBOVR_LIBRARIES) - set(LIBOVR_FOUND TRUE) - endif (LIBOVR_INCLUDE_DIRS AND LIBOVR_LIBRARIES) - - if (LIBOVR_FOUND) - if (NOT LibOVR_FIND_QUIETLY) - message(STATUS "Found LibOVR: ${LIBOVR_LIBRARIES}") - endif (NOT LibOVR_FIND_QUIETLY) - else (LIBOVR_FOUND) - if (LibOVR_FIND_REQUIRED) - message(FATAL_ERROR "Could not find LibOVR") - endif (LibOVR_FIND_REQUIRED) - endif (LIBOVR_FOUND) +select_library_configurations(LIBOVR) - # show the LIBOVR_INCLUDE_DIRS and LIBOVR_LIBRARIES variables only in the advanced view - mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES) +set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") -endif (LIBOVR_LIBRARIES AND LIBOVR_INCLUDE_DIRS) +include(FindPackageHandleStandardArgs) +if (UNIX) + find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_UTIL_INCLUDE_DIR LIBOVR_LIBRARIES) +elseif () + find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_UTIL_INCLUDE_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) +endif () + +mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES) diff --git a/cmake/modules/FindOpenSSL.cmake b/cmake/modules/FindOpenSSL.cmake index 1dbac311da..403bb4e246 100644 --- a/cmake/modules/FindOpenSSL.cmake +++ b/cmake/modules/FindOpenSSL.cmake @@ -35,43 +35,24 @@ endif () if (WIN32) # http://www.slproweb.com/products/Win32OpenSSL.html - set(_OPENSSL_ROOT_HINTS - ${OPENSSL_ROOT_DIR} - $ENV{OPENSSL_ROOT_DIR} - $ENV{HIFI_LIB_DIR}/openssl + set(_OPENSSL_ROOT_HINTS ${OPENSSL_ROOT_DIR} $ENV{OPENSSL_ROOT_DIR} $ENV{HIFI_LIB_DIR}/openssl "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]" ) file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) - set(_OPENSSL_ROOT_PATHS - "${_programfiles}/OpenSSL" - "${_programfiles}/OpenSSL-Win32" - "${_programfiles}/OpenSSL-Win64" - "C:/OpenSSL/" - "C:/OpenSSL-Win32/" - "C:/OpenSSL-Win64/" - ) + set(_OPENSSL_ROOT_PATHS "${_programfiles}/OpenSSL" "${_programfiles}/OpenSSL-Win32" "${_programfiles}/OpenSSL-Win64" + "C:/OpenSSL/" "C:/OpenSSL-Win32/" "C:/OpenSSL-Win64/" + ) unset(_programfiles) - set(_OPENSSL_ROOT_HINTS_AND_PATHS - HINTS ${_OPENSSL_ROOT_HINTS} - PATHS ${_OPENSSL_ROOT_PATHS} - ) + set(_OPENSSL_ROOT_HINTS_AND_PATHS HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS}) else () set(_OPENSSL_ROOT_HINTS_AND_PATHS ${OPENSSL_ROOT_DIR} $ENV{OPENSSL_ROOT_DIR} $ENV{HIFI_LIB_DIR}/openssl) endif () -find_path(OPENSSL_INCLUDE_DIR - NAMES - openssl/ssl.h - HINTS - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - ${_OPENSSL_INCLUDEDIR} - PATH_SUFFIXES - include -) +find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_INCLUDEDIR} PATH_SUFFIXES include) -if(WIN32 AND NOT CYGWIN) - if(MSVC) +if (WIN32 AND NOT CYGWIN) + if (MSVC) # /MD and /MDd are the standard values - if someone wants to use # others, the libnames have to change here too # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b @@ -86,49 +67,20 @@ if(WIN32 AND NOT CYGWIN) # We are using the libraries located in the VC subdir instead of the parent directory eventhough : # libeay32MD.lib is identical to ../libeay32.lib, and # ssleay32MD.lib is identical to ../ssleay32.lib - find_library(LIB_EAY_DEBUG - NAMES - libeay32MDd - libeay32d - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + find_library(LIB_EAY_DEBUG NAMES libeay32MDd libeay32d + ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC" ) - find_library(LIB_EAY_RELEASE - NAMES - libeay32MD - libeay32 - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + find_library(LIB_EAY_RELEASE NAMES libeay32MD libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC" ) - find_library(SSL_EAY_DEBUG - NAMES - ssleay32MDd - ssleay32d - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + find_library(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32d + ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC" ) - find_library(SSL_EAY_RELEASE - NAMES - ssleay32MD - ssleay32 - ssl - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - PATH_SUFFIXES - "lib" - "VC" - "lib/VC" + find_library(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl + ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "VC" "lib/VC" ) set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}") @@ -140,85 +92,45 @@ if(WIN32 AND NOT CYGWIN) select_library_configurations(LIB_EAY) select_library_configurations(SSL_EAY) - set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} ) - elseif(MINGW) + set(OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY}) + elseif (MINGW) # same player, for MinGW set(LIB_EAY_NAMES libeay32) set(SSL_EAY_NAMES ssleay32) - if(CMAKE_CROSSCOMPILING) + + if (CMAKE_CROSSCOMPILING) list(APPEND LIB_EAY_NAMES crypto) list(APPEND SSL_EAY_NAMES ssl) - endif() - find_library(LIB_EAY - NAMES - ${LIB_EAY_NAMES} - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - PATH_SUFFIXES - "lib" - "lib/MinGW" + endif () + + find_library(LIB_EAY NAMES ${LIB_EAY_NAMES} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "lib/MinGW" ) - find_library(SSL_EAY - NAMES - ${SSL_EAY_NAMES} - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - PATH_SUFFIXES - "lib" - "lib/MinGW" + find_library(SSL_EAY NAMES ${SSL_EAY_NAMES} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES "lib" "lib/MinGW" ) mark_as_advanced(SSL_EAY LIB_EAY) - set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY}) unset(LIB_EAY_NAMES) unset(SSL_EAY_NAMES) - else() + else () # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: - find_library(LIB_EAY - NAMES - libeay32 - HINTS - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - ${_OPENSSL_LIBDIR} - PATH_SUFFIXES - lib - ) + find_library(LIB_EAY NAMES libeay32 HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} PATH_SUFFIXES lib) - find_library(SSL_EAY - NAMES - ssleay32 - HINTS - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - ${_OPENSSL_LIBDIR} - PATH_SUFFIXES - lib - ) + find_library(SSL_EAY NAMES ssleay32 HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} PATH_SUFFIXES lib) mark_as_advanced(SSL_EAY LIB_EAY) - set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY}) endif() else() - find_library(OPENSSL_SSL_LIBRARY - NAMES - ssl - ssleay32 - ssleay32MD - HINTS - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - ${_OPENSSL_LIBDIR} - PATH_SUFFIXES - lib + find_library(OPENSSL_SSL_LIBRARY NAMES ssl ssleay32 ssleay32MD HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} + PATH_SUFFIXES lib ) - find_library(OPENSSL_CRYPTO_LIBRARY - NAMES - crypto - HINTS - ${_OPENSSL_ROOT_HINTS_AND_PATHS} - ${_OPENSSL_LIBDIR} - PATH_SUFFIXES - lib - ) + find_library(OPENSSL_CRYPTO_LIBRARY NAMES crypto HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_LIBDIR} PATH_SUFFIXES lib) mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY) @@ -228,7 +140,7 @@ else() set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) -endif() +endif () function(from_hex HEX DEC) string(TOUPPER "${HEX}" HEX) diff --git a/cmake/modules/FindPrioVR.cmake b/cmake/modules/FindPrioVR.cmake index 6e78045321..af2c0aca52 100644 --- a/cmake/modules/FindPrioVR.cmake +++ b/cmake/modules/FindPrioVR.cmake @@ -1,4 +1,4 @@ -# Try to find the PrioVT library +# Try to find the PrioVR library # # You must provide a PRIOVR_ROOT_DIR which contains lib and include directories # @@ -12,31 +12,13 @@ # Copyright (c) 2014 High Fidelity # -if (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) - # in cache already - set(PRIOVR_FOUND TRUE) -else (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) - find_path(PRIOVR_INCLUDE_DIRS yei_skeletal_api.h ${PRIOVR_ROOT_DIR}/include) +find_path(PRIOVR_INCLUDE_DIRS yei_skeletal_api.h ${PRIOVR_ROOT_DIR}/include) - if (WIN32) - find_library(PRIOVR_LIBRARIES Skeletal_API.lib ${PRIOVR_ROOT_DIR}/lib) - endif (WIN32) - - if (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES) - set(PRIOVR_FOUND TRUE) - endif (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES) +if (WIN32) + find_library(PRIOVR_LIBRARIES Skeletal_API.lib ${PRIOVR_ROOT_DIR}/lib) +endif (WIN32) - if (PRIOVR_FOUND) - if (NOT PRIOVR_FIND_QUIETLY) - message(STATUS "Found PrioVR... ${PRIOVR_LIBRARIES}") - endif (NOT PRIOVR_FIND_QUIETLY) - else () - if (PRIOVR_FIND_REQUIRED) - message(FATAL_ERROR "Could not find PrioVR") - endif (PRIOVR_FIND_REQUIRED) - endif () +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PRIOVR DEFAULT_MSG PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) - # show the PRIOVR_INCLUDE_DIRS and PRIOVR_LIBRARIES variables only in the advanced view - mark_as_advanced(PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) - -endif (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS) +mark_as_advanced(PRIOVR_INCLUDE_DIRS PRIOVR_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindQxmpp.cmake b/cmake/modules/FindQxmpp.cmake index 420186d969..71c99369aa 100644 --- a/cmake/modules/FindQxmpp.cmake +++ b/cmake/modules/FindQxmpp.cmake @@ -9,7 +9,7 @@ # # QXMPP_FOUND - system found qxmpp # QXMPP_INCLUDE_DIRS - the qxmpp include directory -# QXMPP_LIBRARY - Link this to use qxmpp +# QXMPP_LIBRARIES - Link this to use qxmpp # # Created on 3/10/2014 by Stephen Birarda # Copyright 2014 High Fidelity, Inc. @@ -18,17 +18,19 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (QXMPP_LIBRARIES AND QXMPP_INCLUDE_DIRS) - # in cache already - set(QXMPP_FOUND TRUE) -else () - - set(QXMPP_SEARCH_DIRS "${QXMPP_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/qxmpp") - - find_path(QXMPP_INCLUDE_DIR QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS}) +set(QXMPP_SEARCH_DIRS "${QXMPP_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/qxmpp") - find_library(QXMPP_LIBRARY NAMES qxmpp qxmpp0 qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS}) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIR QXMPP_LIBRARY) -endif () \ No newline at end of file +find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS}) + +find_library(QXMPP_LIBRARY_RELEASE NAMES qxmpp PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS}) +find_library(QXMPP_LIBRARY_DEBUG NAMES qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS}) + +include(SelectLibraryConfigurations) +select_library_configurations(QXMPP) + +set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) + +mark_as_advanced(QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindRtMidi.cmake b/cmake/modules/FindRtMidi.cmake index ad1167c5d6..d03477710c 100644 --- a/cmake/modules/FindRtMidi.cmake +++ b/cmake/modules/FindRtMidi.cmake @@ -9,7 +9,7 @@ # # RTMIDI_FOUND - system found RtMidi # RTMIDI_INCLUDE_DIRS - the RtMidi include directory -# RTMIDI_CPP - Include this with src to use RtMidi +# RTMIDI_LIBRARIES - link to this to use RtMidi # # Created on 6/30/2014 by Stephen Birarda # Copyright 2014 High Fidelity, Inc. @@ -18,16 +18,12 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (RTMIDI_LIBRARIES AND RTMIDI_INCLUDE_DIRS) - # in cache already - set(RTMIDI_FOUND TRUE) -else () - - set(RTMIDI_SEARCH_DIRS "${RTMIDI_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/rtmidi") - - find_path(RTMIDI_INCLUDE_DIR RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEARCH_DIRS}) - find_library(RTMIDI_LIBRARY NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS}) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(RTMIDI DEFAULT_MSG RTMIDI_INCLUDE_DIR RTMIDI_LIBRARY) -endif () \ No newline at end of file +set(RTMIDI_SEARCH_DIRS "${RTMIDI_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/rtmidi") + +find_path(RTMIDI_INCLUDE_DIRS RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEARCH_DIRS}) +find_library(RTMIDI_LIBRARIES NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(RTMIDI DEFAULT_MSG RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES) + +mark_as_advanced(RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES) \ No newline at end of file diff --git a/cmake/modules/FindSixense.cmake b/cmake/modules/FindSixense.cmake index 02b6e3fc21..9b8209ef29 100644 --- a/cmake/modules/FindSixense.cmake +++ b/cmake/modules/FindSixense.cmake @@ -18,34 +18,27 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (SIXENSE_LIBRARIES AND SIXENSE_INCLUDE_DIRS) - # in cache already - set(SIXENSE_FOUND TRUE) -else () - - set(SIXENSE_SEARCH_DIRS "${SIXENSE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/sixense") - - find_path(SIXENSE_INCLUDE_DIRS sixense.h PATH_SUFFIXES include HINTS ${SIXENSE_SEARCH_DIRS}) +set(SIXENSE_SEARCH_DIRS "${SIXENSE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/sixense") - if (APPLE) - find_library(SIXENSE_LIBRARIES lib/osx_x64/release_dll/libsixense_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS}) - elseif (UNIX) - find_library(SIXENSE_LIBRARIES lib/linux_x64/release/libsixense_x64.so HINTS ${SIXENSE_SEARCH_DIRS}) - elseif (WIN32) - find_library(SIXENSE_LIBRARIES lib/win32/release_dll/sixense.lib HINTS ${SIXENSE_SEARCH_DIRS}) - endif () +find_path(SIXENSE_INCLUDE_DIRS sixense.h PATH_SUFFIXES include HINTS ${SIXENSE_SEARCH_DIRS}) - if (SIXENSE_INCLUDE_DIRS AND SIXENSE_LIBRARIES) - set(SIXENSE_FOUND TRUE) - endif () - - if (SIXENSE_FOUND) - if (NOT SIXENSE_FIND_QUIETLY) - message(STATUS "Found Sixense: ${SIXENSE_LIBRARIES}") - endif (NOT SIXENSE_FIND_QUIETLY) - else () - if (SIXENSE_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Sixense") - endif (SIXENSE_FIND_REQUIRED) - endif () +if (APPLE) + find_library(SIXENSE_LIBRARY_RELEASE lib/osx_x64/release_dll/libsixense_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS}) + find_library(SIXENSE_LIBRARY_DEBUG lib/osx_x64/debug_dll/libsixensed_x64.dylib HINTS ${SIXENSE_SEARCH_DIRS}) +elseif (UNIX) + find_library(SIXENSE_LIBRARY_RELEASE lib/linux_x64/release/libsixense_x64.so HINTS ${SIXENSE_SEARCH_DIRS}) + find_library(SIXENSE_LIBRARY_DEBUG lib/linux_x64/debug/libsixensed_x64.so HINTS ${SIXENSE_SEARCH_DIRS}) +elseif (WIN32) + find_library(SIXENSE_LIBRARY_RELEASE lib/win32/release_dll/sixense.lib HINTS ${SIXENSE_SEARCH_DIRS}) + find_library(SIXENSE_LIBRARY_DEBUG lib/win32/debug_dll/sixensed.lib HINTS ${SIXENSE_SEARCH_DIRS}) endif () + +include(SelectLibraryConfigurations) +select_library_configurations(SIXENSE) + +set(SIXENSE_LIBRARIES "${SIXENSE_LIBRARY}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SIXENSE DEFAULT_MSG SIXENSE_INCLUDE_DIRS SIXENSE_LIBRARIES) + +mark_as_advanced(SIXENSE_LIBRARIES SIXENSE_INCLUDE_DIRS) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 0aa57f6508..4151d3bec0 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -18,65 +18,40 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (VISAGE_LIBRARIES AND VISAGE_INCLUDE_DIRS) - # in cache already - set(VISAGE_FOUND TRUE) -else () - find_path(VISAGE_INCLUDE_DIR VisageTracker2.h ${VISAGE_ROOT_DIR}/include) +set(VISAGE_SEARCH_DIRS "${VISAGE_ROOT_DIR}" "$ENV{VISAGE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/visage") + +find_path(VISAGE_INCLUDE_DIR VisageTracker2.h PATH_SUFFIXES include HINTS ${VISAGE_SEARCH_DIRS}) + +if (APPLE) + find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h HINTS /usr/include/libxml2 ${VISAGE_SEARCH_DIRS}) + find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h PATH_SUFFIXES dependencies/OpenCV_MacOSX/include HINTS ${VISAGE_SEARCH_DIRS}) + find_path(VISAGE_OPENCV2_INCLUDE_DIR opencv.hpp PATH_SUFFIXES dependencies/OpenCV_MacOSX/include/opencv2 HINTS ${VISAGE_SEARCH_DIRS}) - if (APPLE) - find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h /usr/include/libxml2) - find_path(VISAGE_OPENCV_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include) - find_path(VISAGE_OPENCV2_INCLUDE_DIR opencv.hpp ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/include/opencv2) - if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) - set(VISAGE_INCLUDE_DIRS - "${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}" - CACHE INTERNAL "Visage include dirs") - endif (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) - - find_library(VISAGE_CORE_LIBRARY libvscore.a ${VISAGE_ROOT_DIR}/lib) - find_library(VISAGE_VISION_LIBRARY libvsvision.a ${VISAGE_ROOT_DIR}/lib) - find_library(VISAGE_OPENCV_LIBRARY libOpenCV.a ${VISAGE_ROOT_DIR}/dependencies/OpenCV_MacOSX/lib) - if (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) - set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY};${VISAGE_VISION_LIBRARY};${VISAGE_OPENCV_LIBRARY}" - CACHE INTERNAL "Visage libraries") - endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) - - elseif (WIN32) - find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h ${VISAGE_ROOT_DIR}/dependencies/libxml2/include) - find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV/include) - find_path(VISAGE_OPENCV2_INCLUDE_DIR cv.h ${VISAGE_ROOT_DIR}/dependencies/OpenCV/include/opencv) - if (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) - set(VISAGE_INCLUDE_DIRS - "${VISAGE_INCLUDE_DIR};${VISAGE_XML_INCLUDE_DIR};${VISAGE_OPENCV_INCLUDE_DIR};${VISAGE_OPENCV2_INCLUDE_DIR}" - CACHE INTERNAL "Visage include dirs") - endif (VISAGE_INCLUDE_DIR AND VISAGE_XML_INCLUDE_DIR AND VISAGE_OPENCV_INCLUDE_DIR AND VISAGE_OPENCV2_INCLUDE_DIR) - - find_library(VISAGE_CORE_LIBRARY vscore.lib ${VISAGE_ROOT_DIR}/lib) - find_library(VISAGE_VISION_LIBRARY vsvision.lib ${VISAGE_ROOT_DIR}/lib) - find_library(VISAGE_OPENCV_LIBRARY opencv_core243.lib ${VISAGE_ROOT_DIR}/dependencies/OpenCV/lib) - if (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) - set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY};${VISAGE_VISION_LIBRARY};${VISAGE_OPENCV_LIBRARY}" - CACHE INTERNAL "Visage libraries") - endif (VISAGE_CORE_LIBRARY AND VISAGE_VISION_LIBRARY AND VISAGE_OPENCV_LIBRARY) - - endif () - - if (VISAGE_INCLUDE_DIRS AND VISAGE_LIBRARIES) - set(VISAGE_FOUND TRUE) - endif (VISAGE_INCLUDE_DIRS AND VISAGE_LIBRARIES) - - if (VISAGE_FOUND) - if (NOT VISAGE_FIND_QUIETLY) - message(STATUS "Found Visage: ${VISAGE_LIBRARIES}") - endif (NOT VISAGE_FIND_QUIETLY) - else (VISAGE_FOUND) - if (VISAGE_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Visage") - endif (VISAGE_FIND_REQUIRED) - endif (VISAGE_FOUND) - - # show the VISAGE_INCLUDE_DIRS and VISAGE_LIBRARIES variables only in the advanced view - mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) - + find_library(VISAGE_CORE_LIBRARY NAME vscore PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib ${VISAGE_SEARCH_DIRS}) + +elseif (WIN32) + find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) + find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h PATH_SUFFIXES dependencies/OpenCV/include HINTS ${VISAGE_SEARCH_DIRS}) + find_path(VISAGE_OPENCV2_INCLUDE_DIR cv.h PATH_SUFFIXES dependencies/OpenCV/include/opencv HINTS ${VISAGE_SEARCH_DIRS}) + + find_library(VISAGE_CORE_LIBRARY NAME vscore PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(VISAGE_OPENCV_LIBRARY NAME opencv_core243 PATH_SUFFIXES dependencies/OpenCV/lib HINTS ${VISAGE_SEARCH_DIRS}) endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VISAGE DEFAULT_MSG + VISAGE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY +) + +set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}") +set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") + +mark_as_advanced( + VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES + VISAGE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY +) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 324fd6ee1d..5461bc2556 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -58,19 +58,6 @@ foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels pa set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}") endforeach(SUBDIR) -# windows also includes the faceshift externals, because using a lib doesn't work due to debug/release mismatch -if (WIN32) - set(EXTERNAL_SOURCE_SUBDIRS "faceshift") -endif () - -foreach(EXTERNAL_SOURCE_SUBDIR ${EXTERNAL_SOURCE_SUBDIRS}) - file(GLOB_RECURSE SUBDIR_SRCS - "external/${EXTERNAL_SOURCE_SUBDIR}/src/*.cpp" - "external/${EXTERNAL_SOURCE_SUBDIR}/src/*.c" - "external/${EXTERNAL_SOURCE_SUBDIR}/src/*.h") - set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}") -endforeach(EXTERNAL_SOURCE_SUBDIR) - find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) # grab the ui files in resources/ui @@ -154,7 +141,7 @@ if (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) if (APPLE OR UNIX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${SIXENSE_INCLUDE_DIRS}") endif (APPLE OR UNIX) - target_link_libraries(${TARGET_NAME} "${SIXENSE_LIBRARIES}") + target_link_libraries(${TARGET_NAME} ${SIXENSE_LIBRARIES}) endif (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) # likewise with Visage library for webcam feature tracking @@ -183,17 +170,15 @@ endif (FACEPLUS_FOUND AND NOT DISABLE_FACEPLUS) # and with LibOVR for Oculus Rift if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) add_definitions(-DHAVE_LIBOVR) - include_directories(SYSTEM "${LIBOVR_INCLUDE_DIRS}") - - if (APPLE OR UNIX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LIBOVR_INCLUDE_DIRS}") - endif () - - if (WIN32) - target_link_libraries(${TARGET_NAME} optimized "${LIBOVR_RELEASE_LIBRARIES}" debug "${LIBOVR_DEBUG_LIBRARIES}") - else () - target_link_libraries(${TARGET_NAME} "${LIBOVR_LIBRARIES}") + include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS}) + + if (APPLE) + foreach(LIBOVR_DIR ${LIBOVR_INCLUDE_DIRS}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LIBOVR_DIR}") + endforeach() endif () + + target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES}) endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) # and with PrioVR library @@ -208,10 +193,10 @@ if (LEAPMOTION_FOUND AND NOT DISABLE_LEAPMOTION) add_definitions(-DHAVE_LEAPMOTION) include_directories(SYSTEM "${LEAPMOTION_INCLUDE_DIRS}") - if (APPLE OR UNIX) + if (APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LEAPMOTION_INCLUDE_DIRS}") endif () - target_link_libraries(${TARGET_NAME} "${LEAPMOTION_LIBRARIES}") + target_link_libraries(${TARGET_NAME} ${LEAPMOTION_LIBRARIES}) endif (LEAPMOTION_FOUND AND NOT DISABLE_LEAPMOTION) # and with SDL for joysticks @@ -224,23 +209,29 @@ endif (SDL_FOUND AND NOT DISABLE_SDL) # and with qxmpp for chat if (QXMPP_FOUND AND NOT DISABLE_QXMPP) add_definitions(-DHAVE_QXMPP -DQXMPP_STATIC) - include_directories(SYSTEM ${QXMPP_INCLUDE_DIR}) + include_directories(SYSTEM "${QXMPP_INCLUDE_DIRS}") - target_link_libraries(${TARGET_NAME} "${QXMPP_LIBRARY}") + target_link_libraries(${TARGET_NAME} ${QXMPP_LIBRARIES}) endif (QXMPP_FOUND AND NOT DISABLE_QXMPP) # and with RtMidi for RtMidi control if (RTMIDI_FOUND AND NOT DISABLE_RTMIDI) + add_definitions(-DHAVE_RTMIDI) + include_directories(SYSTEM "${RTMIDI_INCLUDE_DIRS}") + target_link_libraries(${TARGET_NAME} ${RTMIDI_LIBRARIES}) - add_definitions(-DHAVE_RTMIDI) - include_directories(SYSTEM ${RTMIDI_INCLUDE_DIR}) - target_link_libraries(${TARGET_NAME} "${RTMIDI_LIBRARY}") - - if (APPLE) - find_library(CoreMIDI CoreMIDI) - add_definitions(-D__MACOSX_CORE__) - target_link_libraries(${TARGET_NAME} ${CoreMIDI}) - endif() + if (APPLE) + find_library(CoreMIDI CoreMIDI) + add_definitions(-D__MACOSX_CORE__) + target_link_libraries(${TARGET_NAME} ${CoreMIDI}) + endif() +endif() + +# and with Faceshift for depth camera face tracking +if (FACESHIFT_FOUND AND NOT DISABLE_FACESHIFT) + add_definitions(-DAHAVE_FACESHIFT) + include_directories(SYSTEM "${FACESHIFT_INCLUDE_DIRS}") + target_link_libraries(${TARGET_NAME} ${FACESHIFT_LIBRARIES}) endif() # include headers for interface and InterfaceConfig. @@ -248,11 +239,10 @@ include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes" # include external library headers # use system flag so warnings are supressed -include_directories(SYSTEM "${FACESHIFT_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") +include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") target_link_libraries( ${TARGET_NAME} - "${FACESHIFT_LIBRARIES}" "${ZLIB_LIBRARIES}" ${OPENSSL_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL @@ -305,7 +295,7 @@ else (APPLE) find_package(OpenGL REQUIRED) find_package(GLUT REQUIRED) - include_directories(SYSTEM "${GLUT_INCLUDE_DIR}") + include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}") if (${OPENGL_INCLUDE_DIR}) include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}") @@ -324,6 +314,6 @@ else (APPLE) # add a definition for ssize_t so that windows doesn't bail add_definitions(-Dssize_t=long) - target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARY}" wsock32.lib opengl32.lib) + target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib) endif() endif (APPLE) diff --git a/interface/external/faceshift/CMakeLists.txt b/interface/external/faceshift/CMakeLists.txt deleted file mode 100644 index be1c320c29..0000000000 --- a/interface/external/faceshift/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -set(TARGET_NAME faceshift) -project(${TARGET_NAME}) - -# grab the implemenation and header files -file(GLOB FACESHIFT_SRCS include/*.h src/*.cpp) - -include_directories(include) - -add_library(${TARGET_NAME} "${FACESHIFT_SRCS}") diff --git a/interface/external/faceshift/include/fsbinarystream.h b/interface/external/faceshift/include/fsbinarystream.h deleted file mode 100644 index 8fa585397b..0000000000 --- a/interface/external/faceshift/include/fsbinarystream.h +++ /dev/null @@ -1,410 +0,0 @@ -#pragma once - -#ifndef FSBINARYSTREAM_H -#define FSBINARYSTREAM_H - -// ========================================================================== -// Copyright (C) 2012 faceshift AG, and/or its licensors. All rights reserved. -// -// the software is free to use and provided "as is", without warranty of any kind. -// faceshift AG does not make and hereby disclaims any express or implied -// warranties including, but not limited to, the warranties of -// non-infringement, merchantability or fitness for a particular purpose, -// or arising from a course of dealing, usage, or trade practice. in no -// event will faceshift AG and/or its licensors be liable for any lost -// revenues, data, or profits, or special, direct, indirect, or -// consequential damages, even if faceshift AG and/or its licensors has -// been advised of the possibility or probability of such damages. -// ========================================================================== - - -/** - * Define the HAVE_EIGEN preprocessor define, if you are using the Eigen library, it allows you to easily convert our tracked data from and to eigen - * See fsVector3f and fsQuaternionf for more details - **/ - -#ifdef HAVE_EIGEN -#include -#include -#endif - -#ifdef _MSC_VER -#include -#else -#include -#endif - -#include -#include -#include - -/******************************************************************************************* - * This first part of the file contains a definition of the datastructures holding the - * tracking results - ******************************************************************************************/ - -namespace fs { - -/** - * A floating point three-vector. - * - * To keep these networking classes as simple as possible, we do not implement the - * vector semantics here, use Eigen for that purpose. The class just holds three named floats, - * and you have to interpret them yourself. - **/ -struct fsVector3f { - float x,y,z; - - fsVector3f() {} -#ifdef HAVE_EIGEN - explicit fsVector3f(const Eigen::Matrix &v) : x(v[0]), y(v[1]), z(v[2]) {} - Eigen::Map< Eigen::Matrix > eigen() const { return Eigen::Map >((float*)this); } -#endif -}; - -/** - * An integer three-vector. - **/ -struct fsVector3i { - int32_t x,y,z; - - fsVector3i() {} -#ifdef HAVE_EIGEN - explicit fsVector3i(const Eigen::Matrix &v) : x(v[0]), y(v[1]), z(v[2]) {} - Eigen::Map > eigen() const { return Eigen::Map >((int32_t*)this); } -#endif -}; - -/** - * An integer four-vector. - **/ -struct fsVector4i { - int32_t x,y,z,w; - - fsVector4i() {} -#ifdef HAVE_EIGEN - explicit fsVector4i(const Eigen::Matrix &v) : x(v[0]), y(v[1]), z(v[2]), w(v[3]) {} - Eigen::Map > eigen() const { return Eigen::Map >((int32_t*)this); } -#endif -}; - -/** - * Structure holding the data of a quaternion. - * - *To keep these networking classes as simple as possible, we do not implement the - * quaternion semantics here. The class just holds four named floats, and you have to interpret them yourself. - * - * If you have Eigen you can just cast this class to an Eigen::Quaternionf and use it. - * - * The quaternion is defined as w+xi+yj+zk - **/ -struct fsQuaternionf { - float x,y,z,w; - - fsQuaternionf() {} -#ifdef HAVE_EIGEN - explicit fsQuaternionf(const Eigen::Quaternionf &q) : x(q.x()), y(q.y()), z(q.z()), w(q.w()) {} - Eigen::Quaternionf eigen() const { return Eigen::Quaternionf(w,x,y,z); } -#endif -}; - -/** - * A structure containing the data tracked for a single frame. - **/ -class fsTrackingData { - public: - //! time stamp in ms - double m_timestamp; - - //! flag whether tracking was successful [0,1] - bool m_trackingSuccessful; - - //! head pose - fsQuaternionf m_headRotation; - fsVector3f m_headTranslation; - - //! eye gaze in degrees - float m_eyeGazeLeftPitch; - float m_eyeGazeLeftYaw; - float m_eyeGazeRightPitch; - float m_eyeGazeRightYaw; - - //! blendshape coefficients - std::vector m_coeffs; - - //! marker positions - format specified in faceshift - std::vector< fsVector3f > m_markers; -}; - -/** - * A structure containing vertex information - */ -class fsVertexData { -public: - //! vertex data - std::vector m_vertices; - -#ifdef HAVE_EIGEN - Eigen::Map > eigen() { return Eigen::Map >((float*)m_vertices.data(),3,m_vertices.size()); } -#endif -}; - -/** - * A strucutre containing mesh information - */ -class fsMeshData { -public: - //! topology (quads) - std::vector m_quads; - - //! topology (triangles) - std::vector m_tris; - - //! vertex data - fsVertexData m_vertex_data; - -#ifdef HAVE_EIGEN - Eigen::Map > quads_eigen() { return Eigen::Map >((int32_t*)m_quads.data(),4,m_quads.size()); } - Eigen::Map > tris_eigen() { return Eigen::Map >((int32_t*)m_tris.data(),3,m_tris.size()); } - Eigen::Map > vertices_eigen() { return m_vertex_data.eigen(); } -#endif - -}; - -/******************************************************************************************* - * Now follows a definition of datastructures encapsulating the network messages - ******************************************************************************************/ - -/** Predeclaration of the message types available in faceshift **/ - -// Inbound -class fsMsgStartCapturing; -class fsMsgStopCapturing; -class fsMsgCalibrateNeutral; -class fsMsgSendMarkerNames; -class fsMsgSendBlendshapeNames; -class fsMsgSendRig; - -// Outbound -class fsMsgTrackingState; -class fsMsgMarkerNames; -class fsMsgBlendshapeNames; -class fsMsgRig; - -/** - * Base class of all message that faceshift is sending. - * A class can be queried for its type, using the id() function for use in a switch statement, or by using a dynamic_cast. - **/ -class fsMsg { -public: - virtual ~fsMsg() {} - - enum MessageType { - // Messages to control faceshift via the network - // These are sent from the client to faceshift - MSG_IN_START_TRACKING = 44344, - MSG_IN_STOP_TRACKING = 44444, - MSG_IN_CALIBRATE_NEUTRAL = 44544, - MSG_IN_SEND_MARKER_NAMES = 44644, - MSG_IN_SEND_BLENDSHAPE_NAMES = 44744, - MSG_IN_SEND_RIG = 44844, - MSG_IN_HEADPOSE_RELATIVE = 44944, - MSG_IN_HEADPOSE_ABSOLUTE = 44945, - - // Messages containing tracking information - // These are sent form faceshift to the client application - MSG_OUT_TRACKING_STATE = 33433, - MSG_OUT_MARKER_NAMES = 33533, - MSG_OUT_BLENDSHAPE_NAMES = 33633, - MSG_OUT_RIG = 33733 - }; - - virtual MessageType id() const = 0; -}; -typedef std::tr1::shared_ptr fsMsgPtr; - - -/************* - * Inbound - ***********/ -class fsMsgStartCapturing : public fsMsg { -public: - virtual ~fsMsgStartCapturing() {} - virtual MessageType id() const { return MSG_IN_START_TRACKING; } -}; -class fsMsgStopCapturing : public fsMsg { -public: - virtual ~fsMsgStopCapturing() {} - virtual MessageType id() const { return MSG_IN_STOP_TRACKING; } -}; -class fsMsgCalibrateNeutral : public fsMsg { -public: - virtual ~fsMsgCalibrateNeutral() {} - virtual MessageType id() const { return MSG_IN_CALIBRATE_NEUTRAL; } -}; -class fsMsgSendMarkerNames : public fsMsg { -public: - virtual ~fsMsgSendMarkerNames() {} - virtual MessageType id() const { return MSG_IN_SEND_MARKER_NAMES; } -}; -class fsMsgSendBlendshapeNames : public fsMsg { -public: - virtual ~fsMsgSendBlendshapeNames() {} - virtual MessageType id() const { return MSG_IN_SEND_BLENDSHAPE_NAMES; } -}; -class fsMsgSendRig : public fsMsg { -public: - virtual ~fsMsgSendRig() {} - virtual MessageType id() const { return MSG_IN_SEND_RIG; } -}; -class fsMsgHeadPoseRelative : public fsMsg { -public: - virtual ~fsMsgHeadPoseRelative() {} - virtual MessageType id() const { return MSG_IN_HEADPOSE_RELATIVE; } -}; -class fsMsgHeadPoseAbsolute : public fsMsg { -public: - virtual ~fsMsgHeadPoseAbsolute() {} - virtual MessageType id() const { return MSG_IN_HEADPOSE_ABSOLUTE; } -}; - -/************* - * Outbound - ***********/ -class fsMsgTrackingState : public fsMsg { -public: - virtual ~fsMsgTrackingState() {} - - /* */ fsTrackingData & tracking_data() /* */ { return m_tracking_data; } - const fsTrackingData & tracking_data() const { return m_tracking_data; } - - virtual MessageType id() const { return MSG_OUT_TRACKING_STATE; } - -private: - fsTrackingData m_tracking_data; -}; -class fsMsgMarkerNames : public fsMsg { -public: - virtual ~fsMsgMarkerNames() {} - - /* */ std::vector & marker_names() /* */ { return m_marker_names; } - const std::vector & marker_names() const { return m_marker_names; } - - virtual MessageType id() const { return MSG_OUT_MARKER_NAMES; } -private: - std::vector m_marker_names; -}; -class fsMsgBlendshapeNames : public fsMsg { -public: - virtual ~fsMsgBlendshapeNames() {} - - /* */ std::vector & blendshape_names() /* */ { return m_blendshape_names; } - const std::vector & blendshape_names() const { return m_blendshape_names; } - - virtual MessageType id() const { return MSG_OUT_BLENDSHAPE_NAMES; } -private: - std::vector m_blendshape_names; -}; -class fsMsgRig : public fsMsg { -public: - virtual ~fsMsgRig() {} - - virtual MessageType id() const { return MSG_OUT_RIG; } - - /* */ fsMeshData & mesh() /* */ { return m_mesh; } - const fsMeshData & mesh() const { return m_mesh; } - - /* */ std::vector & blendshape_names() /* */ { return m_blendshape_names; } - const std::vector & blendshape_names() const { return m_blendshape_names; } - - /* */ std::vector & blendshapes() /* */ { return m_blendshapes; } - const std::vector & blendshapes() const { return m_blendshapes; } - -private: - //! neutral mesh - fsMeshData m_mesh; - //! blendshape names - std::vector m_blendshape_names; - //! blendshapes - std::vector m_blendshapes; -}; -class fsMsgSignal : public fsMsg { - MessageType m_id; -public: - explicit fsMsgSignal(MessageType id) : m_id(id) {} - virtual ~fsMsgSignal() {} - virtual MessageType id() const { return m_id; } -}; - -/** - * Class to parse a faceshift data stream, and to create message to write into such a stream - * - * This needs to be connected with your networking methods by calling - * - * void received(int, const char *); - * - * whenever new data is available. After adding received data to the parser you can parse faceshift messages using the - * - * std::tr1::shared_ptr get_message(); - * - * to get the next message, if a full block of data has been received. This should be iterated until no more messages are in the buffer. - * - * You can also use this to encode messages to send back to faceshift. This works by calling the - * - * void encode_message(std::string &msg_out, const fsMsg &msg); - * - * methods (actually the specializations existing for each of our message types). This will encode the message into a - * binary string in msg_out. You then only need to push the resulting string over the network to faceshift. - * - * This class does not handle differences in endianness or other strange things that can happen when pushing data over the network. - * Should you have to adapt this to such a system, then it should be possible to do this by changing only the write_... and read_... - * functions in the accompanying cpp file, but so far there was no need for it. - **/ -class fsBinaryStream { -public: - fsBinaryStream(); - - /** - * Use to push data into the parser. Typically called inside of your network receiver routine - **/ - void received(long int, const char *); - /** - * After pushing data, you can try to extract messages from the stream. Process messages until a null pointer is returned. - **/ - fsMsgPtr get_message(); - /** - * When an invalid message is received, the valid field is set to false. No attempt is made to recover from the problem, you will have to disconnect. - **/ - bool valid() const { return m_valid; } - void clear() { m_start = 0; m_end = 0; m_valid=true; } - - // Inbound - static void encode_message(std::string &msg_out, const fsMsgTrackingState &msg); - static void encode_message(std::string &msg_out, const fsMsgStartCapturing &msg); - static void encode_message(std::string &msg_out, const fsMsgStopCapturing &msg); - static void encode_message(std::string &msg_out, const fsMsgCalibrateNeutral &msg); - static void encode_message(std::string &msg_out, const fsMsgSendMarkerNames &msg); - static void encode_message(std::string &msg_out, const fsMsgSendBlendshapeNames &msg); - static void encode_message(std::string &msg_out, const fsMsgSendRig &msg); - static void encode_message(std::string &msg_out, const fsMsgHeadPoseRelative &msg); - static void encode_message(std::string &msg_out, const fsMsgHeadPoseAbsolute &msg); - - // Outbound - static void encode_message(std::string &msg_out, const fsTrackingData &msg); - static void encode_message(std::string &msg_out, const fsMsgMarkerNames &msg); - static void encode_message(std::string &msg_out, const fsMsgBlendshapeNames &msg); - static void encode_message(std::string &msg_out, const fsMsgRig &msg); - static void encode_message(std::string &msg_out, const fsMsgSignal &msg); // Generic Signal - -private: - std::string m_buffer; - long int m_start; - long int m_end; - bool m_valid; - -}; - -} - - -#endif // FSBINARYSTREAM_H diff --git a/interface/external/faceshift/lib/MacOS/libfaceshift.a b/interface/external/faceshift/lib/MacOS/libfaceshift.a deleted file mode 100644 index bd9dffa6fb..0000000000 Binary files a/interface/external/faceshift/lib/MacOS/libfaceshift.a and /dev/null differ diff --git a/interface/external/faceshift/lib/UNIX/libfaceshift.a b/interface/external/faceshift/lib/UNIX/libfaceshift.a deleted file mode 100644 index 4d53de7ab5..0000000000 Binary files a/interface/external/faceshift/lib/UNIX/libfaceshift.a and /dev/null differ diff --git a/interface/external/faceshift/readme.txt b/interface/external/faceshift/readme.txt new file mode 100644 index 0000000000..5a7333a9f6 --- /dev/null +++ b/interface/external/faceshift/readme.txt @@ -0,0 +1,21 @@ + +Instructions for adding the Faceshift library to Interface +Stephen Birarda, July 18th, 2014 + +OS X users: You can also use homebrew to get the Faceshift library by tapping our repo - highfidelity/homebrew-formulas +and then calling 'brew install highfidelity/formulas/faceshift'. + +You can download the Faceshift SDK from http://download.faceshift.com/faceshift-network.zip. + +Create a ‘faceshift’ folder under interface/externals. + +You may optionally choose to place this folder in a location outside the repository (so you can re-use with different checkouts and different projects). + +If so our CMake find module expects you to set the ENV variable 'HIFI_LIB_DIR' to a directory containing a subfolder ‘faceshift’ that contains the lib and include folders. + +1. Build a Faceshift static library from the fsbinarystream.cpp file. If you build a release version call it libfaceshift.a. The debug version should be called libfaceshiftd.a. Place this in the ‘lib’ folder in your Faceshift folder. + +2. Copy the fsbinarystream.h header file from the Faceshift SDK into the ‘include’ folder in your Faceshift folder. + +3. Clear your build directory, run cmake and build, and you should be all set. + diff --git a/interface/external/faceshift/src/fsbinarystream.cpp b/interface/external/faceshift/src/fsbinarystream.cpp deleted file mode 100644 index 85f3ac7e7f..0000000000 --- a/interface/external/faceshift/src/fsbinarystream.cpp +++ /dev/null @@ -1,502 +0,0 @@ -// ========================================================================== -// Copyright (C) 2012 faceshift AG, and/or its licensors. All rights reserved. -// -// the software is free to use and provided "as is", without warranty of any kind. -// faceshift AG does not make and hereby disclaims any express or implied -// warranties including, but not limited to, the warranties of -// non-infringement, merchantability or fitness for a particular purpose, -// or arising from a course of dealing, usage, or trade practice. in no -// event will faceshift AG and/or its licensors be liable for any lost -// revenues, data, or profits, or special, direct, indirect, or -// consequential damages, even if faceshift AG and/or its licensors has -// been advised of the possibility or probability of such damages. -// ========================================================================== - -#include "fsbinarystream.h" -#include -#include -#include - -#define FSNETWORKVERSION 1 - -#ifdef FS_INTERNAL -#include -#else -#define LOG_RELEASE_ERROR(...) { printf("ERROR: %20s:%6d", __FILE__, __LINE__); printf(__VA_ARGS__); } -#define LOG_RELEASE_WARNING(...) { printf("WARNING: %20s:%6d", __FILE__, __LINE__); printf(__VA_ARGS__); } -#define LOG_RELEASE_INFO(...) { printf("INFO: %20s:%6d", __FILE__, __LINE__); printf(__VA_ARGS__); } -#endif - - -namespace fs { - -// Ids of the submessages for the tracking state -enum BlockId { - BLOCKID_INFO = 101, - BLOCKID_POSE = 102, - BLOCKID_BLENDSHAPES = 103, - BLOCKID_EYES = 104, - BLOCKID_MARKERS = 105 -}; - - -typedef long int Size; - -struct BlockHeader { - uint16_t id; - uint16_t version; - uint32_t size; - BlockHeader(uint16_t _id=0, - uint32_t _size=0, - uint16_t _version=FSNETWORKVERSION - ) : id(_id), version(_version), size(_size) {} -}; - -// Interprets the data at the position start in buffer as a T and increments start by sizeof(T) -// It should be sufficient to change/overload this function when you are on a wierd endian system -template bool read_pod(T &value, const std::string &buffer, Size &start) { - if(start+sizeof(T) > buffer.size()) return false; - value = *(const T*)(&buffer[start]); - start += sizeof(T); - return true; -} -bool read_pod(std::string &value, const std::string &buffer, Size &start) { - uint16_t len = 0; - if(!read_pod(len, buffer, start)) return false; - if(start+len>Size(buffer.size())) return false; // check whether we have enough data available - value.resize(len); - memcpy(&(value[0]), &buffer[start], len); - start+=len; - return true; -} -template bool read_vector(std::vector & values, const std::string & buffer, Size & start) { - uint32_t len = 0; - if( !read_pod(len, buffer, start)) return false; - if( start+len*sizeof(T) > buffer.size() ) return false; - values.resize(len); - for(uint32_t i = 0; i < len; ++i) { - read_pod(values[i],buffer,start); - } - return true; -} -template bool read_small_vector(std::vector & values, const std::string & buffer, Size & start) { - uint16_t len = 0; - if( !read_pod(len, buffer, start)) return false; - if( start+len*sizeof(T) > buffer.size() ) return false; - values.resize(len); - bool success = true; - for(uint16_t i = 0; i < len; ++i) { - success &= read_pod(values[i],buffer,start); - } - return success; -} - -// Adds the bitpattern of the data to the end of the buffer. -// It should be sufficient to change/overload this function when you are on a wierd endian system -template -void write_pod(std::string &buffer, const T &value) { - Size start = buffer.size(); - buffer.resize(start + sizeof(T)); - *(T*)(&buffer[start]) = value; - start += sizeof(T); -} -// special write function for strings -void write_pod(std::string &buffer, const std::string &value) { - uint16_t len = uint16_t(value.size()); write_pod(buffer, len); - buffer.append(value); -} -template void write_vector(std::string & buffer, const std::vector & values) { - uint32_t len = values.size(); - write_pod(buffer,len); - for(uint32_t i = 0; i < len; ++i) - write_pod(buffer,values[i]); -} -template void write_small_vector(std::string & buffer, const std::vector & values) { - uint16_t len = values.size(); - write_pod(buffer,len); - for(uint16_t i = 0; i < len; ++i) - write_pod(buffer,values[i]); -} -void update_msg_size(std::string &buffer, Size start) { - *(uint32_t*)(&buffer[start+4]) = buffer.size() - sizeof(BlockHeader) - start; -} -void update_msg_size(std::string &buffer) { - *(uint32_t*)(&buffer[4]) = buffer.size() - sizeof(BlockHeader); -} - -static void skipHeader( Size &start) { - start += sizeof(BlockHeader); -} - -//! returns whether @param data contains enough data to read the block header -static bool headerAvailable(BlockHeader &header, const std::string &buffer, Size &start, const Size &end) { - if (end-start >= Size(sizeof(BlockHeader))) { - header = *(BlockHeader*)(&buffer[start]); - return true; - } else { - return false; - } -} - -//! returns whether @param data contains data for a full block -static bool blockAvailable(const std::string &buffer, Size &start, const Size &end) { - BlockHeader header; - if (!headerAvailable(header, buffer, start, end)) return false; - return end-start >= Size(sizeof(header)+header.size); -} - -fsBinaryStream::fsBinaryStream() : m_buffer(), m_start(0), m_end(0), m_valid(true) { m_buffer.resize(64*1024); } // Use a 64kb buffer by default - -void fsBinaryStream::received(long int sz, const char *data) { - - long int new_end = m_end + sz; - if (new_end > Size(m_buffer.size()) && m_start>0) { - // If newly received block is too large to fit into the buffer, but we already have processed data from the start of the buffer, then - // move memory to the front of the buffer - // The buffer only grows, such that it is always large enough to contain the largest message seen so far. - if (m_end>m_start) memmove(&m_buffer[0], &m_buffer[0] + m_start, m_end - m_start); - m_end = m_end - m_start; - m_start = 0; - new_end = m_end + sz; - } - - if (new_end > Size(m_buffer.size())) m_buffer.resize((int)(1.5f * (float)new_end)); // HIFI: to get 1.5 without warnings - - memcpy(&m_buffer[0] + m_end, data, sz); - m_end += sz; - -} - -static bool decodeInfo(fsTrackingData & _trackingData, const std::string &buffer, Size &start) { - bool success = true; - success &= read_pod(_trackingData.m_timestamp, buffer, start); - unsigned char tracking_successfull = 0; - success &= read_pod( tracking_successfull, buffer, start ); - _trackingData.m_trackingSuccessful = bool(tracking_successfull != 0); // HIFI: get rid of windows warning - return success; -} - -static bool decodePose(fsTrackingData & _trackingData, const std::string &buffer, Size &start) { - bool success = true; - success &= read_pod(_trackingData.m_headRotation.x, buffer, start); - success &= read_pod(_trackingData.m_headRotation.y, buffer, start); - success &= read_pod(_trackingData.m_headRotation.z, buffer, start); - success &= read_pod(_trackingData.m_headRotation.w, buffer, start); - success &= read_pod(_trackingData.m_headTranslation.x, buffer, start); - success &= read_pod(_trackingData.m_headTranslation.y, buffer, start); - success &= read_pod(_trackingData.m_headTranslation.z, buffer, start); - return success; -} - -static bool decodeBlendshapes(fsTrackingData & _trackingData, const std::string &buffer, Size &start) { - return read_vector(_trackingData.m_coeffs, buffer, start); -} - -static bool decodeEyeGaze(fsTrackingData & _trackingData, const std::string &buffer, Size &start) { - bool success = true; - success &= read_pod(_trackingData.m_eyeGazeLeftPitch , buffer, start); - success &= read_pod(_trackingData.m_eyeGazeLeftYaw , buffer, start); - success &= read_pod(_trackingData.m_eyeGazeRightPitch, buffer, start); - success &= read_pod(_trackingData.m_eyeGazeRightYaw , buffer, start); - return success; -} - -static bool decodeMarkers(fsTrackingData & _trackingData, const std::string &buffer, Size &start) { - return read_small_vector( _trackingData.m_markers, buffer, start ); -} - -static bool decodeMarkerNames(fsMsgMarkerNames &_msg, const std::string &buffer, Size &start) { - return read_small_vector(_msg.marker_names(), buffer, start); -} -static bool decodeBlendshapeNames(fsMsgBlendshapeNames &_msg, const std::string &buffer, Size &start) { - return read_small_vector(_msg.blendshape_names(), buffer, start); -} -static bool decodeRig(fsMsgRig &_msg, const std::string &buffer, Size &start) { - bool success = true; - success &= read_vector(_msg.mesh().m_quads,buffer,start); // read quads - success &= read_vector(_msg.mesh().m_tris,buffer,start); // read triangles - success &= read_vector(_msg.mesh().m_vertex_data.m_vertices,buffer,start);// read neutral vertices - success &= read_small_vector(_msg.blendshape_names(),buffer,start); // read names - uint16_t bsize = 0; - success &= read_pod(bsize,buffer,start); - _msg.blendshapes().resize(bsize); - for(uint16_t i = 0;i < bsize; i++) - success &= read_vector(_msg.blendshapes()[i].m_vertices,buffer,start); // read blendshapes - return success; -} - -bool is_valid_msg(int id) { - switch(id) { - case fsMsg::MSG_IN_START_TRACKING : - case fsMsg::MSG_IN_STOP_TRACKING : - case fsMsg::MSG_IN_CALIBRATE_NEUTRAL : - case fsMsg::MSG_IN_SEND_MARKER_NAMES : - case fsMsg::MSG_IN_SEND_BLENDSHAPE_NAMES: - case fsMsg::MSG_IN_SEND_RIG : - case fsMsg::MSG_IN_HEADPOSE_RELATIVE : - case fsMsg::MSG_IN_HEADPOSE_ABSOLUTE : - case fsMsg::MSG_OUT_TRACKING_STATE : - case fsMsg::MSG_OUT_MARKER_NAMES : - case fsMsg::MSG_OUT_BLENDSHAPE_NAMES : - case fsMsg::MSG_OUT_RIG : return true; - default: - LOG_RELEASE_ERROR("Invalid Message ID %d", id); - return false; - } -} - -fsMsgPtr fsBinaryStream::get_message() { - BlockHeader super_block; - if( !headerAvailable(super_block, m_buffer, m_start, m_end) ) return fsMsgPtr(); - if (!is_valid_msg(super_block.id)) { LOG_RELEASE_ERROR("Invalid superblock id"); m_valid = false; return fsMsgPtr(); } - if( !blockAvailable( m_buffer, m_start, m_end) ) return fsMsgPtr(); - skipHeader(m_start); - long super_block_data_start = m_start; - switch (super_block.id) { - case fsMsg::MSG_IN_START_TRACKING: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgStartCapturing() ); - }; break; - case fsMsg::MSG_IN_STOP_TRACKING: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgStopCapturing() ); - }; break; - case fsMsg::MSG_IN_CALIBRATE_NEUTRAL: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgCalibrateNeutral() ); - }; break; - case fsMsg::MSG_IN_SEND_MARKER_NAMES: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgSendMarkerNames() ); - }; break; - case fsMsg::MSG_IN_SEND_BLENDSHAPE_NAMES: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgSendBlendshapeNames() ); - }; break; - case fsMsg::MSG_IN_SEND_RIG: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgSendRig() ); - }; break; - case fsMsg::MSG_IN_HEADPOSE_RELATIVE: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgHeadPoseRelative() ); - }; break; - case fsMsg::MSG_IN_HEADPOSE_ABSOLUTE: { - if (super_block.size > 0) { LOG_RELEASE_ERROR("Expected Size to be 0, not %d", super_block.size); m_valid = false; return fsMsgPtr(); } - return fsMsgPtr(new fsMsgHeadPoseAbsolute() ); - }; break; - case fsMsg::MSG_OUT_MARKER_NAMES: { - std::tr1::shared_ptr< fsMsgMarkerNames > msg(new fsMsgMarkerNames()); - if( !decodeMarkerNames(*msg, m_buffer, m_start )) { LOG_RELEASE_ERROR("Could not decode marker names"); m_valid = false; return fsMsgPtr(); } - uint64_t actual_size = m_start-super_block_data_start; - if( actual_size != super_block.size ) { LOG_RELEASE_ERROR("Block was promised to be of size %d, not %d", super_block.size, actual_size); m_valid = false; return fsMsgPtr(); } - return msg; - }; break; - case fsMsg::MSG_OUT_BLENDSHAPE_NAMES: { - std::tr1::shared_ptr< fsMsgBlendshapeNames > msg(new fsMsgBlendshapeNames() ); - if( !decodeBlendshapeNames(*msg, m_buffer, m_start) ) { LOG_RELEASE_ERROR("Could not decode blendshape names"); m_valid = false; return fsMsgPtr(); } - uint64_t actual_size = m_start-super_block_data_start; - if( actual_size != super_block.size ) { LOG_RELEASE_ERROR("Block was promised to be of size %d, not %d", super_block.size, actual_size); m_valid = false; return fsMsgPtr(); } - return msg; - }; break; - case fsMsg::MSG_OUT_TRACKING_STATE: { - BlockHeader sub_block; - uint16_t num_blocks = 0; - if( !read_pod(num_blocks, m_buffer, m_start) ) { LOG_RELEASE_ERROR("Could not read num_blocks"); m_valid = false; return fsMsgPtr(); } - std::tr1::shared_ptr msg = std::tr1::shared_ptr(new fsMsgTrackingState()); - for(int i = 0; i < num_blocks; i++) { - if( !headerAvailable(sub_block, m_buffer, m_start, m_end) ) { LOG_RELEASE_ERROR("could not read sub-header %d", i); m_valid = false; return fsMsgPtr(); } - if( !blockAvailable( m_buffer, m_start, m_end) ) { LOG_RELEASE_ERROR("could not read sub-block %d", i); m_valid = false; return fsMsgPtr(); } - skipHeader(m_start); - long sub_block_data_start = m_start; - bool success = true; - switch(sub_block.id) { - case BLOCKID_INFO: success &= decodeInfo( msg->tracking_data(), m_buffer, m_start); break; - case BLOCKID_POSE: success &= decodePose( msg->tracking_data(), m_buffer, m_start); break; - case BLOCKID_BLENDSHAPES: success &= decodeBlendshapes(msg->tracking_data(), m_buffer, m_start); break; - case BLOCKID_EYES: success &= decodeEyeGaze( msg->tracking_data(), m_buffer, m_start); break; - case BLOCKID_MARKERS: success &= decodeMarkers( msg->tracking_data(), m_buffer, m_start); break; - default: - LOG_RELEASE_ERROR("Unexpected subblock id %d", sub_block.id); - m_valid = false; return msg; - break; - } - if(!success) { - LOG_RELEASE_ERROR("Could not decode subblock with id %d", sub_block.id); - m_valid = false; return fsMsgPtr(); - } - uint64_t actual_size = m_start-sub_block_data_start; - if( actual_size != sub_block.size ) { - LOG_RELEASE_ERROR("Unexpected number of bytes consumed %d instead of %d for subblock %d id:%d", actual_size, sub_block.size, i, sub_block.id); - m_valid = false; return fsMsgPtr(); - } - } - uint64_t actual_size = m_start-super_block_data_start; - if( actual_size != super_block.size ) { - LOG_RELEASE_ERROR("Unexpected number of bytes consumed %d instead of %d", actual_size, super_block.size); - m_valid = false; return fsMsgPtr(); - } - return msg; - }; break; - case fsMsg::MSG_OUT_RIG: { - std::tr1::shared_ptr< fsMsgRig > msg(new fsMsgRig() ); - if( !decodeRig(*msg, m_buffer, m_start) ) { LOG_RELEASE_ERROR("Could not decode rig"); m_valid = false; return fsMsgPtr(); } - if( m_start-super_block_data_start != super_block.size ) { LOG_RELEASE_ERROR("Could not decode rig unexpected size"); m_valid = false; return fsMsgPtr(); } - return msg; - }; break; - default: { - LOG_RELEASE_ERROR("Unexpected superblock id %d", super_block.id); - m_valid = false; return fsMsgPtr(); - }; break; - } - return fsMsgPtr(); -} - -static void encodeInfo(std::string &buffer, const fsTrackingData & _trackingData) { - BlockHeader header(BLOCKID_INFO, sizeof(double) + 1); - write_pod(buffer, header); - - write_pod(buffer, _trackingData.m_timestamp); - unsigned char tracking_successfull = _trackingData.m_trackingSuccessful; - write_pod( buffer, tracking_successfull ); -} - -static void encodePose(std::string &buffer, const fsTrackingData & _trackingData) { - BlockHeader header(BLOCKID_POSE, sizeof(float)*7); - write_pod(buffer, header); - - write_pod(buffer, _trackingData.m_headRotation.x); - write_pod(buffer, _trackingData.m_headRotation.y); - write_pod(buffer, _trackingData.m_headRotation.z); - write_pod(buffer, _trackingData.m_headRotation.w); - write_pod(buffer, _trackingData.m_headTranslation.x); - write_pod(buffer, _trackingData.m_headTranslation.y); - write_pod(buffer, _trackingData.m_headTranslation.z); -} - -static void encodeBlendshapes(std::string &buffer, const fsTrackingData & _trackingData) { - uint32_t num_parameters = _trackingData.m_coeffs.size(); - BlockHeader header(BLOCKID_BLENDSHAPES, sizeof(uint32_t) + sizeof(float)*num_parameters); - write_pod(buffer, header); - write_pod(buffer, num_parameters); - for(uint32_t i = 0; i < num_parameters; i++) - write_pod(buffer, _trackingData.m_coeffs[i]); -} - -static void encodeEyeGaze(std::string &buffer, const fsTrackingData & _trackingData) { - BlockHeader header(BLOCKID_EYES, sizeof(float)*4); - write_pod(buffer, header); - write_pod(buffer, _trackingData.m_eyeGazeLeftPitch ); - write_pod(buffer, _trackingData.m_eyeGazeLeftYaw ); - write_pod(buffer, _trackingData.m_eyeGazeRightPitch); - write_pod(buffer, _trackingData.m_eyeGazeRightYaw ); -} - -static void encodeMarkers(std::string &buffer, const fsTrackingData & _trackingData) { - uint16_t numMarkers = _trackingData.m_markers.size(); - BlockHeader header(BLOCKID_MARKERS, sizeof(uint16_t) + sizeof(float)*3*numMarkers); - write_pod(buffer, header); - write_pod(buffer, numMarkers); - for(int i = 0; i < numMarkers; i++) { - write_pod(buffer, _trackingData.m_markers[i].x); - write_pod(buffer, _trackingData.m_markers[i].y); - write_pod(buffer, _trackingData.m_markers[i].z); - } -} - -// Inbound -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgTrackingState &msg) { - encode_message(msg_out, msg.tracking_data()); -} - -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgStartCapturing &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgStopCapturing &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgCalibrateNeutral &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSendMarkerNames &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSendBlendshapeNames &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSendRig &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgHeadPoseRelative &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgHeadPoseAbsolute &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} - -// Outbound -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgSignal &msg) { - BlockHeader header(msg.id()); - write_pod(msg_out, header); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsTrackingData &tracking_data) { - Size start = msg_out.size(); - - BlockHeader header(fsMsg::MSG_OUT_TRACKING_STATE); - write_pod(msg_out, header); - - uint16_t N_blocks = 5; - write_pod(msg_out, N_blocks); - encodeInfo( msg_out, tracking_data); - encodePose( msg_out, tracking_data); - encodeBlendshapes(msg_out, tracking_data); - encodeEyeGaze( msg_out, tracking_data); - encodeMarkers( msg_out, tracking_data); - - update_msg_size(msg_out, start); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgMarkerNames &msg) { - Size start = msg_out.size(); - - BlockHeader header(msg.id()); - write_pod(msg_out, header); - - write_small_vector(msg_out,msg.marker_names()); - - update_msg_size(msg_out, start); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgBlendshapeNames &msg) { - Size start = msg_out.size(); - - BlockHeader header(msg.id()); - write_pod(msg_out, header); - - write_small_vector(msg_out,msg.blendshape_names()); - - update_msg_size(msg_out, start); -} -void fsBinaryStream::encode_message(std::string &msg_out, const fsMsgRig &msg) { - Size start = msg_out.size(); - - BlockHeader header(msg.id()); - write_pod(msg_out, header); - - write_vector(msg_out, msg.mesh().m_quads); // write quads - write_vector(msg_out, msg.mesh().m_tris);// write triangles - write_vector(msg_out, msg.mesh().m_vertex_data.m_vertices);// write neutral vertices - write_small_vector(msg_out, msg.blendshape_names());// write names - write_pod(msg_out,uint16_t(msg.blendshapes().size())); - for(uint16_t i = 0;i < uint16_t(msg.blendshapes().size()); i++) - write_vector(msg_out, msg.blendshapes()[i].m_vertices); // write blendshapes - - update_msg_size(msg_out, start); -} -} diff --git a/interface/src/devices/Faceshift.cpp b/interface/src/devices/Faceshift.cpp index a7d50814e2..9b2fc7e821 100644 --- a/interface/src/devices/Faceshift.cpp +++ b/interface/src/devices/Faceshift.cpp @@ -19,11 +19,16 @@ #include "Menu.h" #include "Util.h" +#ifdef HAVE_FACESHIFT using namespace fs; +#endif + using namespace std; const quint16 FACESHIFT_PORT = 33433; +#ifdef HAVE_FACESHIFT + Faceshift::Faceshift() : _tcpEnabled(true), _tcpRetryCount(0), @@ -58,18 +63,30 @@ Faceshift::Faceshift() : _udpSocket.bind(FACESHIFT_PORT); } +#else + +Faceshift::Faceshift() { + +} + +#endif + void Faceshift::init() { setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift)); } bool Faceshift::isConnectedOrConnecting() const { return _tcpSocket.state() == QAbstractSocket::ConnectedState || - (_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState); + (_tcpRetryCount == 0 && _tcpSocket.state() != QAbstractSocket::UnconnectedState); } bool Faceshift::isActive() const { +#ifdef HAVE_FACESHIFT const quint64 ACTIVE_TIMEOUT_USECS = 1000000; return (usecTimestampNow() - _lastTrackingStateReceived) < ACTIVE_TIMEOUT_USECS; +#else + return false; +#endif } void Faceshift::update() { @@ -97,12 +114,14 @@ void Faceshift::update() { } void Faceshift::reset() { +#ifdef HAVE_FACESHIFT if (_tcpSocket.state() == QAbstractSocket::ConnectedState) { string message; fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral()); send(message); } _longTermAverageInitialized = false; +#endif } void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp, @@ -138,11 +157,13 @@ void Faceshift::connectSocket() { } void Faceshift::noteConnected() { +#ifdef HAVE_FACESHIFT qDebug("Faceshift: Connected."); // request the list of blendshape names string message; fsBinaryStream::encode_message(message, fsMsgSendBlendshapeNames()); send(message); +#endif } void Faceshift::noteError(QAbstractSocket::SocketError error) { @@ -179,6 +200,7 @@ void Faceshift::send(const std::string& message) { } void Faceshift::receive(const QByteArray& buffer) { +#ifdef HAVE_FACESHIFT _stream.received(buffer.size(), buffer.constData()); fsMsgPtr msg; for (fsMsgPtr msg; (msg = _stream.get_message()); ) { @@ -259,4 +281,5 @@ void Faceshift::receive(const QByteArray& buffer) { break; } } +#endif } diff --git a/interface/src/devices/Faceshift.h b/interface/src/devices/Faceshift.h index 2fc1aaddb1..c14bbed600 100644 --- a/interface/src/devices/Faceshift.h +++ b/interface/src/devices/Faceshift.h @@ -15,8 +15,12 @@ #include #include +#ifdef HAVE_FACESHIFT + #include +#endif + #include "FaceTracker.h" /// Handles interaction with the Faceshift software, which provides head position/orientation and facial features. @@ -24,7 +28,6 @@ class Faceshift : public FaceTracker { Q_OBJECT public: - Faceshift(); void init(); @@ -88,7 +91,11 @@ private: QTcpSocket _tcpSocket; QUdpSocket _udpSocket; + +#ifdef HAVE_FACESHIFT fs::fsBinaryStream _stream; +#endif + bool _tcpEnabled; int _tcpRetryCount; bool _tracking; @@ -123,6 +130,7 @@ private: float _longTermAverageEyePitch; float _longTermAverageEyeYaw; bool _longTermAverageInitialized; + }; #endif // hifi_Faceshift_h diff --git a/interface/src/devices/OculusManager.h b/interface/src/devices/OculusManager.h index db7a6e3f59..466b8c893a 100644 --- a/interface/src/devices/OculusManager.h +++ b/interface/src/devices/OculusManager.h @@ -15,7 +15,7 @@ #ifdef HAVE_LIBOVR #include -#include "../src/Util/Util_Render_Stereo.h" +#include #endif #include "renderer/ProgramObject.h"