FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_LIBALSA QUIET alsa)
SET(LIBALSA_DEFINITIONS ${PC_LIBALSA_CFLAGS_OTHER})

FIND_PATH(LIBALSA_INCLUDE_DIR alsa/asoundlib.h
          HINTS ${PC_LIBALSA_INCLUDEDIR} ${PC_LIBALSA_INCLUDE_DIRS}
          PATH_SUFFIXES alsa )

FIND_LIBRARY(LIBALSA_LIBRARY NAMES asound
             HINTS ${PC_LIBALSA_LIBDIR} ${PC_LIBALSA_LIBRARY_DIRS} )

SET(LIBALSA_LIBRARIES ${LIBALSA_LIBRARY} )
SET(LIBALSA_INCLUDE_DIRS ${LIBALSA_INCLUDE_DIR} )

INCLUDE(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBALSA_FOUND to TRUE
# if all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibAlsa  DEFAULT_MSG
                                  LIBALSA_LIBRARY LIBALSA_INCLUDE_DIR)

MARK_AS_ADVANCED(LIBALSA_INCLUDE_DIR LIBALSA_LIBRARY )
