summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindAlsa.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/FindAlsa.cmake')
-rw-r--r--cmake/modules/FindAlsa.cmake46
1 files changed, 46 insertions, 0 deletions
diff --git a/cmake/modules/FindAlsa.cmake b/cmake/modules/FindAlsa.cmake
new file mode 100644
index 0000000..c99f509
--- /dev/null
+++ b/cmake/modules/FindAlsa.cmake
@@ -0,0 +1,46 @@
1#.rst:
2# FindAlsa
3# --------
4# Finds the Alsa library
5#
6# This will will define the following variables::
7#
8# ALSA_FOUND - system has Alsa
9# ALSA_INCLUDE_DIRS - the Alsa include directory
10# ALSA_LIBRARIES - the Alsa libraries
11# ALSA_DEFINITIONS - the Alsa compile definitions
12#
13# and the following imported targets::
14#
15# ALSA::ALSA - The Alsa library
16
17if(PKG_CONFIG_FOUND)
18 pkg_check_modules(PC_ALSA alsa QUIET)
19endif()
20
21find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h
22 PATHS ${PC_ALSA_INCLUDEDIR})
23find_library(ALSA_LIBRARY NAMES asound
24 PATHS ${PC_ALSA_LIBDIR})
25
26set(ALSA_VERSION ${PC_ALSA_VERSION})
27
28include(FindPackageHandleStandardArgs)
29find_package_handle_standard_args(Alsa
30 REQUIRED_VARS ALSA_LIBRARY ALSA_INCLUDE_DIR
31 VERSION_VAR ALSA_VERSION)
32
33if(ALSA_FOUND)
34 set(ALSA_INCLUDE_DIRS "") # Don't want these added as 'timer.h' is a dangerous file
35 set(ALSA_LIBRARIES ${ALSA_LIBRARY})
36 set(ALSA_DEFINITIONS -DHAVE_ALSA=1 -DUSE_ALSA=1)
37
38 if(NOT TARGET ALSA::ALSA)
39 add_library(ALSA::ALSA UNKNOWN IMPORTED)
40 set_target_properties(ALSA::ALSA PROPERTIES
41 IMPORTED_LOCATION "${ALSA_LIBRARY}"
42 INTERFACE_COMPILE_DEFINITIONS "${ALSA_DEFINITIONS}")
43 endif()
44endif()
45
46mark_as_advanced(ALSA_INCLUDE_DIR ALSA_LIBRARY)