set(PLAYER_LIB_HEADERS
        ${PLAYER_LIB_INC}/Cancellable.hpp
        ${PLAYER_LIB_INC}/MediaDecoder.hpp
        ${PLAYER_LIB_INC}/Error.hpp
        ${PLAYER_LIB_INC}/MediaFormat.hpp
        ${PLAYER_LIB_INC}/Log.hpp
        ${PLAYER_LIB_INC}/MediaType.hpp
        ${PLAYER_LIB_INC}/Player.hpp
        ${PLAYER_LIB_INC}/MediaResult.hpp
        ${PLAYER_LIB_INC}/Quality.hpp
        ${PLAYER_LIB_INC}/ReferenceClock.hpp
        ${PLAYER_LIB_INC}/MediaRenderer.hpp
        ${PLAYER_LIB_INC}/MediaResult.hpp
        ${PLAYER_LIB_INC}/MediaSample.hpp
        ${PLAYER_LIB_INC}/SecureSampleBuffer.hpp
        ${PLAYER_LIB_INC}/MediaSink.hpp
        ${PLAYER_LIB_INC}/MediaSource.hpp
        ${PLAYER_LIB_INC}/MediaTime.hpp
        ${PLAYER_LIB_INC}/TimeRange.hpp
        ${PLAYER_LIB_INC}/platform/Platform.hpp
        ${PLAYER_LIB_INC}/platform/NativePlatform.hpp
        ${PLAYER_LIB_INC}/platform/HttpClient.hpp
        ${PLAYER_LIB_INC}/platform/HttpStatus.hpp
        ${PLAYER_LIB_INC}/platform/HttpMethod.hpp
        ${PLAYER_LIB_INC}/platform/HttpRequest.hpp
        ${PLAYER_LIB_INC}/platform/HttpResponse.hpp
        ${PLAYER_LIB_INC}/platform/Scheduler.hpp
        ${PLAYER_LIB_INC}/platform/VideoRenderer.hpp
)
set(PLAYER_SRCS
        ${PLAYER_LIB_HEADERS}
        AsyncHttpClient.hpp
        AsyncHttpClient.cpp
        AsyncHttpRequest.hpp
        AsyncHttpRequest.cpp
        AsyncHttpResponse.hpp
        AsyncHttpResponse.cpp
        BufferControl.hpp
        BufferControl.cpp
        BufferRange.hpp
        BufferState.hpp
        BufferState.cpp
        cancellation.hpp
        AsyncMediaPlayer.hpp
        AsyncMediaPlayer.cpp
        MediaPlayer.hpp
        MediaPlayer.cpp
        MediaRequest.hpp
        MediaRequest.cpp
        MultiSource.hpp
        MultiSource.cpp
        NativePlatform.cpp
        PassthroughSource.hpp
        PassthroughSource.cpp
        CompositeListener.hpp
        Playhead.hpp
        Playhead.cpp
        Qualities.hpp
        Qualities.cpp
        MediaResult.cpp
        Settings.cpp
        Settings.hpp
        ScopedScheduler.hpp
        ScopedScheduler.cpp
        VideoStatistics.hpp
)

set(MEDIAPLAYER_DEPENDENCIES
    analytics
    debug2
    file
    mediamp4
    mediamp2t
    json11
    caption # CMake doesn't seem to understand that captions depends on caption and doesn't properly clone before the libcaption sub-module leading to a race condition where the include files are not available to build MediaPlayer
    abr
    sink
    twitch
    media
    util
)

add_submodule(mediaplayer
  SOURCES
    ${PLAYER_SRCS}
  LINK_LIBRARIES
    ${MEDIAPLAYER_DEPENDENCIES}
)

target_include_directories(mediaplayer PUBLIC ${PLAYER_LIB_INC})

if(BUILD_UNIFIED_LIB)
  # TODO: Create "PRIVATE_HEADERS" option for add_submodule()
  target_include_directories(mediaplayer_obj PRIVATE ${PLAYER_LIB_INC})
endif()
