INCLUDE(admCheckFreeType)
INCLUDE(admCheckFribidi)
INCLUDE(admCheckFontConfig)
ADD_CORE_INCLUDE(ADM_coreSubtitles)
checkFreeType()
checkFribidi("0.19")
IF(USE_FREETYPE AND USE_FRIBIDI)
  INCLUDE(vf_plugin)
  ADD_VIDEO_FILTER(ADM_vf_ssa ADM_vidASS.cpp)

  IF(DO_COMMON)
    MESSAGE(STATUS "Checking for libass")
    MESSAGE(STATUS "*******************")
    PKG_CHECK_MODULES(LIBASS libass)
    IF(LIBASS_FOUND)
      TARGET_COMPILE_OPTIONS(ADM_vf_ssa PRIVATE ${LIBASS_CFLAGS})
      MESSAGE(STATUS "   found, lib is ${LIBASS_LIBRARIES}")
    ELSE()
      MESSAGE(FATAL_ERROR "Cant locate libass ! cancelling")
    ENDIF()
    TARGET_LINK_LIBRARIES(ADM_vf_ssa PRIVATE ${LIBASS_LIBRARIES} adm_freetype adm_fontconfig adm_fribidi  ADM_coreSubtitles6 ${LIBASS_LDFLAGS})
    TARGET_LINK_DIRECTORIES(ADM_vf_ssa PRIVATE ${LIBASS_LIBRARY_DIR} ${LIBASS_LIBRARY_DIRS})
    # We force the use of fontconfig
    TARGET_COMPILE_DEFINITIONS(ADM_vf_ssa PRIVATE "USE_FONTCONFIG")
    # Add a simple probe program, only on linux/bsd/...
    IF(WIN32 OR APPLE)
    ELSE()
      ADD_EXECUTABLE(freetype_probe probe.cpp)
      TARGET_LINK_LIBRARIES(freetype_probe PRIVATE adm_freetype  adm_fribidi  adm_fontconfig)
    ENDIF()
  ENDIF()

  INIT_VIDEO_FILTER(ADM_vf_ssa)
  INSTALL_VIDEO_FILTER(ADM_vf_ssa)
ELSE()
  MESSAGE(STATUS "Fribidi or feetype missing, skipping filter")
ENDIF()
