find_package(Boost REQUIRED COMPONENTS json)

add_executable(Record main.cpp
    $<$<BOOL:${CROSS_BUILD}>:RkAudio.h RkAudio.cpp>
    OpusCodec.h OpusCodec.cpp
    FFmpegResample.h FFmpegResample.cpp
    ProcessFile.cpp
    SpeexDsp.h SpeexDsp.cpp
    Utility.h Utility.cpp
    WebRtcAecm.h WebRtcAecm.cpp
    WebRTCPublisher.h WebRTCPublisher.cpp
    $<$<BOOL:${CROSS_BUILD}>:Player.cpp>
    $<$<BOOL:${CROSS_BUILD}>:EchoRecord.cpp>
    $<$<BOOL:${CROSS_BUILD}>:Recorder.cpp>
)

target_include_directories(Record
    PRIVATE ${ALSA_INCLUDE_DIR}
    PRIVATE ${MPP_INCLUDE_DIR}
    PRIVATE ${MPP_INCLUDE_DIR}/rkmedia
    PRIVATE /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/opus-1.4/include
    PRIVATE ${KINESIS_ROOT}/include
    PRIVATE /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/speexdsp-1.2.1/include
    PRIVATE ${FFMPEG_INCLUDE_DIR}
    # PRIVATE ${CMAKE_SOURCE_DIR}/rkap/include
)

target_link_directories(Record
    PRIVATE ${ALSA_LIBRARY_DIRS}
    PRIVATE ${MPP_LIBRARY_DIRS}
    PRIVATE ${3rdparty_ROOT}/rkap_3a/lib
    PRIVATE ${FFMPEG_LIBRARY_DIRS}
    PRIVATE /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/speexdsp-1.2.1/lib
    PRIVATE /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/opus-1.4/lib
    PRIVATE ${KINESIS_ROOT}/lib
    PRIVATE /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/usrsctp-0.9.5.0/lib
    PRIVATE /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/lib/libsrtp-2.6.0/lib
    # PRIVATE ${CMAKE_SOURCE_DIR}/rkap/lib
)

if(CROSS_BUILD)
    set(RK_LIBS
        asound
        easymedia
        drm
        rkaiq
        rockchip_mpp
        v4l2
        v4lconvert
        jpeg
        png16
        fontconfig
        freetype
        expat
        rga
        glib-2.0
        pcre
        RKAP_ANR
        RKAP_Common
        uuid
    )
endif()

target_link_libraries(Record
    PRIVATE VocieProcess
    PRIVATE absl::optional
    PRIVATE opus
    PRIVATE speexdsp
    PRIVATE Boost::json
    PRIVATE kvsCommonLws
    PRIVATE kvsWebrtcClient
    PRIVATE kvsWebrtcSignalingClient
    PRIVATE kvspic
    PRIVATE kvspicUtils
    PRIVATE kvspicClient
    PRIVATE usrsctp
    PRIVATE srtp2
    PRIVATE Universal
    PRIVATE HttpProxy
    PRIVATE stdc++fs
    PRIVATE dl
    PRIVATE z
    PRIVATE ${FFMPEG_LIBRARY}
    ${RK_LIBS}
    # PRIVATE RKAP_Common
    # PRIVATE RKAP_3A
)