if(SOUND_BACKEND STREQUAL "xaudio2")
  if(NOT PLATFORM_BACKEND STREQUAL "uwp")
    message(FATAL_ERROR "SOUND_BACKEND=xaudio2 requires PLATFORM_BACKEND=uwp.")
  endif()
  # The sound rules below, over XAudio2 in place of SDL (AUDIO_DEVICE_XAUDIO2.CPP
  # replaces COMMON.CPP and AUDIO_DEVICE.CPP, the SDL transport).
  set(AIL_SDL_SOURCES CD.CPP MIDI.CPP SAMPLE.CPP STREAM.CPP WAV_STREAM.CPP WAV_DECODE.CPP AUDIO_DEVICE_XAUDIO2.CPP VOC_HEADER.CPP stb_vorbis.c)
else()
  set(AIL_SDL_SOURCES CD.CPP COMMON.CPP MIDI.CPP SAMPLE.CPP STREAM.CPP WAV_STREAM.CPP AUDIO_DEVICE.CPP VOC_HEADER.CPP stb_vorbis.c)
endif()
if(MVIDEO_BACKEND STREQUAL "smacker")
  list(APPEND AIL_SDL_SOURCES VIDEO_AUDIO_SDL.CPP)
endif()
target_sources(ail PRIVATE ${AIL_SDL_SOURCES})
if(SOUND_BACKEND STREQUAL "xaudio2")
  target_compile_definitions(ail PUBLIC USE_SOUND_XAUDIO2 PRIVATE LBA2_AIL_XAUDIO2=1)
  target_link_libraries(ail PRIVATE xaudio2_9)
  return()
endif()
target_compile_definitions(ail PUBLIC USE_SOUND_SDL)
if(PLATFORM_BACKEND STREQUAL "sdl2")
  target_compile_definitions(ail PRIVATE LBA2_USE_SDL2=1)
endif()
target_link_libraries(ail PRIVATE ${LBA2_SDL_TARGET})
