PROJECT(AutoMosaic)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

SET(CMAKE_COLOR_MAKEFILE ON)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

# Allow advanced users to generate Makefiles printing detailed commands
MARK_AS_ADVANCED(CMAKE_VERBOSE_MAKEFILE)

# Path to additional CMake modules
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules ${CMAKE_MODULE_PATH})
SET(CMAKE_DEBUG_POSTFIX "d")

#large address aware option setting
IF(${MINGW})
	SET(LARGEADDRESSAWARE "--large-address-aware")
ELSE(${MINGW})
	IF (WIN32)
		SET(LARGEADDRESSAWARE "/LARGEADDRESSAWARE")
	ELSE (WIN32)
		SET(LARGEADDRESSAWARE " ")
	ENDIF (WIN32)
ENDIF (${MINGW})

IF (WIN32)
	SET(APP_OPT "WIN32")
ELSE (WIN32)
	IF (APPLE)
		#SET(APP_OPT "MACOSX_BUNDLE")
		SET(APP_OPT "EXCLUDE_FROM_ALL")
	ELSE (APPLE)
		SET(APP_OPT " ")
	ENDIF (APPLE)
ENDIF (WIN32)

# OpenMP
FIND_PACKAGE(OpenMP)
IF(OPENMP_FOUND)
	OPTION(WITH_OPENMP "Whether to use parallel processing capabilities of OPENMP. ON/OFF" ON)
ENDIF(OPENMP_FOUND)

IF(OPENMP_FOUND AND WITH_OPENMP)
	MESSAGE(STATUS "With OpenMP ")
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAX_OPENMP_NUM_THREADS=${PROCESSOR_COUNT} -DOPENMP_NUM_THREADS=${PROCESSOR_COUNT} ${OpenMP_CXX_FLAGS} -DOPENMP")
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMAX_OPENMP_NUM_THREADS=${PROCESSOR_COUNT} -DOPENMP_NUM_THREADS=${PROCESSOR_COUNT} ${OpenMP_CXX_FLAGS} ${OpenMP_C_FLAGS} -DOPENMP")
ELSE(OPENMP_FOUND AND WITH_OPENMP)
	MESSAGE(STATUS "Without OpenMP")
	SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAX_OPENMP_NUM_THREADS=1 -DOPENMP_NUM_THREADS=1")
	SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMAX_OPENMP_NUM_THREADS=1 -DOPENMP_NUM_THREADS=1")
ENDIF(OPENMP_FOUND AND WITH_OPENMP)

# OpenCV 
FIND_PACKAGE(OpenCV REQUIRED)

# Boost
#SET(Boost_USE_STATIC_LIBS OFF)
#SET(Boost_USE_MULTITHREAD ON)
#FIND_PACKAGE(Boost REQUIRED COMPONENTS filesystem thread)
#MESSAGE(STATUS "Boost_LIBS: ${Boost_LIBRARIES}")

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/Src)

# include header files of libs
INCLUDE_DIRECTORIES(${OPENCV_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/GeneralLibs/LM2.5/include)
#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})

# link libs
LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/bin)
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/GeneralLibs/LM2.5/x64libs)

# Setup output directories
SET(LIBRARY_OUTPUT_PATH 
	${PROJECT_BINARY_DIR}/bin
	CACHE
	PATH
	"Single directory for all libraries")
	
SET(EXECUTABLE_OUTPUT_PATH 
	${PROJECT_BINARY_DIR}/bin
	CACHE
	PATH
	"Single directory for all executables")

ADD_SUBDIRECTORY(Src)
#ADD_SUBDIRECTORY(GeneralLibs)