From 227807df36e8bf8215372ca2dd0c4919390b925b Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 22 Jul 2018 11:01:53 -0700 Subject: [PATCH] cmake: Support system cubeb builds. --- CMake/FindCubeb.cmake | 15 +++++++++++++++ CMakeLists.txt | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 CMake/FindCubeb.cmake diff --git a/CMake/FindCubeb.cmake b/CMake/FindCubeb.cmake new file mode 100644 index 0000000000..c0a730c7ab --- /dev/null +++ b/CMake/FindCubeb.cmake @@ -0,0 +1,15 @@ +find_path(CUBEB_INCLUDE_DIR cubeb.h PATH_SUFFIXES cubeb) +find_library(CUBEB_LIBRARY cubeb) +mark_as_advanced(CUBEB_INCLUDE_DIR CUBEB_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CUBEB DEFAULT_MSG + CUBEB_INCLUDE_DIR CUBEB_LIBRARY) + +if(CUBEB_FOUND AND NOT TARGET CUBEB) + add_library(cubeb::cubeb UNKNOWN IMPORTED) + set_target_properties(cubeb::cubeb PROPERTIES + IMPORTED_LOCATION "${CUBEB_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CUBEB_INCLUDE_DIR}" + ) +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a0e380e91..f6e43a80c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -611,7 +611,13 @@ endif() add_subdirectory(Externals/soundtouch) include_directories(Externals) -add_subdirectory(Externals/cubeb EXCLUDE_FROM_ALL) +find_package(Cubeb) +if(CUBEB_FOUND) + message(STATUS "Using the system cubeb") +else() + message(STATUS "Using static cubeb from Externals") + add_subdirectory(Externals/cubeb EXCLUDE_FROM_ALL) +endif() if(NOT ANDROID) add_definitions(-D__LIBUSB__)