# libopenmpt detection
find_library(LIBOPENMPT NAMES openmpt)
if (NOT "${LIBOPENMPT}" STREQUAL "LIBOPENMPT-NOTFOUND")
  add_plugin("src/plugins/libopenmptdecoder" "openmptdecoder")
endif()

# systemd / MPRIS detection
if (NOT ENABLE_MPRIS MATCHES "false")
  find_library(LIB_SYSTEMD NAMES systemd)
  if (NOT LIB_SYSTEMD MATCHES "LIB_SYSTEMD-NOTFOUND")
    message(STATUS "[mpris] systemd found at " ${LIB_SYSTEMD})
    message(STATUS "[mpris] setting ENABLE_MPRIS=true")
    set(ENABLE_MPRIS "true")
  else()
    message(STATUS "[mpris] systemd *not* found. MPRIS plugin not enabled")
    set(ENABLE_MPRIS "false")
  endif()
endif()

if (CMAKE_SYSTEM_NAME MATCHES "Linux")
  add_plugin("src/plugins/alsaout" "alsaout")
  add_plugin("src/plugins/pulseout" "pulseout")
  if (${ENABLE_PIPEWIRE} MATCHES "true")
    add_plugin("src/plugins/pipewireout" "pipewireout")
  endif()
  if (${ENABLE_MPRIS} MATCHES "true")
    add_plugin("src/plugins/mpris" "mpris")
  endif()
  if (${ENABLE_SNDIO} MATCHES "true")
    add_plugin("src/plugins/sndioout" "sndioout")
  endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
  add_subdirectory(src/plugins/sndioout)
  if (${ENABLE_PULSEAUDIO} MATCHES "true")
    add_plugin("src/plugins/pulseout" "pulseout")
  endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
  add_subdirectory(src/plugins/sndioout)
  if (${ENABLE_PULSEAUDIO} MATCHES "true")
    add_plugin("src/plugins/pulseout" "pulseout")
  endif()
  if (${ENABLE_ALSA} MATCHES "true")
    add_plugin("src/plugins/alsaout" "alsaout")
  endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
  add_plugin("src/plugins/coreaudioout" "coreaudioout")
  add_plugin("src/plugins/macosmediakeys" "macosmediakeys")
endif()