option(WITH_DFM "Enable DFM appearance model" OFF)
option(WITH_PCA "Enable PCA appearance model" ON)

set(APPEARANCE_MODULES AMParams ImageBase SSDBase)
set(APPEARANCE_MODELS SSD NSSD ZNCC SCV LSCV RSCV LRSCV CCRE LKLD MI HIST SSIM NCC SPSS KLD RIU NGF SAD MCSSD MCSCV MCLSCV MCRSCV MCZNCC MCNCC MCMI MCCCRE MCSSIM MCSPSS MCRIU MCSAD SumOfAMs)
set(ILLUMINATION_MODELS GB PGB RBF)

if(WITH_DFM)	
	find_package(Caffe)
	if(Caffe_FOUND)
		set(APPEARANCE_MODELS ${APPEARANCE_MODELS} DFM)
		set(MTF_EXT_INCLUDE_DIRS ${MTF_EXT_INCLUDE_DIRS} ${Caffe_INCLUDE_DIRS})
		set(MTF_LIBS ${MTF_LIBS} ${Caffe_LIBRARIES})
		set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/src/DFM.cc PROPERTIES COMPILE_FLAGS ${Caffe_DEFINITIONS})
	else(Caffe_FOUND)
		message(STATUS "Caffe not found so DFM AM cannot be enabled")
		set(MTF_DEFINITIONS ${MTF_DEFINITIONS} DISABLE_DFM)
	endif(Caffe_FOUND)
else(WITH_DFM)
	message(STATUS "DFM disabled")
	set(MTF_DEFINITIONS ${MTF_DEFINITIONS} DISABLE_DFM)	
endif(WITH_DFM)

if(WITH_PCA)
	set(APPEARANCE_MODELS ${APPEARANCE_MODELS} PCA MCPCA)
else(WITH_PCA)
	message(STATUS "PCA disabled")
	set(MTF_DEFINITIONS ${MTF_DEFINITIONS} DISABLE_PCA)	
endif(WITH_PCA)

addPrefixAndSuffix("${APPEARANCE_MODULES}" "AM/src/" ".cc" APPEARANCE_MODULES_SRC)
addPrefixAndSuffix("${APPEARANCE_MODELS}" "AM/src/" ".cc" APPEARANCE_MODELS_SRC)
addPrefixAndSuffix("${ILLUMINATION_MODELS}" "AM/src/" ".cc" ILLUMINATION_MODELS_SRC)
set(MTF_SRC ${MTF_SRC} ${APPEARANCE_MODULES_SRC} ${APPEARANCE_MODELS_SRC} ${ILLUMINATION_MODELS_SRC})
set(MTF_INCLUDE_DIRS ${MTF_INCLUDE_DIRS} AM/include)
