MACRO(ADD_IF_ENABLED x)
  TARGET_SOURCES(ADM_videoCodec6 PRIVATE ${ARGN})
ENDMACRO()

ADD_LIBRARY(ADM_videoCodec6 STATIC)
TARGET_LINK_LIBRARIES(ADM_videoCodec6 PRIVATE ADM_render6_interface)
TARGET_INCLUDE_DIRECTORIES(ADM_videoCodec6 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)

TARGET_SOURCES(ADM_videoCodec6 PRIVATE
        ADM_videoCodec.cpp
        ADM_dynVideoDecoder.cpp)

# Dont try to use accel codec in non GUI mode
IF("${UI_TYPE}" STREQUAL "ADM_UI_QT4")

  IF(USE_VDPAU)
    ADD_CORE_INCLUDE(ADM_coreVdpau)
    ADD_IF_ENABLED(USE_VDPAU ADM_ffmpeg_vdpau.cpp)
  ENDIF()

  IF(USE_LIBVA)
    ADD_DEFINITIONS(${LIBVA_CFLAGS})
    TARGET_INCLUDE_DIRECTORIES(ADM_videoCodec6 PRIVATE ${LIBVA_INCLUDE_DIR})
    ADD_CORE_INCLUDE(ADM_coreLibVA)
    ADD_IF_ENABLED(USE_LIBVA ADM_ffmpeg_libva.cpp)
  ENDIF()
  IF(USE_DXVA2)
    TARGET_INCLUDE_DIRECTORIES(ADM_videoCodec6 PRIVATE ${DXVA_INCLUDE_DIR})
    TARGET_LINK_LIBRARIES(ADM_videoCodec6 PUBLIC  ADM_coreDxva26)
    ADD_IF_ENABLED(USE_DXVA2 ADM_ffmpeg_dxva2.cpp)
  ENDIF()
  IF(USE_VIDEOTOOLBOX)
    ADD_IF_ENABLED(USE_VIDEOTOOLBOX ADM_ffmpeg_videotoolbox.cpp)
  ENDIF()
  IF(USE_NVENC)
    ADD_DEFINITIONS(${FFNVENC_CFLAGS})
    TARGET_INCLUDE_DIRECTORIES(ADM_videoCodec6 PRIVATE ${NVENC_INCLUDE_DIR})
    ADD_IF_ENABLED(USE_NVENC ADM_ffmpeg_nvdec.cpp)
    IF(UNIX AND NOT APPLE)
      TARGET_LINK_LIBRARIES(ADM_videoCodec6 PRIVATE "-ldl")
    ENDIF()
  ENDIF()
ENDIF()

TARGET_LINK_LIBRARIES(ADM_videoCodec6 PUBLIC  adm_pthread ADM_editor6_interface ADM_videoFilter6_interface)
