From 430083681019cdb7cc785a1ff142a4a1ee36fb59 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 15:47:35 -0800 Subject: [PATCH] make gverb a cmake external project --- cmake/externals/glm/CMakeLists.txt | 4 +-- cmake/externals/gverb/CMakeLists.txt | 16 ++++++++++++ cmake/modules/FindGverb.cmake | 26 +++++-------------- libraries/audio-client/CMakeLists.txt | 12 +++------ .../audio-client/external/gverb/readme.txt | 14 ---------- libraries/audio-client/src/AudioClient.cpp | 5 ++++ libraries/audio-client/src/AudioClient.h | 6 ++--- 7 files changed, 35 insertions(+), 48 deletions(-) create mode 100644 cmake/externals/gverb/CMakeLists.txt delete mode 100644 libraries/audio-client/external/gverb/readme.txt diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt index 8bf597ecc3..928603ecd2 100644 --- a/cmake/externals/glm/CMakeLists.txt +++ b/cmake/externals/glm/CMakeLists.txt @@ -9,7 +9,7 @@ ExternalProject_Add( LOG_DOWNLOAD ON ) -ExternalProject_Get_Property(${EXTERNAL_NAME} install_dir) +ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) -set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${install_dir}/include CACHE TYPE STRING) \ No newline at end of file +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING) \ No newline at end of file diff --git a/cmake/externals/gverb/CMakeLists.txt b/cmake/externals/gverb/CMakeLists.txt new file mode 100644 index 0000000000..1954df703e --- /dev/null +++ b/cmake/externals/gverb/CMakeLists.txt @@ -0,0 +1,16 @@ +set(EXTERNAL_NAME gverb) + +include(ExternalProject) +ExternalProject_Add( + ${EXTERNAL_NAME} + PREFIX ${EXTERNAL_NAME} + GIT_REPOSITORY https://github.com/birarda/gverb.git + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + LOG_DOWNLOAD ON +) + +ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) + +string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING) +set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/libgverb.a CACHE TYPE STRING) \ No newline at end of file diff --git a/cmake/modules/FindGverb.cmake b/cmake/modules/FindGverb.cmake index d4d2377c94..7dc233333c 100644 --- a/cmake/modules/FindGverb.cmake +++ b/cmake/modules/FindGverb.cmake @@ -15,25 +15,11 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (GVERB_INCLUDE_DIRS) - # in cache already - set(GVERB_FOUND TRUE) -else (GVERB_INCLUDE_DIRS) +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("gverb") - include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") - hifi_library_search_hints("gverb") +find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS}) +find_path(GVERB_LIBRARIES gverb PATH_SUFFIXES lib HINTS ${GVERB_SEARCH_DIRS}) - find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS} NO_CMAKE_FIND_ROOT_PATH) - find_path(GVERB_SRC_DIRS gverb.c PATH_SUFFIXES src HINTS ${GVERB_SEARCH_DIRS} NO_CMAKE_FIND_ROOT_PATH) - - if (GVERB_INCLUDE_DIRS) - set(GVERB_FOUND TRUE) - endif (GVERB_INCLUDE_DIRS) - - if (GVERB_FOUND) - message(STATUS "Found Gverb: ${GVERB_INCLUDE_DIRS}") - else (GVERB_FOUND) - message(FATAL_ERROR "Could NOT find Gverb. Read ./libraries/audio-client/externals/gverb/readme.txt") - endif (GVERB_FOUND) - -endif(GVERB_INCLUDE_DIRS) \ No newline at end of file +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GVERB DEFAULT_MSG GVERB_INCLUDE_DIRS GVERB_LIBRARIES) \ No newline at end of file diff --git a/libraries/audio-client/CMakeLists.txt b/libraries/audio-client/CMakeLists.txt index 5477be3bc5..1cd76cf2f5 100644 --- a/libraries/audio-client/CMakeLists.txt +++ b/libraries/audio-client/CMakeLists.txt @@ -8,17 +8,13 @@ link_hifi_libraries(audio) # append audio includes to our list of includes to bubble list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${HIFI_LIBRARY_DIR}/audio/src") -set(GVERB_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/gverb") +# have CMake grab Gverb from git and then set up linking and directory include +add_dependency_external_project(gverb) -# As Gverb is currently the only reverb library, it's required. find_package(Gverb REQUIRED) -file(GLOB GVERB_SRCS ${GVERB_SRC_DIRS}/*.c) -add_library(gverb STATIC ${GVERB_SRCS}) -target_link_libraries(${TARGET_NAME} gverb) - -# append gverb includes to our list of includes to bubble -list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${GVERB_INCLUDE_DIRS}") +target_link_libraries(${TARGET_NAME} ${GVERB_LIBRARIES}) +target_include_directories(${TARGET_NAME} PRIVATE ${GVERB_INCLUDE_DIRS}) # we use libsoxr for resampling find_package(Soxr REQUIRED) diff --git a/libraries/audio-client/external/gverb/readme.txt b/libraries/audio-client/external/gverb/readme.txt deleted file mode 100644 index bb01e48a74..0000000000 --- a/libraries/audio-client/external/gverb/readme.txt +++ /dev/null @@ -1,14 +0,0 @@ -Instructions for adding the Gverb library to audio-client -(This is a required library) -Clément Brisset, October 22nd, 2014 - -1. Go to https://github.com/highfidelity/gverb - Or download the sources directly via this link: - https://github.com/highfidelity/gverb/archive/master.zip - -2. Extract the archive - -3. Place the directories “include” and “src” in libraries/audio-client/external/gverb - (Normally next to this readme) - -4. Clear your build directory, run cmake, build and you should be all set. diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 1919f2bbe5..391d6aaf40 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -33,6 +33,11 @@ #include #include +extern "C" { + #include + #include +} + #include #include diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index e55a116e06..dc4e16d81b 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -47,10 +47,7 @@ #pragma warning( disable : 4273 ) #pragma warning( disable : 4305 ) #endif -extern "C" { - #include - #include -} + #ifdef _WIN32 #pragma warning( pop ) #endif @@ -68,6 +65,7 @@ class QAudioInput; class QAudioOutput; class QIODevice; struct soxr; +typedef struct ty_gverb ty_gverb; typedef glm::vec3 (*AudioPositionGetter)(); typedef glm::quat (*AudioOrientationGetter)();