forked from DominicDirkx/pagmo2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
441 lines (384 loc) · 18.1 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# This version of pagmo2 CMakeLists.txt was modified by
# F. Lupi (github.com/lupif)
# on
# 13/07/2017 at 12:00 pm
# As part of tudatBundle project
#
# changed the name of CMAKE_SOURCE_DIR to CMAKE_CURRENT_SOURCE_DIR
# CMake version check.
cmake_minimum_required(VERSION 3.2)
# Module path setup.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/yacma")
# Set default build type to "Release".
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
# Main build options: build pagmo or pygmo. They cannot be on at the same time,
# and only one must be chosen.
option(PAGMO_BUILD_PAGMO "Build pagmo." ON)
option(PAGMO_BUILD_PYGMO "Build pygmo." OFF)
option(PAGMO_USE_TBB "Use TBB in pagmo." OFF)
if(PAGMO_USE_TBB)
add_definitions(-DPAGMO_USE_TBB=1)
else()
add_definitions(-DPAGMO_USE_TBB=0)
endif()
# Check consistency.
if(PAGMO_BUILD_PAGMO AND PAGMO_BUILD_PYGMO)
message(FATAL_ERROR "Please select whether to build pagmo or pygmo: you cannot build them both at the same time.")
endif()
if((NOT PAGMO_BUILD_PAGMO) AND (NOT PAGMO_BUILD_PYGMO))
message(FATAL_ERROR "Please select if you want to build pagmo or pygmo.")
endif()
# Main pagmo/pygmo project version.
set(PAGMO_PROJECT_VERSION 2.12)
if(PAGMO_BUILD_PAGMO)
# Initial setup of a pagmo build.
project(pagmo VERSION ${PAGMO_PROJECT_VERSION} LANGUAGES CXX C)
message(STATUS "System name: ${CMAKE_SYSTEM_NAME}")
enable_testing()
# Build option: enable test set.
option(PAGMO_BUILD_TESTS "Build test set." OFF)
# Build option: enable tutorials.
option(PAGMO_BUILD_TUTORIALS "Build tutorials." OFF)
# Build option: enable features depending on Eigen3.
option(PAGMO_WITH_EIGEN3 "Enable features depending on Eigen3 (such as CMAES). Requires Eigen3." OFF)
# Build option: enable NLopt.
option(PAGMO_WITH_NLOPT "Enable wrappers for the NLopt algorithms." OFF)
# Build option: enable Ipopt.
option(PAGMO_WITH_IPOPT "Enable wrappers for the Ipopt solver." OFF)
# Detect if we can enable the fork_island UDI.
include(CheckIncludeFileCXX)
include(CheckCXXSymbolExists)
CHECK_INCLUDE_FILE_CXX("sys/types.h" PAGMO_HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE_CXX("sys/wait.h" PAGMO_HAVE_SYS_WAIT_H)
CHECK_INCLUDE_FILE_CXX("unistd.h" PAGMO_HAVE_UNISTD_H)
CHECK_CXX_SYMBOL_EXISTS(fork "unistd.h;sys/types.h" PAGMO_HAVE_FORK_SYSCALL)
if(PAGMO_HAVE_SYS_TYPES_H AND PAGMO_HAVE_SYS_WAIT_H AND PAGMO_HAVE_UNISTD_H AND PAGMO_HAVE_FORK_SYSCALL)
message(STATUS "The fork_island UDI will be available.")
set(PAGMO_WITH_FORK_ISLAND YES)
set(PAGMO_ENABLE_FORK_ISLAND "#define PAGMO_WITH_FORK_ISLAND")
else()
message(STATUS "The fork_island UDI will NOT be available.")
set(PAGMO_WITH_FORK_ISLAND NO)
endif()
else()
# Initial setup of a pygmo build.
project(pygmo VERSION ${PAGMO_PROJECT_VERSION} LANGUAGES CXX C)
message(STATUS "System name: ${CMAKE_SYSTEM_NAME}")
endif()
# Common general bits.
# Initial setup of compiler flags.
include(YACMACompilerLinkerSettings)
# Threading setup.
include(YACMAThreadingSetup)
# Assemble the flags.
set(PAGMO_CXX_FLAGS_DEBUG ${YACMA_CXX_FLAGS} ${YACMA_CXX_FLAGS_DEBUG} ${YACMA_THREADING_CXX_FLAGS})
set(PAGMO_CXX_FLAGS_RELEASE ${YACMA_CXX_FLAGS} ${YACMA_THREADING_CXX_FLAGS})
if(APPLE AND YACMA_COMPILER_IS_CLANGXX)
message(STATUS "Clang compiler on OSX detected, setting the standard library to 'libc++'.")
list(APPEND PAGMO_CXX_FLAGS_DEBUG "-stdlib=libc++")
list(APPEND PAGMO_CXX_FLAGS_RELEASE "-stdlib=libc++")
endif()
if(YACMA_COMPILER_IS_MSVC)
# Disable the idiotic minmax macros on MSVC, some annoying warnings,
# and enable the bigobj option.
list(APPEND PAGMO_CXX_FLAGS_DEBUG "-DNOMINMAX" "/wd4459" "/wd4127" "/wd4702" "/wd4251" "/bigobj")
list(APPEND PAGMO_CXX_FLAGS_RELEASE "-DNOMINMAX" "/wd4459" "/wd4127" "/wd4702" "/wd4251" "/bigobj")
endif()
if(MINGW)
# Flag needed to deal with big binaries in MinGW.
message(STATUS "Enabling the '-Wa,-mbig-obj' flag in MinGW builds.")
list(APPEND PAGMO_CXX_FLAGS_DEBUG "-Wa,-mbig-obj")
list(APPEND PAGMO_CXX_FLAGS_RELEASE "-Wa,-mbig-obj")
endif()
if(PAGMO_BUILD_PAGMO)
# pagmo dependencies.
# TBB.
if(PAGMO_USE_TBB)
find_package(TBB REQUIRED)
endif()
# Eigen3
if(PAGMO_WITH_EIGEN3)
find_package(Eigen3 REQUIRED)
include_directories(SYSTEM AFTER "${EIGEN3_INCLUDE_DIR}")
message(STATUS "Eigen include directory: ${EIGEN3_INCLUDE_DIR}")
message(STATUS "Eigen version detected: ${EIGEN3_VERSION}")
endif()
# NLopt
if(PAGMO_WITH_NLOPT)
find_package(NLOPT REQUIRED)
include_directories(SYSTEM AFTER "${NLOPT_INCLUDE_DIR}")
include_directories(SYSTEM AFTER "${NLOPT_INCLUDE_DIR}/src/api")
message(STATUS "NLopt include directory: ${NLOPT_INCLUDE_DIR}")
message(STATUS "NLopt library: ${NLOPT_LIBRARY}")
endif()
# Ipopt
if(PAGMO_WITH_IPOPT)
find_package(IPOPT REQUIRED)
message(STATUS "Ipopt include directory: ${IPOPT_INCLUDE_DIR}")
message(STATUS "Ipopt library: ${IPOPT_LIBRARY}")
endif()
if(PAGMO_BUILD_TESTS)
# Internal variable that will be used to tell PagmoFindBoost to locate the
# Boost unit test framework, if tests are required.
set(_PAGMO_FIND_BOOST_UNIT_TEST_FRAMEWORK TRUE)
endif()
endif()
if(PAGMO_BUILD_PYGMO)
# pygmo dependencies.
include(YACMAPythonSetup)
# Python version check.
if(${PYTHON_VERSION_MAJOR} LESS 2 OR (${PYTHON_VERSION_MAJOR} EQUAL 2 AND ${PYTHON_VERSION_MINOR} LESS 7))
message(FATAL_ERROR "Minimum supported Python version is 2.7.")
endif()
# NOTE: for the time being, require that pagmo/pygmo versions are matching exactly.
find_package(Pagmo ${PAGMO_PROJECT_VERSION} EXACT REQUIRED)
find_package(NumPy REQUIRED)
# Internal variable that will be used to tell PagmoFindBoost to locate Boost.Python.
set(_PAGMO_FIND_BOOST_PYTHON TRUE)
endif()
# Boost setup (common to pagmo/pygmo).
include(PagmoFindBoost)
if(PAGMO_BUILD_PAGMO)
# List of source files.
set(PAGMO_SRC_FILES
# Core classes.
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithm.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/population.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/bfe.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/island.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/archipelago.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/rng.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/threading.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/topology.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/r_policy.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/s_policy.cpp"
# UDP.
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/null_problem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/cec2006.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/cec2009.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/schwefel.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/rosenbrock.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/hock_schittkowsky_71.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/inventory.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/zdt.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/dtlz.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/unconstrain.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/translate.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/decompose.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/golomb_ruler.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/lennard_jones.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/ackley.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/griewank.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/rastrigin.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/minlp_rastrigin.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/luksan_vlcek1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/wfg.cpp"
# UDA.
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/null_algorithm.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/de.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/pso.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/not_population_based.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/compass_search.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/mbh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/cstrs_self_adaptive.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/pso_gen.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/ihs.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/sade.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/bee_colony.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/sea.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/sga.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/simulated_annealing.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/moead.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/nsga2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/gaco.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/de1220.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/gwo.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/nspso.cpp"
# UDI.
"${CMAKE_CURRENT_SOURCE_DIR}/src/islands/thread_island.cpp"
# UDBFE.
"${CMAKE_CURRENT_SOURCE_DIR}/src/batch_evaluators/default_bfe.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/batch_evaluators/member_bfe.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/batch_evaluators/thread_bfe.cpp"
# UDT.
"${CMAKE_CURRENT_SOURCE_DIR}/src/topologies/base_bgl_topology.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/topologies/unconnected.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/topologies/fully_connected.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/topologies/ring.cpp"
# UDRP.
"${CMAKE_CURRENT_SOURCE_DIR}/src/r_policies/fair_replace.cpp"
# UDSP.
"${CMAKE_CURRENT_SOURCE_DIR}/src/s_policies/select_best.cpp"
# Utils.
"${CMAKE_CURRENT_SOURCE_DIR}/src/utils/constrained.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/utils/discrepancy.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/utils/generic.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/utils/multi_objective.cpp"
# Detail.
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/base_sr_policy.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/bfe_impl.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/task_queue.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/prime_numbers.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/gte_getter.cpp"
)
# Some compilers choke on the cec2013/2014 data arrays.
if(NOT YACMA_COMPILER_IS_MSVC AND NOT APPLE AND NOT MINGW)
set(PAGMO_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/cec2014.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/cec2014_data.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/cec2013.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/problems/cec2013_data.cpp"
"${PAGMO_SRC_FILES}"
)
endif()
# Optional and platform-dependent bits.
if(PAGMO_WITH_FORK_ISLAND)
set(PAGMO_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/islands/fork_island.cpp"
"${PAGMO_SRC_FILES}"
)
endif()
if(PAGMO_WITH_EIGEN3)
set(PAGMO_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/cmaes.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/xnes.cpp"
"${PAGMO_SRC_FILES}"
)
endif()
if(PAGMO_WITH_NLOPT)
set(PAGMO_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/nlopt.cpp"
"${PAGMO_SRC_FILES}"
)
endif()
if(PAGMO_WITH_IPOPT)
set(PAGMO_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/algorithms/ipopt.cpp"
"${PAGMO_SRC_FILES}"
)
endif()
# Setup of the pagmo library.
if(PAGMO_AS_STATIC_LIB)
add_library(pagmo STATIC "${PAGMO_SRC_FILES}")
else()
add_library(pagmo SHARED "${PAGMO_SRC_FILES}")
endif()
set_property(TARGET pagmo PROPERTY VERSION "1.0")
set_property(TARGET pagmo PROPERTY SOVERSION 1)
target_compile_options(pagmo PRIVATE "$<$<CONFIG:DEBUG>:${PAGMO_CXX_FLAGS_DEBUG}>" "$<$<CONFIG:RELEASE>:${PAGMO_CXX_FLAGS_RELEASE}>")
set_target_properties(pagmo PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(pagmo PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
# Let's setup the target C++ standard, but only if the user did not provide it manually.
if(NOT CMAKE_CXX_STANDARD)
set_property(TARGET pagmo PROPERTY CXX_STANDARD 11)
endif()
set_property(TARGET pagmo PROPERTY CXX_STANDARD_REQUIRED YES)
set_property(TARGET pagmo PROPERTY CXX_EXTENSIONS NO)
# NOTE: make sure the include directories from the current build
# are included first, so that if there is already a pagmo installation
# in the prefix path we don't risk including the headers from that
# one instead.
target_include_directories(pagmo PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
# Threads.
target_link_libraries(pagmo PUBLIC Threads::Threads)
# Boost.
target_link_libraries(pagmo PUBLIC Boost::boost Boost::serialization)
# TBB.
if(PAGMO_USE_TBB)
target_link_libraries(pagmo PUBLIC TBB::tbb)
endif()
if(PAGMO_WITH_EIGEN3)
# Link pagmo to eigen3.
# target_link_libraries(pagmo PUBLIC Eigen3::eigen3)
set(PAGMO_ENABLE_EIGEN3 "#define PAGMO_WITH_EIGEN3")
endif()
if(PAGMO_WITH_NLOPT)
# Link pagmo to NLopt.
target_link_libraries(pagmo PUBLIC NLOPT::nlopt)
set(PAGMO_ENABLE_NLOPT "#define PAGMO_WITH_NLOPT")
endif()
if(PAGMO_WITH_IPOPT)
# Link pagmo to Ipopt.
target_link_libraries(pagmo PUBLIC IPOPT::ipopt)
set(PAGMO_ENABLE_IPOPT "#define PAGMO_WITH_IPOPT")
endif()
# Configure config.hpp.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/include/pagmo/config.hpp" @ONLY)
# Configure the doc files.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/Doxyfile.in" "${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/Doxyfile" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/sphinx/conf.py.in" "${CMAKE_CURRENT_SOURCE_DIR}/doc/sphinx/conf.py" @ONLY)
if(PAGMO_BUILD_TESTS)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests")
endif()
if(PAGMO_BUILD_TUTORIALS)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tutorials")
endif()
endif()
if(PAGMO_BUILD_PYGMO)
# Add the pygmo subdirectory.
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/pygmo")
if(MINGW OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message(STATUS "Creating the files for the generation of a binary wheel.")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/wheel_setup.py" "${CMAKE_CURRENT_BINARY_DIR}/wheel/setup.py" @ONLY)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# NOTE: this is necessary on linux but harmful on mingw.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/wheel_setup.cfg" "${CMAKE_CURRENT_BINARY_DIR}/wheel/setup.cfg" @ONLY)
endif()
if(MINGW)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/mingw_wheel_libs_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.txt" "${CMAKE_CURRENT_BINARY_DIR}/wheel/mingw_wheel_libs_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.txt" @ONLY)
endif()
endif()
endif()
# Library installation.
if(PAGMO_BUILD_PAGMO)
# Installation of the header files.
install(DIRECTORY include/ DESTINATION include)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/pagmo/config.hpp" DESTINATION include/pagmo)
# Installation of the library.
install(TARGETS pagmo
EXPORT pagmo_export
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
# Setup of the optional deps.
set(_PAGMO_CONFIG_OPTIONAL_DEPS)
if(PAGMO_WITH_EIGEN3)
set(_PAGMO_CONFIG_OPTIONAL_DEPS "${_PAGMO_CONFIG_OPTIONAL_DEPS}find_package(Eigen3 REQUIRED)\n")
endif()
if(PAGMO_WITH_NLOPT)
set(_PAGMO_CONFIG_OPTIONAL_DEPS "${_PAGMO_CONFIG_OPTIONAL_DEPS}find_package(NLOPT REQUIRED)\n")
endif()
if(PAGMO_WITH_IPOPT)
set(_PAGMO_CONFIG_OPTIONAL_DEPS "${_PAGMO_CONFIG_OPTIONAL_DEPS}find_package(IPOPT REQUIRED)\n")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pagmo-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/pagmo-config.cmake" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pagmo-config.cmake" DESTINATION "lib/cmake/pagmo")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindEigen3.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindNLOPT.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindIPOPT.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/PagmoFindBoost.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/FindTBB.cmake" DESTINATION "lib/cmake/pagmo")
install(EXPORT pagmo_export NAMESPACE Pagmo:: DESTINATION lib/cmake/pagmo)
# Take care of versioning.
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/pagmo-config-version.cmake" VERSION ${pagmo_VERSION}
COMPATIBILITY ExactVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pagmo-config-version.cmake" DESTINATION "lib/cmake/pagmo")
endif()
# Uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()