add_library(RtMidi STATIC EXCLUDE_FROM_ALL "thirdparty/rtmidi/RtMidi.cpp")
target_include_directories(RtMidi PUBLIC "thirdparty/rtmidi")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  target_compile_definitions(RtMidi PUBLIC "__LINUX_ALSA__")
  target_link_libraries(RtMidi PUBLIC "asound")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  target_compile_definitions(RtMidi PUBLIC "__WINDOWS_MM__")
  target_link_libraries(RtMidi PUBLIC "winmm")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  target_compile_definitions(RtMidi PUBLIC "__MACOSX_CORE__")
  find_library(COREMIDI_LIBRARY "CoreMIDI")
  find_library(FOUNDATION_LIBRARY "Foundation")
  target_link_libraries(RtMidi PUBLIC "${COREMIDI_LIBRARY}" "${FOUNDATION_LIBRARY}")
endif()
if(JACK_FOUND)
  target_compile_definitions(RtMidi PUBLIC "__UNIX_JACK__")
  target_include_directories(RtMidi PUBLIC ${JACK_INCLUDE_DIRS})
  link_directories(${JACK_LIBRARY_DIRS})
  target_link_libraries(RtMidi PUBLIC ${JACK_LIBRARIES})
endif()
