# SimAnn - Simulated Annealing Method for cell tracking in 3D+time 
# Written in 2015 by BioEmergences CNRS USR bioemergences@inaf.cnrs-gif.fr
# Paul Bourgine paul.bourgine@polytechnique.edu
# Alessandro Sarti alessandro.sarti@ehess.fr
# Camilo Melani camilomelani@gmail.com
# Rene Doursat rene.doursat@inaf.cnrs-gif.fr
# 
# To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC BY-NC-SA 4.0 Dedication along with this software. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode>.

PROJECT( mainParallelTracking )
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../EXE)


cmake_minimum_required( VERSION 2.6 FATAL_ERROR )


FIND_PACKAGE(VTK)
IF(VTK_FOUND)
        INCLUDE(${USE_VTK_FILE})
ENDIF(VTK_FOUND)

add_definitions ("-w")


INCLUDE_DIRECTORIES ( ${MPI_INCLUDE_PATH} )
LINK_DIRECTORIES ( ${MPI_LIBRARIES} )
find_package(MPI REQUIRED)


INCLUDE_DIRECTORIES ( ${BOOST_INCLUDEDIR} )
LINK_DIRECTORIES ( ${BOOST_LIBRARYDIR} )

find_package(Boost REQUIRED)
find_package(Boost COMPONENTS system filesystem date_time program_options serialization mpi graph_parallel REQUIRED)


INCLUDE_DIRECTORIES(${ANN_DIR}/include )
LINK_DIRECTORIES(${ANN_DIR}/lib)

SET(LIB_ANN_NAME ANN )

##########

#####Without this change I can not build the project
#SET(myflags  ${CMAKE_CXX_FLAGS} )
#STRING(REGEX REPLACE "-ftemplate-depth-50" "-ftemplate-depth-200" myflags ${myflags})
#SET(CMAKE_CXX_FLAGS  "-fpermissive ${myflags}"  )
#########





######### CELL ########


SET(CELL_LIBRARY_SRCS
EmbryoLib/Cell/CelluleType.cxx
)
SET(CELL_LIBRARY_HEADS
EmbryoLib/Cell/CelluleType.h
)






######### EMBRYO ########
SET(EMBRYO_LIBRARY_SRCS
#		EmbryoLib/ImageProvider/ImageProvider.cxx
)
SET(EMBRYO_LIBRARY_HEADS
		EmbryoLib/Embryo/GraphCellType.h
		EmbryoLib/Embryo/MultiTimeSetPoint.h
		EmbryoLib/Parallel/ParallelGraphCellType.h
		EmbryoLib/Embryo/EmbryoType.h
		EmbryoLib/EmbryoState/EmbryoStateType.h
		EmbryoLib/EmbryoState/SetPointsWithLocator.h
		EmbryoLib/EmbryoState/SortPoints3.h
		EmbryoLib/Parallel/Recorder.h
#		EmbryoLib/ImageProvider/ImageProvider.h
)


######### MINIMIZER ########
SET(MINIMIZER_LIBRARY_SRCS
		EmbryoLib/Minimizer/SimulatedAnnealing.cxx
)
SET(MINIMIZER_LIBRARY_HEADS

		EmbryoLib/Minimizer/CommandType.h
		EmbryoLib/Minimizer/EnergyType.h
		EmbryoLib/Minimizer/SimulatedAnnealing.h
		EmbryoLib/Minimizer/SingularCallBack.h
		EmbryoLib/Minimizer/Solution.h
		EmbryoLib/LineageConstructor/LineageConstructor.h
)

############# Common ########

SET(COMMON_LIBRARY_HEADS
		EmbryoLib/Common/functions.h
		EmbryoLib/Common/definitions.h
		EmbryoLib/Common/Convert.h
		EmbryoLib/Common/IOfunctions.h
		EmbryoLib/Common/BoxType4d.h
)

############# Common ########

SET(IO_LIBRARY_SRCS
		EmbryoLib/IO/Disk.cxx
		EmbryoLib/Parallel/ParallelDisk.cxx
)

SET(IO_LIBRARY_HEADS
		EmbryoLib/IO/Disk.h
		EmbryoLib/Parallel/ParallelDisk.h
)

###################mpi####

INCLUDE_DIRECTORIES(
		   EmbryoLib/EmbryoState
		   EmbryoLib/Cell
		   EmbryoLib/Embryo
		   EmbryoLib/Minimizer
		   EmbryoLib/Common
		   EmbryoLib/EmbryoStatistic
		   EmbryoLib/LineageConstructor
#          EmbryoLib/ImageProvider
           EmbryoLib/IO
           EmbryoLib/Parallel
)


SET(CMAKE_C_COMPILER ${MPI_C_COMPILER})
SET(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})

##############

ADD_EXECUTABLE(${PROJECT_NAME}
       ${PROJECT_NAME}.cxx
        ${CELL_LIBRARY_SRCS}
		${CELL_LIBRARY_HEADS} 
		${EMBRYO_LIBRARY_SRCS}
		${EMBRYO_LIBRARY_HEADS} 
		${MINIMIZER_LIBRARY_SRCS}
		${MINIMIZER_LIBRARY_HEADS} 
		${COMMON_LIBRARY_HEADS} 
		${IO_LIBRARY_SRCS} 
		${IO_LIBRARY_HEADS} 
	)

message (" Boost_LIBRARIES= " ${Boost_LIBRARIES})
message (" MPI_LIBRARIES= " ${MPI_LIBRARIES})
          
TARGET_LINK_LIBRARIES (${PROJECT_NAME} ${Boost_LIBRARIES} ${LIB_ANN_NAME} ${MPI_LIBRARIES})


