-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
142 lines (110 loc) · 5.67 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# ParadiseO
######################################################################################
### 0) Check the CMake version
######################################################################################
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
######################################################################################
### 1) Define the project
######################################################################################
## Name
project("ParadisEO"
VERSION 3.0.0
DESCRIPTION "Evolutionary optimization framework"
LANGUAGES C CXX)
## Language
set(CMAKE_CXX_STANDARD 17)
######################################################################################
### 2) Check dependencies
######################################################################################
## Optional
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/module" CACHE INTERNAL "Cmake module" FORCE)
include(FindDoxygen OPTIONAL)
if(NOT DOXYGEN_FOUND)
message(WARNING "Doxygen was not found, install it if you want to generate the documentation.")
else()
message(STATUS "Doxygen found, use the target `doc` to generate the documentation.")
endif()
######################################################################################
### 3) Include CMake files
######################################################################################
## Configuration file for building type and flags
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake)
## Macro file
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Macro.cmake)
## Custom Targets file
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Target.cmake)
######################################################################################
### 4) Define and add module paths : EO, MO, MOEO
######################################################################################
## Paths to sources of modules
set( EO_SRC_DIR "${PROJECT_SOURCE_DIR}/eo" CACHE INTERNAL "ParadisEO-EO source directory" FORCE)
set( EDO_SRC_DIR "${PROJECT_SOURCE_DIR}/edo" CACHE INTERNAL "ParadisEO-EDO source directory" FORCE)
set( MO_SRC_DIR "${PROJECT_SOURCE_DIR}/mo" CACHE INTERNAL "ParadisEO-MO source directory" FORCE)
set(MOEO_SRC_DIR "${PROJECT_SOURCE_DIR}/moeo" CACHE INTERNAL "ParadisEO-MOEO source directory" FORCE)
set( SMP_SRC_DIR "${PROJECT_SOURCE_DIR}/smp" CACHE INTERNAL "ParadisEO-SMP source directory" FORCE)
set( MPI_SRC_DIR "${PROJECT_SOURCE_DIR}/eo/src/mpi" CACHE INTERNAL "ParadisEO-MPI source directory" FORCE)
set(PROBLEMS_SRC_DIR "${PROJECT_SOURCE_DIR}/problems" CACHE INTERNAL "Problems dependant source directory" FORCE)
set(CMAKE_BASE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
# All libraries are built in <build_dir>/lib/
set( EO_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-EO binary directory" FORCE)
set( EDO_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-EDO binary directory" FORCE)
set( MO_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-MO binary directory" FORCE)
set(MOEO_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-MOEO binary directory" FORCE)
set( SMP_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-SMP binary directory" FORCE)
set( MPI_BIN_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "ParadisEO-MPI binary directory" FORCE)
set(EO_ONLY "false" CACHE BOOL "Only build EO and not the other modules")
set(ENABLE_OPENMP "false" CACHE BOOL "Build EO with the OpenMP support (shared-memory parallel evaluators on multi-core)")
set(ENABLE_GNUPLOT "false" CACHE BOOL "Build EO with the GNUplot support (real-time convergence plotting)")
set(EDO "false" CACHE BOOL "Build the EDO module")
set(EDO_USE_LIB "Eigen3" CACHE STRING "Which linear algebra library to use to build EDO ('UBlas' or 'Eigen3', Eigen3 is recommended)")
set(SMP "false" CACHE BOOL "Build the SMP module")
set(MPI "false" CACHE BOOL "Build the MPI module")
## EO Module
set(MODULE_NAME "Paradiseo")
set(DOXYGEN_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
# set(EO_MODULE_NAME "Evolving Objects")
set(CMAKE_SOURCE_DIR ${EO_SRC_DIR})
add_subdirectory(${EO_SRC_DIR})
if(NOT EO_ONLY)
## MO Module
# set(MO_MODULE_NAME "Moving Objects")
# set(MODULE_NAME "Moving Objects")
set(CMAKE_SOURCE_DIR ${MO_SRC_DIR})
add_subdirectory(${MO_SRC_DIR})
## EDO Module
if(EDO)
# set(EDO_MODULE_NAME "Evolving Distribution Objects")
set(CMAKE_SOURCE_DIR ${EDO_SRC_DIR})
add_subdirectory(${EDO_SRC_DIR})
endif()
## MOEO Module
# set(MOEO_MODULE_NAME "Multi-Objectives EO")
set(CMAKE_SOURCE_DIR ${MOEO_SRC_DIR})
add_subdirectory(${MOEO_SRC_DIR})
## SMP Module
if(SMP)
# set(SMP_MODULE_NAME "Symmetric Multi-Processing")
set(CMAKE_SOURCE_DIR ${SMP_SRC_DIR})
add_subdirectory(${SMP_SRC_DIR})
endif()
## MPI Module
if(MPI)
find_package(MPI REQUIRED)
add_definitions(-DWITH_MPI)
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
include_directories(${MPI_INCLUDE_PATH})
add_subdirectory(${MPI_SRC_DIR})
endif()
endif()
######################################################################################
### 5) Packaging : only in release !
######################################################################################
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Package.cmake)
endif()
# Add all targets to the build-tree export set
export(TARGETS eo FILE "${PROJECT_BINARY_DIR}/paradiseo-config.cmake")
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE paradiseo)