1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00
Files
CMake/Modules/FindALSA.cmake
Peter Kokot 4e6a13f211 Use lower case style for commands
Where possible this syncs the CS for command names:

- check_c_source_compiles()
- check_cxx_compiler_flag()
- check_cxx_source_compiles()
- check_cxx_symbol_exists()
- check_include_file_cxx()
- check_include_file()
- check_include_files()
- check_library_exists()
- check_source_compiles()
- check_struct_has_member()
- check_symbol_exists()
- check_type_size()
- cmake_dependent_option()
- cmake_parse_arguments()
- feature_summary()
- file()
- find_package_handle_standard_args()
- if(), endif...
- install(FILES)
- list()
- message()
- pkg_check_modules()
- select_library_configurations()
- set_package_info()
- test_big_endian()
2025-01-28 13:51:46 -05:00

82 lines
2.3 KiB
CMake

# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
FindALSA
--------
Find Advanced Linux Sound Architecture (ALSA)
Find the alsa libraries (``asound``)
IMPORTED Targets
^^^^^^^^^^^^^^^^
.. versionadded:: 3.12
This module defines :prop_tgt:`IMPORTED` target ``ALSA::ALSA``, if
ALSA has been found.
Result Variables
^^^^^^^^^^^^^^^^
This module defines the following variables:
``ALSA_FOUND``
True if ALSA_INCLUDE_DIR & ALSA_LIBRARY are found
``ALSA_LIBRARIES``
List of libraries when using ALSA.
``ALSA_INCLUDE_DIRS``
Where to find the ALSA headers.
Cache variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``ALSA_INCLUDE_DIR``
the ALSA include directory
``ALSA_LIBRARY``
the absolute path of the asound library
#]=======================================================================]
cmake_policy(PUSH)
cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h
DOC "The ALSA (asound) include directory"
)
find_library(ALSA_LIBRARY NAMES asound
DOC "The ALSA (asound) library"
)
if(ALSA_INCLUDE_DIR AND EXISTS "${ALSA_INCLUDE_DIR}/alsa/version.h")
file(STRINGS "${ALSA_INCLUDE_DIR}/alsa/version.h" alsa_version_str REGEX "^#define[\t ]+SND_LIB_VERSION_STR[\t ]+\".*\"")
string(REGEX REPLACE "^.*SND_LIB_VERSION_STR[\t ]+\"([^\"]*)\".*$" "\\1" ALSA_VERSION_STRING "${alsa_version_str}")
unset(alsa_version_str)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(ALSA
REQUIRED_VARS ALSA_LIBRARY ALSA_INCLUDE_DIR
VERSION_VAR ALSA_VERSION_STRING)
if(ALSA_FOUND)
set( ALSA_LIBRARIES ${ALSA_LIBRARY} )
set( ALSA_INCLUDE_DIRS ${ALSA_INCLUDE_DIR} )
if(NOT TARGET ALSA::ALSA)
add_library(ALSA::ALSA UNKNOWN IMPORTED)
set_target_properties(ALSA::ALSA PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ALSA_INCLUDE_DIRS}")
set_property(TARGET ALSA::ALSA APPEND PROPERTY IMPORTED_LOCATION "${ALSA_LIBRARY}")
endif()
endif()
mark_as_advanced(ALSA_INCLUDE_DIR ALSA_LIBRARY)
cmake_policy(POP)