From 0849981f6a7af1197fe5f0eb45658e34d3d61e34 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 24 Jul 2014 14:43:25 -0700 Subject: [PATCH] more standardization for external library searches --- cmake/macros/HifiLibrarySearchHints.cmake | 26 +++++++++++++++++++++++ cmake/modules/FindFaceshift.cmake | 3 ++- cmake/modules/FindGLEW.cmake | 3 ++- cmake/modules/FindGLM.cmake | 3 ++- cmake/modules/FindGLUT.cmake | 5 +++-- cmake/modules/FindLeapMotion.cmake | 16 +++++++------- cmake/modules/FindLibOVR.cmake | 3 ++- cmake/modules/FindOpenSSL.cmake | 5 ++++- cmake/modules/FindQxmpp.cmake | 3 ++- cmake/modules/FindRtMidi.cmake | 3 ++- cmake/modules/FindSixense.cmake | 3 ++- cmake/modules/FindVisage.cmake | 3 ++- 12 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 cmake/macros/HifiLibrarySearchHints.cmake diff --git a/cmake/macros/HifiLibrarySearchHints.cmake b/cmake/macros/HifiLibrarySearchHints.cmake new file mode 100644 index 0000000000..c784e2da4a --- /dev/null +++ b/cmake/macros/HifiLibrarySearchHints.cmake @@ -0,0 +1,26 @@ +# +# HifiLibrarySearchHints.cmake +# +# Created by Stephen Birarda on July 24th, 2014 +# 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 +# + +macro(HIFI_LIBRARY_SEARCH_HINTS LIBRARY_PREFIX LIBRARY_FOLDER) + set(${LIBRARY_PREFIX}_SEARCH_DIRS "") + + if (${LIBRARY_PREFIX}_ROOT_DIR) + set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}") + endif () + + if (DEFINED ENV{${LIBRARY_PREFIX}_ROOT_DIR}) + set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}") + endif () + + if (DEFINED ENV{HIFI_LIB_DIR}) + set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}") + endif () + +endmacro(HIFI_LIBRARY_SEARCH_HINTS _library_prefix _library_folder) \ No newline at end of file diff --git a/cmake/modules/FindFaceshift.cmake b/cmake/modules/FindFaceshift.cmake index e11c21cd3f..e44f686d82 100644 --- a/cmake/modules/FindFaceshift.cmake +++ b/cmake/modules/FindFaceshift.cmake @@ -18,7 +18,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -set(FACESHIFT_SEARCH_DIRS "${FACESHIFT_ROOT_DIR}" "$ENV{FACESHIFT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/faceshift") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("FACESHIFT" "faceshift") find_path(FACESHIFT_INCLUDE_DIRS fsbinarystream.h PATH_SUFFIXES include HINTS ${FACESHIFT_SEARCH_DIRS}) diff --git a/cmake/modules/FindGLEW.cmake b/cmake/modules/FindGLEW.cmake index 59927dc468..0ffe8c433d 100644 --- a/cmake/modules/FindGLEW.cmake +++ b/cmake/modules/FindGLEW.cmake @@ -19,7 +19,8 @@ # if (WIN32) - set(WIN_GLEW_SEARCH_DIRS "${GLEW_ROOT_DIR}" "$ENV{GLEW_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glew") + include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") + hifi_library_search_hints("GLEW" "glew") find_path(GLEW_INCLUDE_DIRS GL/glew.h PATH_SUFFIXES include HINTS ${WIN_GLEW_SEARCH_DIRS}) diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake index 04bc252796..0c4c596834 100644 --- a/cmake/modules/FindGLM.cmake +++ b/cmake/modules/FindGLM.cmake @@ -14,7 +14,8 @@ # # setup hints for GLM search -set(GLM_HEADER_SEARCH_HINTS "${GLM_ROOT_DIR}" "$ENV{GLM_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/glm") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("GLM" "glm") # locate header find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_HEADER_SEARCH_HINTS}) diff --git a/cmake/modules/FindGLUT.cmake b/cmake/modules/FindGLUT.cmake index 881e649ecd..5a78ddd589 100644 --- a/cmake/modules/FindGLUT.cmake +++ b/cmake/modules/FindGLUT.cmake @@ -18,10 +18,11 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -set(GLUT_HINT_DIRS "${GLUT_ROOT_DIR}" "$ENV{GLUT_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/freeglut") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("GLUT" "freeglut") if (WIN32) - set(GLUT_HINT_DIRS "${GLUT_HINT_DIRS}" "${OPENGL_INCLUDE_DIR}") + set(GLUT_HINT_DIRS "${GLUT_HINT_DIRS} ${OPENGL_INCLUDE_DIR}")s 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}) diff --git a/cmake/modules/FindLeapMotion.cmake b/cmake/modules/FindLeapMotion.cmake index 91ac080c30..1b8e6eae11 100644 --- a/cmake/modules/FindLeapMotion.cmake +++ b/cmake/modules/FindLeapMotion.cmake @@ -12,22 +12,22 @@ # Copyright (c) 2014 High Fidelity # -set(LEAPMOTION_SEARCH_DIRS "${LEAPMOTION_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/leapmotion") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("LEAPMOTION" "leapmotion") find_path(LEAPMOTION_INCLUDE_DIRS Leap.h PATH_SUFFIXES include HINTS ${LEAPMOTION_SEARCH_DIRS}) 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) + find_library(LEAPMOTION_LIBRARY_DEBUG Leapd PATH_SUFFIXES lib/x86 HINTS ${LEAPMOTION_SEARCH_DIRS}) + find_library(LEAPMOTION_LIBRARY_RELEASE Leap PATH_SUFFIXES lib/x86 HINTS ${LEAPMOTION_SEARCH_DIRS}) +elseif (APPLE) + find_library(LEAPMOTION_LIBRARY_RELEASE Leap PATH_SUFFIXES lib/libc++ lib HINTS ${LEAPMOTION_SEARCH_DIRS}) +endif () include(SelectLibraryConfigurations) select_library_configurations(LEAPMOTION) -set(LEAPMOTION_LIBRARIES "${LEAPMOTION_LIBARIES}") +set(LEAPMOTION_LIBRARIES "${LEAPMOTION_LIBRARY}") include(FindPackageHandleStandardArgs) find_package_handle_standard_args(LEAPMOTION DEFAULT_MSG LEAPMOTION_INCLUDE_DIRS LEAPMOTION_LIBRARIES) diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index 738a30519c..82baa41ee4 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -18,7 +18,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -set(LIBOVR_SEARCH_DIRS "${LIBOVR_ROOT_DIR}" "$ENV{LIBOVR_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/oculus") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("LIBOVR" "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}) diff --git a/cmake/modules/FindOpenSSL.cmake b/cmake/modules/FindOpenSSL.cmake index 403bb4e246..5b398c2329 100644 --- a/cmake/modules/FindOpenSSL.cmake +++ b/cmake/modules/FindOpenSSL.cmake @@ -46,7 +46,10 @@ if (WIN32) unset(_programfiles) 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) + include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") + hifi_library_search_hints("OPENSSL" "openssl") + + set(_OPENSSL_ROOT_HINTS_AND_PATHS ${OPENSSL_SEARCH_DIRS}) endif () find_path(OPENSSL_INCLUDE_DIR NAMES openssl/ssl.h HINTS ${_OPENSSL_ROOT_HINTS_AND_PATHS} ${_OPENSSL_INCLUDEDIR} PATH_SUFFIXES include) diff --git a/cmake/modules/FindQxmpp.cmake b/cmake/modules/FindQxmpp.cmake index 71c99369aa..02340941fc 100644 --- a/cmake/modules/FindQxmpp.cmake +++ b/cmake/modules/FindQxmpp.cmake @@ -18,7 +18,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -set(QXMPP_SEARCH_DIRS "${QXMPP_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/qxmpp") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("QXMPP" "qxmpp") find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${QXMPP_SEARCH_DIRS}) diff --git a/cmake/modules/FindRtMidi.cmake b/cmake/modules/FindRtMidi.cmake index d03477710c..b52ab7b23a 100644 --- a/cmake/modules/FindRtMidi.cmake +++ b/cmake/modules/FindRtMidi.cmake @@ -18,7 +18,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -set(RTMIDI_SEARCH_DIRS "${RTMIDI_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/rtmidi") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("RTMIDI" "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}) diff --git a/cmake/modules/FindSixense.cmake b/cmake/modules/FindSixense.cmake index 94d211fdac..18eaf0409f 100644 --- a/cmake/modules/FindSixense.cmake +++ b/cmake/modules/FindSixense.cmake @@ -18,7 +18,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -set(SIXENSE_SEARCH_DIRS "${SIXENSE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/sixense") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("SIXENSE" "sixense") find_path(SIXENSE_INCLUDE_DIRS sixense.h PATH_SUFFIXES include HINTS ${SIXENSE_SEARCH_DIRS}) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 7e1d6e60b6..2d968184cf 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -18,7 +18,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -set(VISAGE_SEARCH_DIRS "${VISAGE_ROOT_DIR}" "$ENV{VISAGE_ROOT_DIR}" "$ENV{HIFI_LIB_DIR}/visage") +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("VISAGE" "visage") find_path(VISAGE_BASE_INCLUDE_DIR VisageTracker2.h PATH_SUFFIXES include HINTS ${VISAGE_SEARCH_DIRS})