set(MODULE_NAME audio)

message(STATUS "Checking dependencies for module: " ${MODULE_NAME})
if (UNIX)
    find_package(ALSA QUIET)     
    if(ALSA_FOUND)
	    list(APPEND PLATFORM_HEADERS
	        audio_interfaces/AlsaInterface.h
	        ${ALSA_INCLUDE_DIRS})
	    list(APPEND PLATFORM_SOURCES
	        audio_interfaces/AlsaInterface.cpp
	    )
	    list(APPEND PLATFORM_LIBS
	        ${ALSA_LIBRARIES}
	    )
	    list(APPEND DEFINES "HAS_ALSA")    
	else()
		message(STATUS "ALSA not found - skipping support")
		list(APPEND PLATFORM_HEADERS
	        audio_interfaces/NullAudioInterface.h
	    )
	    list(APPEND PLATFORM_SOURCES
	        audio_interfaces/NullAudioInterface.cpp
	    )	
    endif()
else()
    list(APPEND PLATFORM_HEADERS
        audio_interfaces/WasapiInterface.h
    )
    list(APPEND PLATFORM_SOURCES
        audio_interfaces/WasapiInterface.cpp
    )
endif (UNIX)

list(APPEND HEADERS 
    AudioDevice.h
    AudioManager.h
    AudioTrack.h
    AudioSample.h
    AudioSynth.h
    AudioWriter.h
    audio_interfaces/IAudioInterface.h
    ${PLATFORM_HEADERS})

list(APPEND SOURCES 
    AudioDevice.cpp
    AudioManager.cpp
    AudioSample.cpp
    AudioSynth.cpp
    AudioTrack.cpp
    AudioWriter.cpp
    ${PLATFORM_SOURCES})

add_library(${MODULE_NAME} SHARED ${HEADERS} ${SOURCES})
target_include_directories(${MODULE_NAME} PUBLIC
                          ${CMAKE_CURRENT_SOURCE_DIR}
                          ${CMAKE_CURRENT_SOURCE_DIR}/audio_interfaces
                          )
                          
target_compile_definitions(${MODULE_NAME} PRIVATE ${DEFINES})
target_link_libraries(${MODULE_NAME} PUBLIC core ${PLATFORM_LIBS})
set_target_properties(${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)

set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src/media)