# RTAUDIO_FOUND
# RTAUDIO_INCLUDE_DIR
# RTAUDIO_LIBRARY
# RTAUDIO_DEFINITIONS
# RTAUDIO_VERSION_STRING

find_package(PkgConfig)
include(FindPackageHandleStandardArgs)

pkg_check_modules(PK_RTAUDIO rtaudio)

set(RTAUDIO_DEFINITIONS ${PK_RTAUDIO_CFLAGS_OTHER})
set(RTAUDIO_VERSION_STRING ${PK_RTAUDIO_VERSION})

find_path(
  RTAUDIO_INCLUDE_DIR RtAudio.h
  HINTS ${PK_RTAUDIO_INCLUDEDIR} ${PK_RTAUDIO_INCLUDE_DIRS})

find_library(
  RTAUDIO_LIBRARY NAMES rtaudio
  HINTS ${PK_RTAUDIO_LIBDIR} ${PK_RTAUDIO_LIBRARY_DIRS})

find_package_handle_standard_args(
  RtAudio
  REQUIRED_VARS RTAUDIO_LIBRARY RTAUDIO_INCLUDE_DIR
  VERSION_VAR RTAUDIO_VERSION_STRING)

mark_as_advanced(RTAUDIO_INCLUDE_DIR RTAUDIO_LIBRARY)

# Provide a modern cmake imported target
add_library(RtAudio::rtaudio STATIC IMPORTED)
set_property(TARGET RtAudio::rtaudio PROPERTY IMPORTED_LOCATION ${RTAUDIO_LIBRARY})
target_include_directories(RtAudio::rtaudio INTERFACE ${RTAUDIO_INCLUDE_DIR})
