forked from francois-keith/roboptim-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
281 lines (253 loc) · 13 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
# Copyright 2010, Thomas Moulard, LAAS-CNRS
#
# This file is part of roboptim-core.
# roboptim-core is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# roboptim-core is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Lesser Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with roboptim-core. If not, see <http://www.gnu.org/licenses/>.
# Requires at least CMake 2.8.12 to configure the package.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/lapack.cmake)
INCLUDE(cmake/cpack.cmake)
INCLUDE(cmake/eigen.cmake)
INCLUDE(cmake/msvc-specific.cmake)
SET(PROJECT_NAME roboptim-core)
SET(PROJECT_DESCRIPTION "RobOptim Core")
SET(PROJECT_URL "http://github.com/roboptim/roboptim-core")
SET(PROJECT_DEBUG_POSTFIX "_d")
# Use MathJax for Doxygen formulae
SET(DOXYGEN_USE_MATHJAX "YES")
SET(HEADERS
${CMAKE_SOURCE_DIR}/include/roboptim/core.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/alloc.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/cache.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/cache.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/callback/multiplexer.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/callback/multiplexer.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/callback/wrapper.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/callback/wrapper.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/debug.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/derivable-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/derivable-parametrized-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/derivative-size.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/detail/autopromote.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/detail/structured-input.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/detail/structured-input.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/detail/utility.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/differentiable-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/differentiable-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/decorator/cached-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/decorator/cached-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/decorator/finite-difference-gradient.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/decorator/finite-difference-gradient.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/bind.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/bind.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/chain.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/chain.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/concatenate.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/concatenate.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/derivative.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/map.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/map.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/minus.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/minus.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/plus.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/plus.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/product.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/product.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/scalar.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/scalar.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/selection-by-id.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/selection-by-id.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/selection.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/selection.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/split.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/operator/split.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/finite-difference-gradient.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/function-pool.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/function-pool.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/function/constant.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/function/cos.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/function/identity.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/function/polynomial.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/function/polynomial.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/function/sin.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/fwd.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/generic-solver.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/indent.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/io.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/linear-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/linear-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/n-times-derivable-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/n-times-derivable-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/numeric-linear-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/numeric-linear-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/numeric-quadratic-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/numeric-quadratic-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/optimization-logger.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/optimization-logger.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/parametrized-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/parametrized-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/plugin/dummy-laststate.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/plugin/dummy-laststate.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/plugin/dummy-td.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/plugin/dummy.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/portability.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/problem.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/problem.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/quadratic-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/quadratic-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/result-analyzer.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/result-analyzer.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/result-with-warnings.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/result.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/scaling-helper.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/scaling-helper.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-callback.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-callback.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-error.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-factory.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-factory.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-state.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-state.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver-warning.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/solver.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/sum-of-c1-squares.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/sum-of-c1-squares.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/sys.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/terminal-color.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/twice-derivable-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/twice-differentiable-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/twice-differentiable-function.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/util.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/util.hxx
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/fwd.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/gnuplot-commands.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/gnuplot-differentiable-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/gnuplot-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/gnuplot-matrix.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/gnuplot.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/matplotlib-commands.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/matplotlib-function.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/matplotlib-matrix.hh
${CMAKE_SOURCE_DIR}/include/roboptim/core/visualization/matplotlib.hh
)
SETUP_PROJECT()
SET (ROBOPTIM_DO_NOT_CHECK_ALLOCATION TRUE CACHE BOOL
"Do not check dynamic allocation of Eigen matrices")
IF(ROBOPTIM_DO_NOT_CHECK_ALLOCATION)
ADD_DEFINITIONS(-DROBOPTIM_DO_NOT_CHECK_ALLOCATION)
PKG_CONFIG_APPEND_CFLAGS (-DROBOPTIM_DO_NOT_CHECK_ALLOCATION)
ELSE()
ADD_DEFINITIONS(-DEIGEN_RUNTIME_NO_MALLOC)
PKG_CONFIG_APPEND_CFLAGS(-DEIGEN_RUNTIME_NO_MALLOC)
ENDIF()
# Fix for apparent bug with GCC 5.3
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
IF(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 5.3)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
ENDIF()
ENDIF()
IF(PROJECT_DEBUG_POSTFIX)
SET(FLAG_POSTFIX -DROBOPTIM_DEBUG_POSTFIX=${PROJECT_DEBUG_POSTFIX})
ADD_COMPILE_OPTIONS($<$<CONFIG:Debug>:${FLAG_POSTFIX}>)
PKG_CONFIG_APPEND_CFLAGS_DEBUG(${FLAG_POSTFIX})
ENDIF()
SET(USE_CXX11 FALSE CACHE BOOL "Whether to use C++11")
SET(ROBOPTIM_PRECOMPILE_DENSE_SPARSE FALSE CACHE BOOL
"Precompile code for dense and sparse matrices (C++11 required)")
IF(ROBOPTIM_PRECOMPILE_DENSE_SPARSE)
IF(USE_CXX11)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ADD_DEFINITIONS(-DROBOPTIM_PRECOMPILED_DENSE_SPARSE)
PKG_CONFIG_APPEND_CFLAGS(-DROBOPTIM_PRECOMPILED_DENSE_SPARSE)
ELSE()
MESSAGE(WARNING "C++11 is required for explicit template instantiation")
ENDIF()
ENDIF()
IF(MSVC)
ADD_DEFINITIONS(-DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE)
PKG_CONFIG_APPEND_CFLAGS (-DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE)
ENDIF()
# If compiler support symbol visibility, enable it.
INCLUDE(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAS_VISIBILITY)
IF(HAS_VISIBILITY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
ENDIF()
# Search for dependencies.
SET(BOOST_COMPONENTS date_time filesystem system unit_test_framework)
SEARCH_FOR_BOOST()
SEARCH_FOR_EIGEN("eigen3 >= 3.2.0")
IF(WIN32)
ADD_REQUIRED_DEPENDENCY("liblog4cxx >= 0.10.0" "liblog4cxx_d >= 0.10.0")
ELSE()
ADD_REQUIRED_DEPENDENCY("liblog4cxx >= 0.10.0")
ENDIF()
# Libtool dynamic loading
# This project does not use Libtool directly but still uses ltdl for
# plug-in loading.
IF(WIN32)
ADD_OPTIONAL_DEPENDENCY("ltdl" "ltdl_d")
ENDIF(WIN32)
IF(NOT LTDL_FOUND)
#FIXME: check that libltdl.so is available instead of adding it blindly.
INCLUDE(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(ltdl.h LTDL_H_FOUND)
IF (NOT LTDL_H_FOUND)
MESSAGE(FATAL_ERROR
"Failed to find ltdl.h, check that Libtool ltdl is installed.")
ENDIF()
PKG_CONFIG_APPEND_LIBS(ltdl)
ENDIF(NOT LTDL_FOUND)
HEADER_INSTALL("${HEADERS}")
# Set plug-in subdirectory name (can be empty).
SET(PLUGIN_SUBDIR "${PROJECT_NAME}" CACHE
STRING "libdir subdirectory where plug-ins will be installed (can be empty)")
SET(PLUGINDIR "${CMAKE_INSTALL_LIBDIR}/${PLUGIN_SUBDIR}")
SET(FULL_PLUGINDIR "${CMAKE_INSTALL_FULL_LIBDIR}/${PLUGIN_SUBDIR}")
MESSAGE("-- Relative plug-in directory: ${PLUGIN_SUBDIR}")
MESSAGE("-- Absolute plug-in directory: ${FULL_PLUGINDIR}")
# Add extra keys to pkg-config file to export the location of the
# plug-in directory in a robust manner.
SET(PKG_CONFIG_EXTRA "relplugindir=${PLUGIN_SUBDIR}\nplugindir=\${libdir}/\${relplugindir}")
# Set the default storage order for Eigen matrices (ColMajor or RowMajor).
# Note: RowMajor may yield better results for the dense Jacobian filling process
# if most functions only implement impl_gradient, but ColMajor is the usual
# default storage order for this kind of scenario.
SET(STORAGE_ORDER "ColMajor" CACHE
STRING "Storage order for Eigen matrices (ColMajor or RowMajor")
IF(NOT (STORAGE_ORDER STREQUAL "ColMajor" OR STORAGE_ORDER STREQUAL "RowMajor"))
MESSAGE(FATAL_ERROR "Storage order should be either ColMajor or RowMajor.")
ENDIF()
ADD_DEFINITIONS(-DROBOPTIM_STORAGE_ORDER=${STORAGE_ORDER})
PKG_CONFIG_APPEND_CFLAGS (-DROBOPTIM_STORAGE_ORDER=${STORAGE_ORDER})
OPTION(DISABLE_TESTS "Disable test programs" OFF)
# For MSVC, set local environment variable to enable finding the built dlls
# of roboptim-core and the plugins when launching ctest with RUN_TESTS
IF(MSVC)
SET(CMAKE_MSVCIDE_RUN_PATH "\$(SolutionDir)/src/\$(Configuration)")
ENDIF(MSVC)
ADD_SUBDIRECTORY(src)
# Add main library to pkg-config file.
PKG_CONFIG_APPEND_LIBS(roboptim-core)
IF(NOT DISABLE_TESTS)
ADD_SUBDIRECTORY(tests)
ELSE()
MESSAGE(WARNING
"Tests should only be disabled for specific cases. Do it at your own risk.")
ENDIF()
SETUP_PROJECT_FINALIZE()
SETUP_PROJECT_CPACK()