standardization of hints used to find external libraries
Unified · Split
| @@ -0,0 +1,27 @@ | |||
| 1 | # | ||
| 2 | # HifiLibrarySearchHints.cmake | ||
| 3 | # | ||
| 4 | # Created by Stephen Birarda on July 24th, 2014 | ||
| 5 | # Copyright 2014 High Fidelity, Inc. | ||
| 6 | # | ||
| 7 | # Distributed under the Apache License, Version 2.0. | ||
| 8 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
| 9 | # | ||
| 10 | |||
| 11 | macro(HIFI_LIBRARY_SEARCH_HINTS LIBRARY_FOLDER) | ||
| 12 | string(TOUPPER ${LIBRARY_FOLDER} LIBRARY_PREFIX) | ||
| 13 | set(${LIBRARY_PREFIX}_SEARCH_DIRS "") | ||
| 14 | |||
| 15 | if (${LIBRARY_PREFIX}_ROOT_DIR) | ||
| 16 | set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}") | ||
| 17 | endif () | ||
| 18 | |||
| 19 | if (DEFINED ENV{${LIBRARY_PREFIX}_ROOT_DIR}) | ||
| 20 | set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}") | ||
| 21 | endif () | ||
| 22 | |||
| 23 | if (DEFINED ENV{HIFI_LIB_DIR}) | ||
| 24 | set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}") | ||
| 25 | endif () | ||
| 26 | |||
| 27 | endmacro(HIFI_LIBRARY_SEARCH_HINTS _library_folder) | ||
| @@ -18,7 +18,8 @@ · 17 unmodified lines | |||
| 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | set(FACESHIFT_SEARCH_DIRS "${FACESHIFT_ROOT_DIR}" "$ENV{FACESHIFT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/faceshift") | 21 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 22 | hifi_library_search_hints("faceshift") | ||
| 22 | 23 | ||
| 23 | find_path(FACESHIFT_INCLUDE_DIRS fsbinarystream.h PATH_SUFFIXES include HINTS ${FACESHIFT_SEARCH_DIRS}) | 24 | find_path(FACESHIFT_INCLUDE_DIRS fsbinarystream.h PATH_SUFFIXES include HINTS ${FACESHIFT_SEARCH_DIRS}) |
| 24 | 25 | ||
| @@ -41,4 +42,4 @@ set(FACESHIFT_LIBRARIES ${FACESHIFT_LIBRARY}) · 16 unmodified lines | |||
| 41 | include(FindPackageHandleStandardArgs) | 42 | include(FindPackageHandleStandardArgs) |
| 42 | find_package_handle_standard_args(FACESHIFT DEFAULT_MSG FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) | 43 | find_package_handle_standard_args(FACESHIFT DEFAULT_MSG FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) |
| 43 | 44 | ||
| 44 | mark_as_advanced(FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES) | 45 | mark_as_advanced(FACESHIFT_INCLUDE_DIRS FACESHIFT_LIBRARIES FACESHIFT_SEARCH_DIRS) |
| @@ -19,12 +19,13 @@ · 18 unmodified lines | |||
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | if (WIN32) | 21 | if (WIN32) |
| 22 | set(WIN_GLEW_SEARCH_DIRS "${GLEW_ROOT_DIR}" "$ENV{GLEW_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glew") | 22 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 23 | hifi_library_search_hints("glew") | ||
| 23 | 24 | ||
| 24 | find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS}) | 25 | find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${GLEW_SEARCH_DIRS}) |
| 25 | 26 | ||
| 26 | find_library(GLEW_LIBRARY_RELEASE glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS}) | 27 | find_library(GLEW_LIBRARY_RELEASE glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS}) |
| 27 | find_library(GLEW_LIBRARY_DEBUG glew32s PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${WIN_GLEW_SEARCH_DIRS}) | 28 | find_library(GLEW_LIBRARY_DEBUG glew32s PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS}) |
| 28 | 29 | ||
| 29 | include(SelectLibraryConfigurations) | 30 | include(SelectLibraryConfigurations) |
| 30 | select_library_configurations(GLEW) | 31 | select_library_configurations(GLEW) |
| @@ -35,4 +36,4 @@ set(GLEW_LIBRARIES "${GLEW_LIBRARY}") · 4 unmodified lines | |||
| 35 | include(FindPackageHandleStandardArgs) | 36 | include(FindPackageHandleStandardArgs) |
| 36 | find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES) | 37 | find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES) |
| 37 | 38 | ||
| 38 | mark_as_advanced(GLEW_INCLUDE_DIRS GLEW_LIBRARIES) | 39 | mark_as_advanced(GLEW_INCLUDE_DIRS GLEW_LIBRARIES GLEW_SEARCH_DIRS) |
| @@ -14,13 +14,14 @@ · 13 unmodified lines | |||
| 14 | # | 14 | # |
| 15 | 15 | ||
| 16 | # setup hints for GLM search | 16 | # setup hints for GLM search |
| 17 | set(GLM_HEADER_SEARCH_HINTS "${GLM_ROOT_DIR}" "$ENV{GLM_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glm") | 17 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 18 | hifi_library_search_hints("glm") | ||
| 18 | 19 | ||
| 19 | # locate header | 20 | # locate header |
| 20 | find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_HEADER_SEARCH_HINTS}) | 21 | find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS}) |
| 21 | set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") | 22 | set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") |
| 22 | 23 | ||
| 23 | include(FindPackageHandleStandardArgs) | 24 | include(FindPackageHandleStandardArgs) |
| 24 | find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS) | 25 | find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS) |
| 25 | 26 | ||
| 26 | mark_as_advanced(GLM_INCLUDE_DIRS) | 27 | mark_as_advanced(GLM_INCLUDE_DIRS GLM_SEARCH_DIRS) |
| @@ -18,16 +18,17 @@ · 17 unmodified lines | |||
| 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | set(GLUT_HINT_DIRS "${GLUT_ROOT_DIR}" "$ENV{GLUT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/freeglut") | 21 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 22 | hifi_library_search_hints("freeglut") | ||
| 22 | 23 | ||
| 23 | if (WIN32) | 24 | if (WIN32) |
| 24 | set(GLUT_HINT_DIRS "${GLUT_HINT_DIRS}" "${OPENGL_INCLUDE_DIR}") | 25 | set(GLUT_HINT_DIRS "${FREEGLUT_SEARCH_DIRS} ${OPENGL_INCLUDE_DIR}") |
| 25 | 26 | ||
| 26 | find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${GLUT_HINT_DIRS}) | 27 | find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${FREEGLUT_SEARCH_DIRS}) |
| 27 | find_library(GLUT_LIBRARY freeglut PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) | 28 | find_library(GLUT_LIBRARY freeglut PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS}) |
| 28 | else () | 29 | else () |
| 29 | find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${GLUT_HINT_DIRS}) | 30 | find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${FREEGLUT_SEARCH_DIRS}) |
| 30 | find_library(GLUT_LIBRARY glut PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) | 31 | find_library(GLUT_LIBRARY glut PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS}) |
| 31 | endif () | 32 | endif () |
| 32 | 33 | ||
| 33 | include(FindPackageHandleStandardArgs) | 34 | include(FindPackageHandleStandardArgs) |
| @@ -35,12 +36,12 @@ include(FindPackageHandleStandardArgs) · 1 unmodified line | |||
| 35 | set(GLUT_LIBRARIES "${GLUT_LIBRARY}" "${XMU_LIBRARY}" "${XI_LIBRARY}") | 36 | set(GLUT_LIBRARIES "${GLUT_LIBRARY}" "${XMU_LIBRARY}" "${XI_LIBRARY}") |
| 36 | 37 | ||
| 37 | if (UNIX) | 38 | if (UNIX) |
| 38 | find_library(XI_LIBRARY Xi PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) | 39 | find_library(XI_LIBRARY Xi PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS}) |
| 39 | find_library(XMU_LIBRARY Xmu PATH_SUFFIXES lib HINTS ${GLUT_HINT_DIRS}) | 40 | find_library(XMU_LIBRARY Xmu PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS}) |
| 40 | 41 | ||
| 41 | find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES XI_LIBRARY XMU_LIBRARY) | 42 | find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES XI_LIBRARY XMU_LIBRARY) |
| 42 | else () | 43 | else () |
| 43 | find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES) | 44 | find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES) |
| 44 | endif () | 45 | endif () |
| 45 | 46 | ||
| 46 | mark_as_advanced(GLUT_INCLUDE_DIRS GLUT_LIBRARIES GLUT_LIBRARY XI_LIBRARY XMU_LIBRARY) | 47 | mark_as_advanced(GLUT_INCLUDE_DIRS GLUT_LIBRARIES GLUT_LIBRARY XI_LIBRARY XMU_LIBRARY FREEGLUT_SEARCH_DIRS) |
| @@ -12,24 +12,24 @@ · 11 unmodified lines | |||
| 12 | # Copyright (c) 2014 High Fidelity | 12 | # Copyright (c) 2014 High Fidelity |
| 13 | # | 13 | # |
| 14 | 14 | ||
| 15 | set(LEAPMOTION_SEARCH_DIRS "${LEAPMOTION_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/leapmotion") | 15 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 16 | hifi_library_search_hints("leapmotion") | ||
| 16 | 17 | ||
| 17 | find_path(LEAPMOTION_INCLUDE_DIRS Leap.h PATH_SUFFIXES include HINTS ${LEAPMOTION_SEARCH_DIRS}) | 18 | find_path(LEAPMOTION_INCLUDE_DIRS Leap.h PATH_SUFFIXES include HINTS ${LEAPMOTION_SEARCH_DIRS}) |
| 18 | 19 | ||
| 19 | if (WIN32) | 20 | if (WIN32) |
| 20 | find_library(LEAPMOTION_LIBRARY_DEBUG "lib/x86/Leapd.lib" HINTS ${LEAPMOTION_SEARCH_DIRS}) | 21 | find_library(LEAPMOTION_LIBRARY_DEBUG Leapd PATH_SUFFIXES lib/x86 HINTS ${LEAPMOTION_SEARCH_DIRS}) |
| 21 | find_library(LEAPMOTION_LIBRARY_RELEASE "lib/x86/Leap.lib" HINTS ${LEAPMOTION_SEARCH_DIRS}) | 22 | find_library(LEAPMOTION_LIBRARY_RELEASE Leap PATH_SUFFIXES lib/x86 HINTS ${LEAPMOTION_SEARCH_DIRS}) |
| 22 | endif (WIN32) | 23 | elseif (APPLE) |
| 23 | if (APPLE) | 24 | find_library(LEAPMOTION_LIBRARY_RELEASE Leap PATH_SUFFIXES lib HINTS ${LEAPMOTION_SEARCH_DIRS}) |
| 24 | find_library(LEAPMOTION_LIBRARY_RELEASE "lib/libLeap.dylib" HINTS ${LEAPMOTION_SEARCH_DIRS}) | 25 | endif () |
| 25 | endif (APPLE) | ||
| 26 | 26 | ||
| 27 | include(SelectLibraryConfigurations) | 27 | include(SelectLibraryConfigurations) |
| 28 | select_library_configurations(LEAPMOTION) | 28 | select_library_configurations(LEAPMOTION) |
| 29 | 29 | ||
| 30 | set(LEAPMOTION_LIBRARIES "${LEAPMOTION_LIBARIES}") | 30 | set(LEAPMOTION_LIBRARIES "${LEAPMOTION_LIBRARY}") |
| 31 | 31 | ||
| 32 | include(FindPackageHandleStandardArgs) | 32 | include(FindPackageHandleStandardArgs) |
| 33 | find_package_handle_standard_args(LEAPMOTION DEFAULT_MSG LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) | 33 | find_package_handle_standard_args(LEAPMOTION DEFAULT_MSG LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) |
| 34 | 34 | ||
| 35 | mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) | 35 | mark_as_advanced(LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES LEAPMOTION_SEARCH_DIRS) |
| @@ -18,10 +18,11 @@ · 17 unmodified lines | |||
| 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | set(LIBOVR_SEARCH_DIRS "${LIBOVR_ROOT_DIR}" "$ENV{LIBOVR_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/oculus") | 21 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 22 | hifi_library_search_hints("oculus") | ||
| 22 | 23 | ||
| 23 | find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${LIBOVR_SEARCH_DIRS}) | 24 | find_path(LIBOVR_INCLUDE_DIRS OVR.h PATH_SUFFIXES Include HINTS ${OCULUS_SEARCH_DIRS}) |
| 24 | find_path(LIBOVR_UTIL_INCLUDE_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${LIBOVR_SEARCH_DIRS}) | 25 | find_path(LIBOVR_UTIL_INCLUDE_DIR Util_Render_Stereo.h PATH_SUFFIXES Src/Util HINTS ${OCULUS_SEARCH_DIRS}) |
| 25 | 26 | ||
| 26 | # add the util include dir to the general include dirs | 27 | # add the util include dir to the general include dirs |
| 27 | set(LIBOVR_INCLUDE_DIRS "${LIBOVR_INCLUDE_DIRS}" "${LIBOVR_UTIL_INCLUDE_DIR}") | 28 | set(LIBOVR_INCLUDE_DIRS "${LIBOVR_INCLUDE_DIRS}" "${LIBOVR_UTIL_INCLUDE_DIR}") |
| @@ -29,8 +30,8 @@ set(LIBOVR_INCLUDE_DIRS "${LIBOVR_INCLUDE_DIRS}" "${LIBOVR_UTIL_INCLUDE_DIR}") · 1 unmodified line | |||
| 29 | include(SelectLibraryConfigurations) | 30 | include(SelectLibraryConfigurations) |
| 30 | 31 | ||
| 31 | if (APPLE) | 32 | if (APPLE) |
| 32 | find_library(LIBOVR_LIBRARY_DEBUG "Lib/MacOS/Debug/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) | 33 | find_library(LIBOVR_LIBRARY_DEBUG "Lib/MacOS/Debug/libovr.a" HINTS ${OCULUS_SEARCH_DIRS}) |
| 33 | find_library(LIBOVR_LIBRARY_RELEASE "Lib/MacOS/Release/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) | 34 | find_library(LIBOVR_LIBRARY_RELEASE "Lib/MacOS/Release/libovr.a" HINTS ${OCULUS_SEARCH_DIRS}) |
| 34 | elseif (UNIX) | 35 | elseif (UNIX) |
| 35 | find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/) | 36 | find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/) |
| 36 | find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/) | 37 | find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/) |
| @@ -41,15 +42,15 @@ elseif (UNIX) · 4 unmodified lines | |||
| 41 | set(LINUX_ARCH_DIR "x86_64") | 42 | set(LINUX_ARCH_DIR "x86_64") |
| 42 | endif() | 43 | endif() |
| 43 | 44 | ||
| 44 | find_library(LIBOVR_LIBRARY_DEBUG "Lib/Linux/Debug/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) | 45 | find_library(LIBOVR_LIBRARY_DEBUG "Lib/Linux/Debug/${LINUX_ARCH_DIR}/libovr.a" HINTS ${OCULUS_SEARCH_DIRS}) |
| 45 | find_library(LIBOVR_LIBRARY_RELEASE "Lib/Linux/Release/${LINUX_ARCH_DIR}/libovr.a" HINTS ${LIBOVR_SEARCH_DIRS}) | 46 | find_library(LIBOVR_LIBRARY_RELEASE "Lib/Linux/Release/${LINUX_ARCH_DIR}/libovr.a" HINTS ${OCULUS_SEARCH_DIRS}) |
| 46 | 47 | ||
| 47 | select_library_configurations(UDEV) | 48 | select_library_configurations(UDEV) |
| 48 | select_library_configurations(XINERAMA) | 49 | select_library_configurations(XINERAMA) |
| 49 | 50 | ||
| 50 | elseif (WIN32) | 51 | elseif (WIN32) |
| 51 | find_library(LIBOVR_LIBRARY_DEBUG "Lib/Win32/libovrd.lib" HINTS ${LIBOVR_SEARCH_DIRS}) | 52 | find_library(LIBOVR_LIBRARY_DEBUG "Lib/Win32/libovrd.lib" HINTS ${OCULUS_SEARCH_DIRS}) |
| 52 | find_library(LIBOVR_LIBRARY_RELEASE "Lib/Win32/libovr.lib" HINTS ${LIBOVR_SEARCH_DIRS}) | 53 | find_library(LIBOVR_LIBRARY_RELEASE "Lib/Win32/libovr.lib" HINTS ${OCULUS_SEARCH_DIRS}) |
| 53 | endif () | 54 | endif () |
| 54 | 55 | ||
| 55 | select_library_configurations(LIBOVR) | 56 | select_library_configurations(LIBOVR) |
| @@ -63,4 +64,4 @@ elseif () · 7 unmodified lines | |||
| 63 | find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_UTIL_INCLUDE_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) | 64 | find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_UTIL_INCLUDE_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) |
| 64 | endif () | 65 | endif () |
| 65 | 66 | ||
| 66 | mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES) | 67 | mark_as_advanced(LIBOVR_INCLUDE_DIRS LIBOVR_LIBRARIES OCULUS_SEARCH_DIRS) |
| @@ -46,7 +46,10 @@ if (WIN32) · 45 unmodified lines | |||
| 46 | unset(_programfiles) | 46 | unset(_programfiles) |
| 47 | set(_OPENSSL_ROOT_HINTS_AND_PATHS HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS}) | 47 | set(_OPENSSL_ROOT_HINTS_AND_PATHS HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS}) |
| 48 | else () | 48 | else () |
| 49 | set(_OPENSSL_ROOT_HINTS_AND_PATHS ${OPENSSL_ROOT_DIR} $ENV{OPENSSL_ROOT_DIR} $ENV{HIFI_LIB_DIR}/openssl) | 49 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 50 | hifi_library_search_hints("openssl") | ||
| 51 | |||
| 52 | set(_OPENSSL_ROOT_HINTS_AND_PATHS ${OPENSSL_SEARCH_DIRS}) | ||
| 50 | endif () | 53 | endif () |
| 51 | 54 | ||
| 52 | find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_INCLUDEDIR} PATH_SUFFIXES include) | 55 | find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_INCLUDEDIR} PATH_SUFFIXES include) |
| @@ -228,4 +231,4 @@ else () · 175 unmodified lines | |||
| 228 | ) | 231 | ) |
| 229 | endif () | 232 | endif () |
| 230 | 233 | ||
| 231 | mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) | 234 | mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES OPENSSL_SEARCH_DIRS) |
| @@ -18,7 +18,8 @@ · 17 unmodified lines | |||
| 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | set(QXMPP_SEARCH_DIRS "${QXMPP_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/qxmpp") | 21 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 22 | hifi_library_search_hints("qxmpp") | ||
| 22 | 23 | ||
| 23 | find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS}) | 24 | find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS}) |
| 24 | 25 | ||
| @@ -33,4 +34,4 @@ set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}") · 8 unmodified lines | |||
| 33 | include(FindPackageHandleStandardArgs) | 34 | include(FindPackageHandleStandardArgs) |
| 34 | find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) | 35 | find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) |
| 35 | 36 | ||
| 36 | mark_as_advanced(QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) | 37 | mark_as_advanced(QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES QXMPP_SEARCH_DIRS) |
| @@ -18,7 +18,8 @@ · 17 unmodified lines | |||
| 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | set(RTMIDI_SEARCH_DIRS "${RTMIDI_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/rtmidi") | 21 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 22 | hifi_library_search_hints("rtmidi") | ||
| 22 | 23 | ||
| 23 | find_path(RTMIDI_INCLUDE_DIRS RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEARCH_DIRS}) | 24 | find_path(RTMIDI_INCLUDE_DIRS RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEARCH_DIRS}) |
| 24 | find_library(RTMIDI_LIBRARIES NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS}) | 25 | find_library(RTMIDI_LIBRARIES NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS}) |
| @@ -26,4 +27,4 @@ find_library(RTMIDI_LIBRARIES NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEAR · 1 unmodified line | |||
| 26 | include(FindPackageHandleStandardArgs) | 27 | include(FindPackageHandleStandardArgs) |
| 27 | find_package_handle_standard_args(RTMIDI DEFAULT_MSG RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES) | 28 | find_package_handle_standard_args(RTMIDI DEFAULT_MSG RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES) |
| 28 | 29 | ||
| 29 | mark_as_advanced(RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES) | 30 | mark_as_advanced(RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES RTMIDI_SEARCH_DIRS) |
| @@ -18,7 +18,8 @@ · 17 unmodified lines | |||
| 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | set(SIXENSE_SEARCH_DIRS "${SIXENSE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/sixense") | 21 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 22 | hifi_library_search_hints("sixense") | ||
| 22 | 23 | ||
| 23 | find_path(SIXENSE_INCLUDE_DIRS sixense.h PATH_SUFFIXES include HINTS ${SIXENSE_SEARCH_DIRS}) | 24 | find_path(SIXENSE_INCLUDE_DIRS sixense.h PATH_SUFFIXES include HINTS ${SIXENSE_SEARCH_DIRS}) |
| 24 | 25 | ||
| @@ -41,4 +42,4 @@ set(SIXENSE_LIBRARIES "${SIXENSE_LIBRARY}") · 16 unmodified lines | |||
| 41 | include(FindPackageHandleStandardArgs) | 42 | include(FindPackageHandleStandardArgs) |
| 42 | find_package_handle_standard_args(SIXENSE DEFAULT_MSG SIXENSE_INCLUDE_DIRS SIXENSE_LIBRARIES) | 43 | find_package_handle_standard_args(SIXENSE DEFAULT_MSG SIXENSE_INCLUDE_DIRS SIXENSE_LIBRARIES) |
| 43 | 44 | ||
| 44 | mark_as_advanced(SIXENSE_LIBRARIES SIXENSE_INCLUDE_DIRS) | 45 | mark_as_advanced(SIXENSE_LIBRARIES SIXENSE_INCLUDE_DIRS SIXENSE_SEARCH_DIRS) |
| @@ -18,7 +18,8 @@ · 17 unmodified lines | |||
| 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 18 | # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 19 | # | 19 | # |
| 20 | 20 | ||
| 21 | set(VISAGE_SEARCH_DIRS "${VISAGE_ROOT_DIR}" "$ENV{VISAGE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/visage") | 21 | include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") |
| 22 | hifi_library_search_hints("visage") | ||
| 22 | 23 | ||
| 23 | find_path(VISAGE_BASE_INCLUDE_DIR VisageTracker2.h PATH_SUFFIXES include HINTS ${VISAGE_SEARCH_DIRS}) | 24 | find_path(VISAGE_BASE_INCLUDE_DIR VisageTracker2.h PATH_SUFFIXES include HINTS ${VISAGE_SEARCH_DIRS}) |
| 24 | 25 | ||
| @@ -53,5 +54,5 @@ set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISA · 28 unmodified lines | |||
| 53 | mark_as_advanced( | 54 | mark_as_advanced( |
| 54 | VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES | 55 | VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES |
| 55 | VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR | 56 | VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR |
| 56 | VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY | 57 | VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY VISAGE_SEARCH_DIRS |
| 57 | ) | 58 | ) |
| @@ -12,15 +12,15 @@ project(${TARGET_NAME}) · 11 unmodified lines | |||
| 12 | 12 | ||
| 13 | # setup for find modules | 13 | # setup for find modules |
| 14 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") | 14 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") |
| 15 | set(FACEPLUS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/faceplus") | ||
| 16 | set(FACESHIFT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/faceshift") | ||
| 17 | set(LIBOVR_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/oculus") | ||
| 18 | set(PRIOVR_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/priovr") | ||
| 19 | set(SIXENSE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/sixense") | ||
| 20 | set(VISAGE_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/visage") | ||
| 21 | set(LEAPMOTION_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/leapmotion") | ||
| 22 | set(RTMIDI_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/rtmidi") | ||
| 23 | 15 | ||
| 16 | # set a default root dir for each of our optional externals if it was not passed | ||
| 17 | set(OPTIONAL_EXTERNALS "faceplus" "faceshift" "oculus" "priovr" "sixense" "visage" "leapmotion" "rtmidi" "qxmpp") | ||
| 18 | foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) | ||
| 19 | string(TOUPPER ${EXTERNAL} UPPER_EXTERNAL) | ||
| 20 | if (NOT ${UPPER_EXTERNAL}_ROOT_DIR) | ||
| 21 | set(${UPPER_EXTERNAL}_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/${EXTERNAL}") | ||
| 22 | endif () | ||
| 23 | endforeach() | ||
| 24 | 24 | ||
| 25 | find_package(Qt5LinguistTools REQUIRED) | 25 | find_package(Qt5LinguistTools REQUIRED) |
| 26 | find_package(Qt5LinguistToolsMacros) | 26 | find_package(Qt5LinguistToolsMacros) |
| @@ -134,105 +134,54 @@ find_package(Qxmpp) · 107 unmodified lines | |||
| 134 | find_package(RtMidi) | 134 | find_package(RtMidi) |
| 135 | find_package(OpenSSL REQUIRED) | 135 | find_package(OpenSSL REQUIRED) |
| 136 | 136 | ||
| 137 | # include the Sixense library for Razer Hydra if available | 137 | # perform standard include and linking for found externals |
| 138 | if (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) | 138 | foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) |
| 139 | add_definitions(-DHAVE_SIXENSE) | 139 | string(TOUPPER ${EXTERNAL} UPPER_EXTERNAL) |
| 140 | include_directories(SYSTEM "${SIXENSE_INCLUDE_DIRS}") | ||
| 141 | if (APPLE OR UNIX) | ||
| 142 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${SIXENSE_INCLUDE_DIRS}") | ||
| 143 | endif (APPLE OR UNIX) | ||
| 144 | target_link_libraries(${TARGET_NAME} ${SIXENSE_LIBRARIES}) | ||
| 145 | endif (SIXENSE_FOUND AND NOT DISABLE_SIXENSE) | ||
| 146 | |||
| 147 | # likewise with Visage library for webcam feature tracking | ||
| 148 | if (VISAGE_FOUND AND NOT DISABLE_VISAGE) | ||
| 149 | add_definitions(-DHAVE_VISAGE -DVISAGE_STATIC) | ||
| 150 | include_directories(SYSTEM "${VISAGE_INCLUDE_DIRS}") | ||
| 151 | if (APPLE) | ||
| 152 | add_definitions(-DMAC_OS_X) | ||
| 153 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment") | ||
| 154 | include_directories(SYSTEM "${VISAGE_INCLUDE_DIRS}") | ||
| 155 | find_library(AVFoundation AVFoundation) | ||
| 156 | find_library(CoreMedia CoreMedia) | ||
| 157 | find_library(NEW_STD_LIBRARY libc++.dylib /usr/lib/) | ||
| 158 | target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia} ${NEW_STD_LIBRARY}) | ||
| 159 | endif (APPLE) | ||
| 160 | target_link_libraries(${TARGET_NAME} "${VISAGE_LIBRARIES}") | ||
| 161 | endif (VISAGE_FOUND AND NOT DISABLE_VISAGE) | ||
| 162 | |||
| 163 | # and with Faceplus library, also for webcam feature tracking | ||
| 164 | if (FACEPLUS_FOUND AND NOT DISABLE_FACEPLUS) | ||
| 165 | add_definitions(-DHAVE_FACEPLUS) | ||
| 166 | include_directories(SYSTEM "${FACEPLUS_INCLUDE_DIRS}") | ||
| 167 | target_link_libraries(${TARGET_NAME} "${FACEPLUS_LIBRARIES}") | ||
| 168 | endif (FACEPLUS_FOUND AND NOT DISABLE_FACEPLUS) | ||
| 169 | |||
| 170 | # and with LibOVR for Oculus Rift | ||
| 171 | if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) | ||
| 172 | add_definitions(-DHAVE_LIBOVR) | ||
| 173 | include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS}) | ||
| 174 | 140 | ||
| 175 | if (APPLE) | 141 | if (${UPPER_EXTERNAL} MATCHES "OCULUS") |
| 176 | foreach(LIBOVR_DIR ${LIBOVR_INCLUDE_DIRS}) | 142 | # the oculus directory is named OCULUS and not LIBOVR so hack to fix that here |
| 177 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LIBOVR_DIR}") | 143 | set(UPPER_EXTERNAL "LIBOVR") |
| 178 | endforeach() | ||
| 179 | endif () | 144 | endif () |
| 180 | 145 | ||
| 181 | target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES}) | 146 | if (${UPPER_EXTERNAL}_FOUND AND NOT DISABLE_${UPPER_EXTERNAL}) |
| 182 | endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) | 147 | add_definitions(-DHAVE_${UPPER_EXTERNAL}) |
| 183 | 148 | ||
| 184 | # and with PrioVR library | 149 | # include the library directories (ignoring warnings) |
| 185 | if (PRIOVR_FOUND AND NOT DISABLE_PRIOVR) | 150 | include_directories(SYSTEM ${${UPPER_EXTERNAL}_INCLUDE_DIRS}) |
| 186 | add_definitions(-DHAVE_PRIOVR) | 151 | |
| 187 | include_directories(SYSTEM "${PRIOVR_INCLUDE_DIRS}") | 152 | # perform the system include hack for OS X to ignore warnings |
| 188 | target_link_libraries(${TARGET_NAME} "${PRIOVR_LIBRARIES}") | ||
| 189 | endif (PRIOVR_FOUND AND NOT DISABLE_PRIOVR) | ||
| 190 | |||
| 191 | # and with LeapMotion library | ||
| 192 | if (LEAPMOTION_FOUND AND NOT DISABLE_LEAPMOTION) | ||
| 193 | add_definitions(-DHAVE_LEAPMOTION) | ||
| 194 | include_directories(SYSTEM "${LEAPMOTION_INCLUDE_DIRS}") | ||
| 195 | |||
| 196 | if (APPLE) | 153 | if (APPLE) |
| 197 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${LEAPMOTION_INCLUDE_DIRS}") | 154 | foreach(EXTERNAL_INCLUDE_DIR ${${UPPER_EXTERNAL}_INCLUDE_DIRS}) |
| 155 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${EXTERNAL_INCLUDE_DIR}") | ||
| 156 | endforeach() | ||
| 198 | endif () | 157 | endif () |
| 199 | target_link_libraries(${TARGET_NAME} ${LEAPMOTION_LIBRARIES}) | 158 | |
| 200 | endif (LEAPMOTION_FOUND AND NOT DISABLE_LEAPMOTION) | 159 | target_link_libraries(${TARGET_NAME} ${${UPPER_EXTERNAL}_LIBRARIES}) |
| 201 | 160 | ||
| 202 | # and with SDL for joysticks | 161 | endif () |
| 203 | if (SDL_FOUND AND NOT DISABLE_SDL) | 162 | endforeach() |
| 204 | add_definitions(-DHAVE_SDL) | 163 | |
| 205 | include_directories(SYSTEM "${SDL_INCLUDE_DIR}") | 164 | # special APPLE modifications for Visage library |
| 206 | target_link_libraries(${TARGET_NAME} "${SDL_LIBRARY}") | 165 | if (VISAGE_FOUND AND NOT DISABLE_VISAGE AND APPLE) |
| 207 | endif (SDL_FOUND AND NOT DISABLE_SDL) | 166 | add_definitions(-DMAC_OS_X) |
| 208 | 167 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-comment") | |
| 209 | # and with qxmpp for chat | 168 | find_library(AVFoundation AVFoundation) |
| 210 | if (QXMPP_FOUND AND NOT DISABLE_QXMPP) | 169 | find_library(CoreMedia CoreMedia) |
| 211 | add_definitions(-DHAVE_QXMPP -DQXMPP_STATIC) | 170 | find_library(NEW_STD_LIBRARY libc++.dylib /usr/lib/) |
| 212 | include_directories(SYSTEM "${QXMPP_INCLUDE_DIRS}") | 171 | target_link_libraries(${TARGET_NAME} ${AVFoundation} ${CoreMedia} ${NEW_STD_LIBRARY}) |
| 213 | 172 | endif () | |
| 214 | target_link_libraries(${TARGET_NAME} ${QXMPP_LIBRARIES}) | ||
| 215 | endif (QXMPP_FOUND AND NOT DISABLE_QXMPP) | ||
| 216 | |||
| 217 | # and with RtMidi for RtMidi control | ||
| 218 | if (RTMIDI_FOUND AND NOT DISABLE_RTMIDI) | ||
| 219 | add_definitions(-DHAVE_RTMIDI) | ||
| 220 | include_directories(SYSTEM "${RTMIDI_INCLUDE_DIRS}") | ||
| 221 | target_link_libraries(${TARGET_NAME} ${RTMIDI_LIBRARIES}) | ||
| 222 | |||
| 223 | if (APPLE) | ||
| 224 | find_library(CoreMIDI CoreMIDI) | ||
| 225 | add_definitions(-D__MACOSX_CORE__) | ||
| 226 | target_link_libraries(${TARGET_NAME} ${CoreMIDI}) | ||
| 227 | endif() | ||
| 228 | endif() | ||
| 229 | 173 | ||
| 230 | # and with Faceshift for depth camera face tracking | 174 | # special OS X modifications for RtMidi library |
| 231 | if (FACESHIFT_FOUND AND NOT DISABLE_FACESHIFT) | 175 | if (RTMIDI_FOUND AND NOT DISABLE_RTMIDI AND APPLE) |
| 232 | add_definitions(-DHAVE_FACESHIFT) | 176 | find_library(CoreMIDI CoreMIDI) |
| 233 | include_directories(SYSTEM "${FACESHIFT_INCLUDE_DIRS}") | 177 | add_definitions(-D__MACOSX_CORE__) |
| 234 | target_link_libraries(${TARGET_NAME} ${FACESHIFT_LIBRARIES}) | 178 | target_link_libraries(${TARGET_NAME} ${CoreMIDI}) |
| 235 | endif() | 179 | endif () |
| 180 | |||
| 181 | if (QXMPP_FOUND AND NOT DISABLE_QXMPP AND WIN32) | ||
| 182 | # assume we're linking a static Qt on windows | ||
| 183 | add_definitions(-DQXMPP_STATIC) | ||
| 184 | endif () | ||
| 236 | 185 | ||
| 237 | # include headers for interface and InterfaceConfig. | 186 | # include headers for interface and InterfaceConfig. |
| 238 | include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") | 187 | include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") |
| @@ -242,8 +242,8 @@ Menu::Menu() : · 241 unmodified lines | |||
| 242 | 242 | ||
| 243 | const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); | 243 | const QXmppClient& xmppClient = XmppClient::getInstance().getXMPPClient(); |
| 244 | toggleChat(); | 244 | toggleChat(); |
| 245 | connect(&xmppClient, SIGNAL(connected()), this, SLOT(toggleChat())); | 245 | connect(&xmppClient, &QXmppClient::connected, this, &Menu::toggleChat); |
| 246 | connect(&xmppClient, SIGNAL(disconnected()), this, SLOT(toggleChat())); | 246 | connect(&xmppClient, &QXmppClient::disconnected, this, &Menu::toggleChat); |
| 247 | 247 | ||
| 248 | QDir::setCurrent(Application::resourcesPath()); | 248 | QDir::setCurrent(Application::resourcesPath()); |
| 249 | // init chat window to listen chat | 249 | // init chat window to listen chat |
| @@ -9,7 +9,6 @@ · 8 unmodified lines | |||
| 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 10 | // | 10 | // |
| 11 | 11 | ||
| 12 | #ifdef HAVE_QXMPP | ||
| 13 | 12 | ||
| 14 | #include <AccountManager.h> | 13 | #include <AccountManager.h> |
| 15 | 14 | ||
| @@ -18,6 +17,7 @@ · 2 unmodified lines | |||
| 18 | const QString DEFAULT_XMPP_SERVER = "chat.highfidelity.io"; | 17 | const QString DEFAULT_XMPP_SERVER = "chat.highfidelity.io"; |
| 19 | const QString DEFAULT_CHAT_ROOM = "public@public-chat.highfidelity.io"; | 18 | const QString DEFAULT_CHAT_ROOM = "public@public-chat.highfidelity.io"; |
| 20 | 19 | ||
| 20 | #ifdef HAVE_QXMPP | ||
| 21 | XmppClient::XmppClient() : | 21 | XmppClient::XmppClient() : |
| 22 | _xmppClient(), | 22 | _xmppClient(), |
| 23 | _xmppMUCManager() | 23 | _xmppMUCManager() |
| @@ -26,6 +26,11 @@ XmppClient::XmppClient() : · 2 unmodified lines | |||
| 26 | connect(&accountManager, SIGNAL(profileChanged()), this, SLOT(connectToServer())); | 26 | connect(&accountManager, SIGNAL(profileChanged()), this, SLOT(connectToServer())); |
| 27 | connect(&accountManager, SIGNAL(logoutComplete()), this, SLOT(disconnectFromServer())); | 27 | connect(&accountManager, SIGNAL(logoutComplete()), this, SLOT(disconnectFromServer())); |
| 28 | } | 28 | } |
| 29 | #else | ||
| 30 | XmppClient::XmppClient() { | ||
| 31 | |||
| 32 | } | ||
| 33 | #endif | ||
| 29 | 34 | ||
| 30 | XmppClient& XmppClient::getInstance() { | 35 | XmppClient& XmppClient::getInstance() { |
| 31 | static XmppClient sharedInstance; | 36 | static XmppClient sharedInstance; |
| @@ -33,18 +38,23 @@ XmppClient& XmppClient::getInstance() { · 1 unmodified line | |||
| 33 | } | 38 | } |
| 34 | 39 | ||
| 35 | void XmppClient::xmppConnected() { | 40 | void XmppClient::xmppConnected() { |
| 41 | #ifdef HAVE_QXMPP | ||
| 36 | _publicChatRoom = _xmppMUCManager.addRoom(DEFAULT_CHAT_ROOM); | 42 | _publicChatRoom = _xmppMUCManager.addRoom(DEFAULT_CHAT_ROOM); |
| 37 | _publicChatRoom->setNickName(AccountManager::getInstance().getAccountInfo().getUsername()); | 43 | _publicChatRoom->setNickName(AccountManager::getInstance().getAccountInfo().getUsername()); |
| 38 | _publicChatRoom->join(); | 44 | _publicChatRoom->join(); |
| 39 | emit joinedPublicChatRoom(); | 45 | emit joinedPublicChatRoom(); |
| 46 | #endif | ||
| 40 | } | 47 | } |
| 41 | 48 | ||
| 42 | void XmppClient::xmppError(QXmppClient::Error error) { | 49 | void XmppClient::xmppError(QXmppClient::Error error) { |
| 50 | #ifdef HAVE_QXMPP | ||
| 43 | qDebug() << "Error connnecting to XMPP for user " | 51 | qDebug() << "Error connnecting to XMPP for user " |
| 44 | << AccountManager::getInstance().getAccountInfo().getUsername() << ": " << error; | 52 | << AccountManager::getInstance().getAccountInfo().getUsername() << ": " << error; |
| 53 | #endif | ||
| 45 | } | 54 | } |
| 46 | 55 | ||
| 47 | void XmppClient::connectToServer() { | 56 | void XmppClient::connectToServer() { |
| 57 | #ifdef HAVE_QXMPP | ||
| 48 | disconnectFromServer(); | 58 | disconnectFromServer(); |
| 49 | 59 | ||
| 50 | if (_xmppClient.addExtension(&_xmppMUCManager)) { | 60 | if (_xmppClient.addExtension(&_xmppMUCManager)) { |
| @@ -55,12 +65,15 @@ void XmppClient::connectToServer() { · 4 unmodified lines | |||
| 55 | QString user = accountManager.getAccountInfo().getUsername(); | 65 | QString user = accountManager.getAccountInfo().getUsername(); |
| 56 | const QString& password = accountManager.getAccountInfo().getXMPPPassword(); | 66 | const QString& password = accountManager.getAccountInfo().getXMPPPassword(); |
| 57 | _xmppClient.connectToServer(user + "@" + DEFAULT_XMPP_SERVER, password); | 67 | _xmppClient.connectToServer(user + "@" + DEFAULT_XMPP_SERVER, password); |
| 68 | #endif | ||
| 58 | } | 69 | } |
| 59 | 70 | ||
| 60 | void XmppClient::disconnectFromServer() { | 71 | void XmppClient::disconnectFromServer() { |
| 72 | #ifdef HAVE_QXMPP | ||
| 61 | if (_xmppClient.isConnected()) { | 73 | if (_xmppClient.isConnected()) { |
| 62 | _xmppClient.disconnectFromServer(); | 74 | _xmppClient.disconnectFromServer(); |
| 63 | } | 75 | } |
| 76 | #endif | ||
| 64 | } | 77 | } |
| 65 | 78 | ||
| 66 | XmppClient::XmppClient(const XmppClient& other) { | 79 | XmppClient::XmppClient(const XmppClient& other) { |
| @@ -70,5 +83,3 @@ XmppClient::XmppClient(const XmppClient& other) { · 3 unmodified lines | |||
| 70 | void XmppClient::operator =(XmppClient const& other) { | 83 | void XmppClient::operator =(XmppClient const& other) { |
| 71 | Q_UNUSED(other); | 84 | Q_UNUSED(other); |
| 72 | } | 85 | } |
| 73 | |||
| 74 | #endif | ||
| @@ -9,25 +9,27 @@ · 8 unmodified lines | |||
| 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 10 | // | 10 | // |
| 11 | 11 | ||
| 12 | #ifdef HAVE_QXMPP | ||
| 13 | |||
| 14 | #ifndef hifi_XmppClient_h | 12 | #ifndef hifi_XmppClient_h |
| 15 | #define hifi_XmppClient_h | 13 | #define hifi_XmppClient_h |
| 16 | 14 | ||
| 17 | #include <QObject> | 15 | #include <QObject> |
| 16 | |||
| 17 | #ifdef HAVE_QXMPP | ||
| 18 | #include <QXmppClient.h> | 18 | #include <QXmppClient.h> |
| 19 | #include <QXmppMucManager.h> | 19 | #include <QXmppMucManager.h> |
| 20 | #endif | ||
| 20 | 21 | ||
| 21 | /// Generalized threaded processor for handling received inbound packets. | 22 | /// Generalized threaded processor for handling received inbound packets. |
| 22 | class XmppClient : public QObject { | 23 | class XmppClient : public QObject { |
| 23 | Q_OBJECT | 24 | Q_OBJECT |
| 24 | |||
| 25 | public: | 25 | public: |
| 26 | static XmppClient& getInstance(); | 26 | static XmppClient& getInstance(); |
| 27 | 27 | ||
| 28 | #ifdef HAVE_QXMPP | ||
| 28 | QXmppClient& getXMPPClient() { return _xmppClient; } | 29 | QXmppClient& getXMPPClient() { return _xmppClient; } |
| 29 | const QXmppMucRoom* getPublicChatRoom() const { return _publicChatRoom; } | 30 | const QXmppMucRoom* getPublicChatRoom() const { return _publicChatRoom; } |
| 30 | 31 | #endif | |
| 32 | |||
| 31 | signals: | 33 | signals: |
| 32 | void joinedPublicChatRoom(); | 34 | void joinedPublicChatRoom(); |
| 33 | 35 | ||
| @@ -43,11 +45,11 @@ private: · 9 unmodified lines | |||
| 43 | XmppClient(XmppClient const& other); // not implemented | 45 | XmppClient(XmppClient const& other); // not implemented |
| 44 | void operator=(XmppClient const& other); // not implemented | 46 | void operator=(XmppClient const& other); // not implemented |
| 45 | 47 | ||
| 48 | #ifdef HAVE_QXMPP | ||
| 46 | QXmppClient _xmppClient; | 49 | QXmppClient _xmppClient; |
| 47 | QXmppMucManager _xmppMUCManager; | 50 | QXmppMucManager _xmppMUCManager; |
| 48 | QXmppMucRoom* _publicChatRoom; | 51 | QXmppMucRoom* _publicChatRoom; |
| 52 | #endif | ||
| 49 | }; | 53 | }; |
| 50 | 54 | ||
| 51 | #endif // __interface__XmppClient__ | ||
| 52 | |||
| 53 | #endif // hifi_XmppClient_h | 55 | #endif // hifi_XmppClient_h |