INCLUDE(vf_plugin)
INCLUDE(FindTar)

IF(NOT WIN32 AND NOT APPLE)
SET(ADM_vf_avsfilter_SRCS avsfilter.cpp avspipecomm.cpp cdebug.cpp strnew.cpp avsfilterparam_json.cpp)

ADD_LIBRARY(ADM_vf_avsfilter SHARED ${ADM_vf_avsfilter_SRCS})
INCLUDE(vf_plugin)

INIT_VIDEO_FILTER(ADM_vf_avsfilter)
INSTALL_VIDEO_FILTER(ADM_vf_avsfilter)
ADD_DEFINITIONS("-DVERSION_2_5 -DDEBUGMSG")
ADD_DEFINITIONS(-DAVS_WINE_BINARY_PATH="${CMAKE_INSTALL_PREFIX}/share/ADM6_addons/avsfilter")
ADD_TARGET_CFLAGS(ADM_vf_avsfilter "-I${AVIDEMUX_SOURCE_DIR}/avidemux_plugins")

IF(DO_SETTINGS)
message(STATUS "avsfilter binary uncompressed")
set(AVSFILTER_WINE_BINARY_ARCHIVE ${AVIDEMUX_SOURCE_DIR}/addons/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) 
ENDIF(DO_SETTINGS) 
ENDIF(NOT WIN32 AND NOT APPLE)
