INCLUDE(vf_plugin)
INCLUDE(FindTar)

IF(NOT WIN32 AND NOT APPLE)

  SET(PLUGIN ADM_vf_avsfilter)
  ADD_VIDEO_FILTER(${PLUGIN} SHARED avsfilter.cpp avspipecomm.cpp cdebug.cpp strnew.cpp avsfilterparam_json.cpp)
  INCLUDE(vf_plugin)

  INIT_VIDEO_FILTER(${PLUGIN})
  INSTALL_VIDEO_FILTER(${PLUGIN})
  IF(DO_COMMON)
    TARGET_COMPILE_DEFINITIONS(${PLUGIN} PRIVATE VERSION_2_5 DEBUGMSG)
    TARGET_COMPILE_DEFINITIONS(${PLUGIN} PRIVATE AVS_WINE_BINARY_PATH="${CMAKE_INSTALL_PREFIX}/share/ADM6_addons/avsfilter")
    TARGET_INCLUDE_DIRECTORIES(${PLUGIN} PRIVATE "${AVIDEMUX_SOURCE_DIR}/avidemux_plugins")
  ENDIF()
  IF(DO_SETTINGS)
    MESSAGE(STATUS "avsfilter binary uncompressed")
    SET(AVSFILTER_WINE_BINARY_ARCHIVE ${CMAKE_SOURCE_DIR}/ADM_videoFilters6/avsfilter/avsload_pipe_binary.tar.bz2)
    SET(addonesInstallDir ${CMAKE_INSTALL_PREFIX}/share/ADM6_addons/avsfilter)
    SET(tempAvsFilterUnpackDir ${CMAKE_BINARY_DIR}/ADM_videoFilters6/avsfilter)
    #message(STATUS "AVSFILTER_WINE_BINARY_ARCHIVE" ${AVSFILTER_WINE_BINARY_ARCHIVE})
    #message(STATUS "addonesInstallDir" ${addonesInstallDir})
    #message(STATUS "tempAvsFilterUnpackDir" ${tempAvsFilterUnpackDir})
    FIND_PACKAGE(Tar)
    #message(STATUS "TAR FOUND ->""${TAR_EXECUTABLE}")
    EXECUTE_PROCESS(COMMAND ${TAR_EXECUTABLE} xvf ${AVSFILTER_WINE_BINARY_ARCHIVE} -C ${tempAvsFilterUnpackDir})
    #INSTALL(FILES ${tempAvsFilterUnpackDir}/avsload.exe ${tempAvsFilterUnpackDir}/pipe_source.dll DESTINATION ${addonesInstallDir} COMPONENT plugins)
    INSTALL(FILES ${tempAvsFilterUnpackDir}/avsload.exe ${tempAvsFilterUnpackDir}/pipe_source.dll DESTINATION ${addonesInstallDir} COMPONENT settings)
  ENDIF()
ENDIF()
