
######################################################################################
### 0) If you want to set your own variables in moeo-conf.cmake and avoid the cmd line
######################################################################################

INCLUDE(moeo-conf.cmake OPTIONAL)

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


######################################################################################
### 1) Project properties
######################################################################################

# set the project name
PROJECT(ParadisEO-MOEO)

SET(PACKAGE_BUGREPORT "paradiseo-help@lists.gforge.inria.fr" CACHE STRING "Package bug report" FORCE)
SET(PACKAGE_NAME "ParadisEO-MOEO Moving Objects" CACHE STRING "Package name" FORCE)
SET(PACKAGE_STRING "ParadisEO-MOEO 1.0" CACHE STRING "Package string full name" FORCE)
SET(PACKAGE_VERSION "1.0" CACHE STRING "Package version" FORCE)
SET(GLOBAL_VERSION "1.0" CACHE STRING "Global version" FORCE)
SET(VERSION "1.0" CACHE STRING "Version" FORCE)

# check cmake version compatibility
CMAKE_MINIMUM_REQUIRED(VERSION 2.4 FATAL_ERROR)

# regular expression checking
INCLUDE_REGULAR_EXPRESSION("^.*$" "^$")

# set a language for the entire project.
ENABLE_LANGUAGE(CXX)
ENABLE_LANGUAGE(C)

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


#####################################################################################
### 2) Include required modules
#####################################################################################

INCLUDE(CMakeBackwardCompatibilityCXX)

INCLUDE(FindDoxygen)

INCLUDE(FindGnuplot)

# check for some functions
INCLUDE(CheckLibraryExists)

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


######################################################################################
### 3) Include the main configuration variables
######################################################################################

# The "config" variable must be provided on the command line
IF(NOT DEFINED config OR NOT config)
  MESSAGE(FATAL_ERROR  "The \"config\" variable must be set on the command line to 
  						give the path of the install configuration file. ")
ENDIF(NOT DEFINED config OR NOT config)

# Need the config file whose full path is given thanks to the "config" variable
INCLUDE(${config})

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


######################################################################################
### 4) Paths checking 
######################################################################################

IF(WIN32)
  SET (ABSOLUTE_PATH_REGEX "^[A-Z]:|^[a-z]:")
ELSE(WIN32)
  SET (ABSOLUTE_PATH_REGEX "^/")
ENDIF(WIN32)

SET(REQUIRED_PATHS "EO_SRC_DIR" "EO_BIN_DIR")
FOREACH (path ${REQUIRED_PATHS})
	  	IF(EXISTS ${${path}})
			MESSAGE (STATUS "Using ${path}=${${path}}")
		ELSE(EXISTS ${${path}})
			MESSAGE (FATAL_ERROR "\n Cannot find \"${${path}}\". Please, fill \"${config}\" with a correct value")
		ENDIF(EXISTS ${${path}})
		
		IF(NOT ${${path}} MATCHES "${ABSOLUTE_PATH_REGEX}")
			MESSAGE (FATAL_ERROR "${${path}} MUST BE an absolute path")
		ENDIF(NOT ${${path}} MATCHES "${ABSOLUTE_PATH_REGEX}")
ENDFOREACH (path ${REQUIRED_PATHS})
######################################################################################


#####################################################################################
### 5) Manage the build type
#####################################################################################

# the user should choose the build type on windows environments,excepted under cygwin (default=none)
SET(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "Variable that stores the default CMake build type" FORCE)

IF(WIN32 AND NOT CYGWIN)
  IF(NOT CMAKE_BUILD_TYPE)
     SET( CMAKE_BUILD_TYPE 
          ${CMAKE_DEFAULT_BUILD_TYPE} CACHE STRING 
          "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." 
           FORCE)
  ENDIF(NOT CMAKE_BUILD_TYPE)  
ELSE(WIN32 AND NOT CYGWIN)
   IF(CMAKE_COMPILER_IS_GNUCXX)
       SET(CMAKE_CXX_FLAGS_DEBUG  "-Wall -pedantic -Wextra -Wno-import -Winit-self  -Wmissing-include-dirs -Wunused-parameter -Wundef  -Wshadow  -Wunsafe-loop-optimizations -Wcast-align -Wconversion -Wsign-compare -Winline -Wdisabled-optimization")                       
  ENDIF(CMAKE_COMPILER_IS_GNUCXX)       
ENDIF(WIN32 AND NOT CYGWIN)

IF(CMAKE_BUILD_TYPE MATCHES Debug)
    ADD_DEFINITIONS(-DCMAKE_VERBOSE_MAKEFILE=ON)
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)

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


######################################################################################
### 6) Where must cmake go now ?
######################################################################################

SUBDIRS(doc src test tutorial)

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


######################################################################################
### 7) Test config
######################################################################################

#SET(ENABLE_CMAKE_TESTING TRUE CACHE BOOL "Should we test using Dart")

IF (ENABLE_CMAKE_TESTING)
	ENABLE_TESTING()
ENDIF (ENABLE_CMAKE_TESTING)

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