# RTMIDI_FOUND
# RTMIDI_INCLUDE_DIR
# RTMIDI_LIBRARY
# RTMIDI_DEFINITIONS
# RTMIDI_VERSION_STRING

find_package(PkgConfig)
include(FindPackageHandleStandardArgs)

pkg_check_modules(PK_RTMIDI rtmidi)

set(RTMIDI_DEFINITIONS ${PK_RTMIDI_CFLAGS_OTHER})
set(RTMIDI_VERSION_STRING ${PK_RTMIDI_VERSION})

find_path(
  RTMIDI_INCLUDE_DIR RtMidi.h
  HINTS ${PK_RTMIDI_INCLUDEDIR} ${PK_RTMIDI_INCLUDE_DIRS})

find_library(
  RTMIDI_LIBRARY NAMES rtmidi
  HINTS ${PK_RTMIDI_LIBDIR} ${PK_RTMIDI_LIBRARY_DIRS})

find_package_handle_standard_args(
  RtMidi
  REQUIRED_VARS RTMIDI_LIBRARY RTMIDI_INCLUDE_DIR
  VERSION_VAR RTMIDI_VERSION_STRING)

mark_as_advanced(RTMIDI_INCLUDE_DIR RTMIDI_LIBRARY)

# Provide a modern cmake imported target:
add_library(RtMidi::rtmidi STATIC IMPORTED)
set_property(TARGET RtMidi::rtmidi PROPERTY IMPORTED_LOCATION ${RTMIDI_LIBRARY})
target_include_directories(RtMidi::rtmidi INTERFACE ${RTMIDI_INCLUDE_DIR})
