PROJECT(Comparator)

cmake_minimum_required(VERSION 2.6)

FIND_PACKAGE(Boost COMPONENTS date_time filesystem regex system)
FIND_PACKAGE(MYSQL)

if(NOT Boost_FOUND)
	MESSAGE(FATAL_ERROR "Boost not found!")
endif(NOT Boost_FOUND)
if(UNIX)
	add_definitions(-DLINUX)
endif(UNIX)

include_directories (
	${Matrices_SOURCE_DIR}
	${Boost_INCLUDE_DIR}
	${Mysql_INCLUDE_DIR}
    "../matrices"
)
link_directories(${Matrices_BINARY_DIR}
		 ${Boost_BINARY_DIR})

set(filters_SRC filters/FilterFeature.cpp
	filters/FilterFeature01.cpp
	filters/FilterVector.cpp
	filters/NoiseFilter.cpp
	filters/entropy.cpp)

set(weights_SRC weights/CRMDt.cpp weights/CRmDmi.cpp 
	weights/MIWeight.cpp weights/LocalLogEntWeight.cpp
	weights/MIWeightQuantified.cpp
	weights/LocalToGlobalWeightFeature.cpp weights/LocalWeightFeature.cpp
	weights/LogEntNormalizeWeight.cpp weights/LogEntWeight.cpp
	weights/MLEWeightFeature.cpp weights/MatrixTransformer.cpp
	weights/NormalizeWeight.cpp 
	weights/RWFZScore.cpp weights/TScoreWeight.cpp
	weights/TfidfNormalizeWeight.cpp
	weights/TfidfWeight.cpp weights/WeightFeature.cpp weights/SimpleMIWeight.cpp
	weights/PMINoLog.cpp
	weights/RWFBase.cpp
	weights/RWFAnyWeight.cpp
	weights/RWFPMIWeight.cpp weights/RWFLinWeight.cpp
	weights/RFFWeight.cpp
	weights/RankBuilder.cpp
	weights/RWFLinFilteredWeight.cpp
	weights/ContingencyTableWeight.cpp
	weights/RWFLogLikelihood.cpp
	weights/RWFEvertsMI.cpp
	weights/RWFChi2.cpp
	weights/RWFNoWeight.cpp
	weights/QuantizationWeight.cpp
	weights/FunctionScaledWeight.cpp
	weights/RowScaledWeight.cpp
	weights/ColumnScaledWeight.cpp
	weights/BoundaryScaledWeight.cpp
	weights/EvertsMI.cpp
	weights/LogLikelihood.cpp
	weights/Chi2.cpp
	weights/ZScore.cpp
	weights/Beta.cpp
	weights/CTBasedWeight.cpp
	weights/FirstKulczynsky.cpp
	weights/UnigramSubtuples.cpp
	weights/SCost.cpp
	weights/IdfWeight.cpp
	)

set(simfunctions_SRC simfunctions/CosineFilterSimilarity.cpp
	simfunctions/CosineFunction.cpp simfunctions/EhlertSimilarity.cpp
	simfunctions/IRad.cpp simfunctions/LinSimilarity.cpp
	simfunctions/LocalCosineSimilarity.cpp
	simfunctions/LocalSimilarityFunction.cpp simfunctions/PEntP.cpp
	simfunctions/SimCRM.cpp simfunctions/SimilarityFunction.cpp
	simfunctions/SHD.cpp simfunctions/MCFSim.cpp
	simfunctions/filesimfunction.cpp
	simfunctions/Dice.cpp
	simfunctions/DiceBugged.cpp
	simfunctions/Jaccard.cpp
	simfunctions/DistanceSim.cpp
	simfunctions/RatioSim.cpp
	simfunctions/IntersectionScaledSimilarity.cpp
	simfunctions/PartialMSR.cpp
	simfunctions/PartialMSR2Base.cpp
	simfunctions/PartialMSR2A.cpp
	simfunctions/PartialMSR2B.cpp
	simfunctions/PartialMSR2Bp.cpp
	simfunctions/partialmsr/LexicalUnit.cpp	# stored in folder because of many files
	simfunctions/partialmsr/Synset.cpp
	simfunctions/partialmsr/SynsetClass.cpp
	simfunctions/partialmsr/SynsetClassSet.cpp
	simfunctions/partialmsr/DBManagerMySQL.cpp
	simfunctions/Bhattacharyya.cpp
	)

set(selectors_SRC selectors/RelativeTScoreKBestSelector.cpp
	selectors/RowRelativeSelector.cpp selectors/Selector.cpp
	selectors/TScoreKBestSelector.cpp selectors/TScoreSelector.cpp
	selectors/FrequencySelector.cpp
	selectors/rffselector.cpp
	)

set(transformations_SRC
	transformations/SimMatrixTransformation.cpp
	transformations/Transformation.cpp
	transformations/GenericTransformer.cpp
	transformations/LDATransformation.cpp
	transformations/SVDTransformation.cpp)

SET(SVD_EXECUTABLE "SVD_EXECUTABLE-NOTFOUND" CACHE FILEPATH "svd executalbe")
FIND_PROGRAM(SVD_EXECUTABLE NAMES svd PATHS ${SVD_DIR})
IF(EXISTS ${SVD_EXECUTABLE})
	add_definitions(-DSVD="1")
	MESSAGE(STATUS "Found SVD in ${SVD_DIR}")
ELSE(EXISTS ${SVD_EXECUTABLE})
	add_definitions(-DSVD="0")
	MESSAGE(WARNING "Could not find SVD executable")
ENDIF(EXISTS ${SVD_EXECUTABLE})

FIND_PACKAGE(gensim)
set(compare_SRC 
	compare/Comparator.cpp 
	compare/CompareFunction.cpp
	compare/DoubleCompare.cpp  
	compare/RWFZScoreRankComparision.cpp #still used in: clustering/cbc/cbc
	compare/PMIComparision.cpp #stil used in clustering/cbc/cbc
	compare/FunctionFactory.cpp
	compare/FunctionFactory2.cpp
	compare/MILinsComparision.cpp #still used in: clustering/cbc/cbc and tools/wbst_simfunction_tester
	compare/CombinedCompareFunction.cpp
	compare/SimpleCombinedCompareFunction.cpp 
	compare/RWFMILinComparision.cpp #still used in:clustering/cbc/cbc
	compare/domaincomparator.cpp
	compare/EnsembleCompareFunction.cpp
	compare/RWFLinScaled.cpp #still used in: comparator/compare/FunctionFactory
	compare/RankEnsembleCompareFunction.cpp
	)

set(distances_SRC
    distances/Distance.cpp
    distances/MinkowskiDist.cpp
    distances/EuclidianDist.cpp)


add_library (comparator SHARED ${filters_SRC} ${weights_SRC}
	${simfunctions_SRC} ${selectors_SRC} ${transformations_SRC}
	${distributions_SRC} ${compare_SRC} ${distances_SRC})

target_link_libraries(comparator ${LOG4CXX_LIBRARY})

target_link_libraries (comparator ${Boost_LIBRARIES})

target_link_libraries (comparator ${Mysql++_LIBRARY})


if(NOT WIN32)
	target_link_libraries(comparator matrices)
else(NOT WIN32)
	target_link_libraries(comparator matrices)
endif(NOT WIN32)

install(TARGETS comparator
	LIBRARY DESTINATION lib)

install(
	DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
	DESTINATION include
	FILES_MATCHING PATTERN "*.h"
	PATTERN ".svn" EXCLUDE
	PATTERN "bin" EXCLUDE
	PATTERN "build" EXCLUDE	
	PATTERN "CMake*" EXCLUDE
    PATTERN "debian" EXCLUDE
)
