From 8cdf8dec703d882b46ca50a769fabb95ffc48e2c Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 24 Nov 2016 21:27:41 +0100 Subject: sync with upstream --- project/cmake/modules/FindAlsa.cmake | 52 +++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'project/cmake/modules/FindAlsa.cmake') diff --git a/project/cmake/modules/FindAlsa.cmake b/project/cmake/modules/FindAlsa.cmake index b15a0cf..a282243 100644 --- a/project/cmake/modules/FindAlsa.cmake +++ b/project/cmake/modules/FindAlsa.cmake @@ -1,20 +1,46 @@ -# - Try to find ALSA -# Once done this will define +#.rst: +# FindAlsa +# -------- +# Finds the Alsa library # -# ALSA_FOUND - system has libALSA -# ALSA_INCLUDE_DIRS - the libALSA include directory -# ALSA_LIBRARIES - The libALSA libraries +# This will will define the following variables:: +# +# ALSA_FOUND - system has Alsa +# ALSA_INCLUDE_DIRS - the Alsa include directory +# ALSA_LIBRARIES - the Alsa libraries +# ALSA_DEFINITIONS - the Alsa compile definitions +# +# and the following imported targets:: +# +# ALSA::ALSA - The Alsa library if(PKG_CONFIG_FOUND) - pkg_check_modules (ALSA alsa) -else() - find_path(ALSA_INCLUDE_DIRS asoundlib.h PATH_SUFFIXES alsa) - find_library(ALSA_LIBRARIES asound) + pkg_check_modules(PC_ALSA alsa QUIET) endif() +find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h + PATHS ${PC_ALSA_INCLUDEDIR}) +find_library(ALSA_LIBRARY NAMES asound + PATHS ${PC_ALSA_LIBDIR}) + +set(ALSA_VERSION ${PC_ALSA_VERSION}) + include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Alsa DEFAULT_MSG ALSA_INCLUDE_DIRS ALSA_LIBRARIES) +find_package_handle_standard_args(ALSA + REQUIRED_VARS ALSA_LIBRARY ALSA_INCLUDE_DIR + VERSION_VAR ALSA_VERSION) + +if(ALSA_FOUND) + set(ALSA_INCLUDE_DIRS "") # Don't want these added as 'timer.h' is a dangerous file + set(ALSA_LIBRARIES ${ALSA_LIBRARY}) + set(ALSA_DEFINITIONS -DHAVE_ALSA=1 -DUSE_ALSA=1) + + if(NOT TARGET ALSA::ALSA) + add_library(ALSA::ALSA UNKNOWN IMPORTED) + set_target_properties(ALSA::ALSA PROPERTIES + IMPORTED_LOCATION "${ALSA_LIBRARY}" + INTERFACE_COMPILE_DEFINITIONS "${ALSA_DEFINITIONS}") + endif() +endif() -set(ALSA_INCLUDE_DIRS "") # Dont want these added as 'timer.h' is a dangerous file -mark_as_advanced(ALSA_INCLUDE_DIRS ALSA_LIBRARIES) -list(APPEND ALSA_DEFINITIONS -DHAVE_ALSA=1 -DUSE_ALSA=1) +mark_as_advanced(ALSA_INCLUDE_DIR ALSA_LIBRARY) -- cgit v1.2.3