
set(platform_HEADERS "")
set(platform_INCLUDES "")

if (UNIX)
    find_package(ALSA REQUIRED)     
    list(APPEND platform_HEADERS
        audio_interfaces/AlsaInterface.h
        ${ALSA_INCLUDE_DIRS}
    )
    list(APPEND platform_INCLUDES
        audio_interfaces/AlsaInterface.cpp
    )
    list(APPEND platform_LIBS
        ${ALSA_LIBRARIES}
    )
else()
    list(APPEND platform_HEADERS
        audio_interfaces/WasapiInterface.h
    )
    list(APPEND platform_INCLUDES
        audio_interfaces/WasapiInterface.cpp
    )
endif (UNIX)

list(APPEND audio_HEADERS 
    AudioDevice.h
    AudioManager.h
    AudioTrack.h
    AudioSample.h
    AudioSynth.h
    AudioWriter.h
    audio_interfaces/IAudioInterface.h
    midi/reader/MidiReader.h
    midi/MidiTrack.h
    midi/MidiDocument.h
    midi/MidiElements.h
    midi/MidiEvent.h
    midi/MetaMidiEvent.h
    midi/MidiChannelEvent.h
    ${platform_HEADERS})

list(APPEND audio_LIB_INCLUDES 
    AudioDevice.cpp
    AudioManager.cpp
    AudioSample.cpp
    AudioSynth.cpp
    AudioTrack.cpp
    AudioWriter.cpp
    midi/reader/MidiReader.cpp
    midi/reader/MidiTimeAdapter.cpp
    midi/reader/MidiMetaEventAdapter.cpp
    midi/reader/MidiChannelEventAdapter.cpp
    midi/MidiTrack.cpp
    midi/MidiDocument.cpp
    midi/MidiEvent.cpp
    midi/MetaMidiEvent.cpp
    midi/MidiChannelEvent.cpp
    ${platform_INCLUDES})

add_library(audio SHARED ${audio_LIB_INCLUDES} ${platform_INCLUDES} ${audio_HEADERS} ${platform_HEADERS})
target_include_directories(audio PUBLIC
                          "${CMAKE_CURRENT_SOURCE_DIR}"
                          "${PROJECT_SOURCE_DIR}/src/core/file_utilities"
                          "${PROJECT_SOURCE_DIR}/src/core/loggers"
                          "${CMAKE_CURRENT_SOURCE_DIR}/audio_interfaces"
                          "${CMAKE_CURRENT_SOURCE_DIR}/midi"
                          "${CMAKE_CURRENT_SOURCE_DIR}/midi/reader"
                          )
                          
target_link_libraries(audio PUBLIC core ${platform_LIBS})
set_target_properties( audio PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
set_property(TARGET audio PROPERTY FOLDER src)