CMakeLists.txt 12.3 KB
Newer Older
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
1
#
2
# Copyright (c) 2015-2018 CNRS
3
# Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France.
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
4
#
5
# This file is part of Pinocchio
Florent Lamiraux's avatar
Florent Lamiraux committed
6
# pinocchio is free software: you can redistribute it
7
8
9
# 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.
Florent Lamiraux's avatar
Florent Lamiraux committed
10
# pinocchio is distributed in the hope that it will be
11
12
13
14
# 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
Florent Lamiraux's avatar
Florent Lamiraux committed
15
# pinocchio If not, see
16
# <http://www.gnu.org/licenses/>.
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
17
18
19
20
21
22

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
23
INCLUDE(cmake/ide.cmake)
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
24
25
26

SET(PROJECT_NAME pinocchio)
SET(PROJECT_DESCRIPTION "Rigid multi body dynamics algorithms")
jcarpent's avatar
jcarpent committed
27
SET(PROJECT_URL "http://github.com/stack-of-tasks/pinocchio")
jcarpent's avatar
jcarpent committed
28
OPTION(INSTALL_DOCUMENTATION "Generate and install the documentation" ON)
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
29

30
31
SET(DOXYGEN_USE_MATHJAX YES)

32
IF(APPLE)
33
34
35
36
37
38
39
40
41
42
  SET(CMAKE_MACOSX_RPATH TRUE)
  SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
  SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
  if("${isSystemDir}" STREQUAL "-1")
     set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  endif("${isSystemDir}" STREQUAL "-1")
43
44
ENDIF(APPLE)

Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
45
46
47
48
49
50
# Disable -Werror on Unix for now.
SET(CXX_DISABLE_WERROR True)
SET(CMAKE_VERBOSE_MAKEFILE True)

SETUP_PROJECT()

51
52
53
54
55
56
IF(WIN32)
  SET(LINK copy_if_different)
ELSE(WIN32)
  SET(LINK create_symlink)
ENDIF(WIN32)

57
58
# --- OPTIONS ----------------------------------------
OPTION (BUILD_BENCHMARK "Build the benchmarks" OFF)
59
OPTION (BUILD_UNIT_TESTS "Build the unitary tests" ON)
60
OPTION (BUILD_UTILS "Build the utils" OFF)
61
OPTION (INITIALIZE_WITH_NAN "Initialize Eigen entries with NaN" OFF)
62
OPTION (BUILD_TESTS_WITH_HPP "Build geom tests and benchmarks with hpp to do comparisons" OFF)
63
OPTION (BUILD_PYTHON_INTERFACE "Build the python binding" ON)
jcarpent's avatar
jcarpent committed
64
OPTION (BUILD_WITH_LUA_SUPPORT "Build the lua parser" OFF)
65
OPTION (BUILD_WITH_COMMIT_VERSION "Build libraries by setting specific commit version" OFF)
66
67

IF (INITIALIZE_WITH_NAN)
jcarpent's avatar
jcarpent committed
68
  MESSAGE (STATUS "Initialize with NaN all the Eigen entries.")
69
70
  ADD_DEFINITIONS(-DEIGEN_INITIALIZE_MATRICES_BY_NAN)
ENDIF (INITIALIZE_WITH_NAN)
71

72
73
74
75
MACRO(TAG_LIBRARY_VERSION target)
  SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDMACRO(TAG_LIBRARY_VERSION)

Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
76
77
78
# ----------------------------------------------------
# --- DEPENDANCIES -----------------------------------
# ----------------------------------------------------
79
80
ADD_REQUIRED_DEPENDENCY("eigen3 >= 3.0.5")
ADD_OPTIONAL_DEPENDENCY("metapod >= 1.0.7")
Guilhem Saurel's avatar
Guilhem Saurel committed
81
ADD_OPTIONAL_DEPENDENCY("urdfdom >= 0.2.0")
82
ADD_OPTIONAL_DEPENDENCY("hpp-fcl >= 0.5.1")
83

84
# Special care of urdfdom version
85
86
IF(URDFDOM_FOUND)
  IF(${URDFDOM_VERSION} VERSION_LESS "0.3.0")
87
    ADD_DEFINITIONS(-DURDFDOM_COLLISION_WITH_GROUP_NAME)
88
    PKG_CONFIG_APPEND_CFLAGS("-DURDFDOM_COLLISION_WITH_GROUP_NAME")
89
  ENDIF(${URDFDOM_VERSION} VERSION_LESS "0.3.0")
90
91
92
93
94
95
96
97
98
99
100
101

  # defines types from version 0.4.0
  IF(NOT ${URDFDOM_VERSION} VERSION_LESS "0.4.0")
    ADD_DEFINITIONS(-DURDFDOM_TYPEDEF_SHARED_PTR)
    PKG_CONFIG_APPEND_CFLAGS("-DURDFDOM_TYPEDEF_SHARED_PTR")
  ENDIF(NOT ${URDFDOM_VERSION} VERSION_LESS "0.4.0")
  
  # std::shared_ptr appears from version 1.0.0
  IF(${URDFDOM_VERSION} VERSION_GREATER "0.4.2")
    ADD_DEFINITIONS(-DURDFDOM_USE_STD_SHARED_PTR)
    PKG_CONFIG_APPEND_CFLAGS("-DURDFDOM_USE_STD_SHARED_PTR")
  ENDIF(${URDFDOM_VERSION} VERSION_GREATER "0.4.2")
102
103
ENDIF(URDFDOM_FOUND)

104
105
# Special care of lua which can be of versions 5.1 or 5.2
# Priority is set to lua5.2
jcarpent's avatar
jcarpent committed
106
107
108
IF(BUILD_WITH_LUA_SUPPORT)
  ADD_OPTIONAL_DEPENDENCY("lua5.2")
  IF(LUA5_2_FOUND)
109
    SET(LUA5_FOUND TRUE)
jcarpent's avatar
jcarpent committed
110
111
112
113
114
115
116
117
118
119
120
121
122
    SET(LUA5_PACKAGE "lua5.2")
    ADD_DEFINITIONS(-DLUA_VERSION_GREATER_5_2)
    PKG_CONFIG_APPEND_CFLAGS("-DLUA_VERSION_GREATER_5_2")
  ELSE(LUA5_2_FOUND)
    ADD_OPTIONAL_DEPENDENCY("lua5.1")
    IF(LUA5_1_FOUND)
      SET(LUA5_FOUND TRUE)
      SET(LUA5_PACKAGE "lua5.1")
    ELSE(LUA5_1_FOUND)
      MESSAGE(FATAL_ERROR "Cannot find a suitable version of Lua 5.1 or 5.2")
    ENDIF(LUA5_1_FOUND)
  ENDIF(LUA5_2_FOUND)
ENDIF(BUILD_WITH_LUA_SUPPORT)
123

jcarpent's avatar
jcarpent committed
124
125
126
127
SET(BOOST_REQUIERED_COMPONENTS filesystem system)
SET(BOOST_BUILD_COMPONENTS unit_test_framework)
SET(BOOST_OPTIONAL_COMPONENTS "")

128
IF(BUILD_PYTHON_INTERFACE)
jcarpent's avatar
jcarpent committed
129
  SET(BOOST_OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS} python)
130
  FINDPYTHON(2.7 EXACT REQUIRED)
131
  INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS}) 
132
133
ENDIF(BUILD_PYTHON_INTERFACE)

jcarpent's avatar
jcarpent committed
134
SET(BOOST_COMPONENTS ${BOOST_REQUIERED_COMPONENTS} ${BOOST_OPTIONAL_COMPONENTS} ${BOOST_BUILD_COMPONENTS})
135
SEARCH_FOR_BOOST()
136

137
138
139
# Variable containing all the cflags definition relative to optional dependencies
SET(CFLAGS_DEPENDENCIES)

140
# Path to boost headers
141
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
142

Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
143
144
145
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
146
147

SET(${PROJECT_NAME}_MATH_HEADERS
148
  math/fwd.hpp
149
  math/sincos.hpp
150
  math/quaternion.hpp
151
  math/matrix.hpp
152
153
154
  )

SET(${PROJECT_NAME}_TOOLS_HEADERS
155
  tools/axis-label.hpp
156
  tools/timer.hpp
157
  tools/string-generator.hpp
158
  tools/file-explorer.hpp
159
160
161
  )

SET(${PROJECT_NAME}_SPATIAL_HEADERS
162
  spatial/symmetric3.hpp
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
163
164
  spatial/se3.hpp
  spatial/motion.hpp
165
166
167
  spatial/motion-base.hpp
  spatial/motion-dense.hpp
  spatial/motion-tpl.hpp
jcarpent's avatar
jcarpent committed
168
  spatial/motion-ref.hpp
169
  spatial/motion-zero.hpp
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
170
  spatial/force.hpp
171
172
173
174
  spatial/force-base.hpp
  spatial/force-dense.hpp
  spatial/force-tpl.hpp
  spatial/force-ref.hpp
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
175
176
177
  spatial/inertia.hpp
  spatial/fwd.hpp
  spatial/skew.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
178
  spatial/act-on-set.hpp
179
  spatial/act-on-set.hxx
180
  spatial/explog.hpp
jcarpent's avatar
jcarpent committed
181
  spatial/cartesian-axis.hpp
jcarpent's avatar
jcarpent committed
182
  spatial/spatial-axis.hpp
183
184
  )

185
SET(${PROJECT_NAME}_MULTIBODY_JOINT_HEADERS
186
  multibody/joint/fwd.hpp
187
188
  multibody/joint/joint-base.hpp
  multibody/joint/joint-revolute.hpp
189
  multibody/joint/joint-revolute-unaligned.hpp
190
  multibody/joint/joint-revolute-unbounded.hpp
191
  multibody/joint/joint-spherical.hpp
192
  multibody/joint/joint-spherical-ZYX.hpp
193
  multibody/joint/joint-prismatic.hpp
jcarpent's avatar
jcarpent committed
194
  multibody/joint/joint-prismatic-unaligned.hpp
195
  multibody/joint/joint-planar.hpp
196
  multibody/joint/joint-translation.hpp
197
198
  multibody/joint/joint-free-flyer.hpp
  multibody/joint/joint-variant.hpp
199
  multibody/joint/joint.hpp
200
201
  multibody/joint/joint-basic-visitors.hpp
  multibody/joint/joint-basic-visitors.hxx
202
  multibody/joint/joint-composite.hpp
203
204
  ) 

205
206
SET(${PROJECT_NAME}_MULTIBODY_LIEGROUP_HEADERS
  multibody/liegroup/liegroup.hpp
207
208
  multibody/liegroup/liegroup-algo.hpp
  multibody/liegroup/liegroup-algo.hxx
jcarpent's avatar
jcarpent committed
209
  multibody/liegroup/liegroup-variant.hpp
210
211
  multibody/liegroup/liegroup-variant-visitors.hpp
  multibody/liegroup/liegroup-variant-visitors.hxx
212
  multibody/liegroup/operation-base.hpp
213
  multibody/liegroup/operation-base.hxx
214
215
216
217
218
219
  multibody/liegroup/vector-space.hpp
  multibody/liegroup/cartesian-product.hpp
  multibody/liegroup/special-orthogonal.hpp
  multibody/liegroup/special-euclidean.hpp
  ) 

220
SET(${PROJECT_NAME}_MULTIBODY_HEADERS
221
  multibody/fwd.hpp
222
223
  multibody/constraint.hpp
  multibody/force-set.hpp
224
  multibody/frame.hpp
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
225
  multibody/model.hpp
226
  multibody/model.hxx
jcarpent's avatar
jcarpent committed
227
228
  multibody/data.hpp
  multibody/data.hxx
229
  multibody/visitor.hpp
230
231
232
  )

SET(${PROJECT_NAME}_ALGORITHM_HEADERS
jcarpent's avatar
jcarpent committed
233
  algorithm/aba.hpp
234
  algorithm/aba.hxx
235
236
  algorithm/aba-derivatives.hpp
  algorithm/aba-derivatives.hxx
237
  algorithm/rnea.hpp
238
  algorithm/rnea.hxx
239
240
  algorithm/rnea-derivatives.hpp
  algorithm/rnea-derivatives.hxx
241
  algorithm/crba.hpp
242
  algorithm/crba.hxx
243
244
  algorithm/finite-differences.hpp
  algorithm/finite-differences.hxx
Nicolas Mansard's avatar
Nicolas Mansard committed
245
  algorithm/jacobian.hpp
246
  algorithm/jacobian.hxx
Nicolas Mansard's avatar
Nicolas Mansard committed
247
  algorithm/cholesky.hpp
248
  algorithm/cholesky.hxx
249
  algorithm/kinematics.hpp
250
  algorithm/kinematics.hxx
251
252
  algorithm/kinematics-derivatives.hpp
  algorithm/kinematics-derivatives.hxx
253
  algorithm/dynamics.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
254
  algorithm/center-of-mass.hpp
255
  algorithm/center-of-mass.hxx
256
  algorithm/joint-configuration.hpp
257
  algorithm/joint-configuration.hxx
258
  algorithm/energy.hpp
259
  algorithm/frames.hpp
260
  algorithm/frames.hxx
261
  algorithm/compute-all-terms.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
262
  algorithm/copy.hpp
263
  algorithm/check.hpp
264
265
  algorithm/check.hxx
  algorithm/default-check.hpp
266
267
  algorithm/regressor.hpp
  algorithm/regressor.hxx
268
  )
269

270
271
272
273
SET(${PROJECT_NAME}_CONTAINER_HEADERS
  container/aligned-vector.hpp
  )

274
275
276
277
278
279
SET(${PROJECT_NAME}_PARSERS_HEADERS
  parsers/sample-models.hpp
  parsers/utils.hpp
  parsers/srdf.hpp
  ) 

280
IF(URDFDOM_FOUND)
281
282
283
  LIST(APPEND ${PROJECT_NAME}_PARSERS_HEADERS
    parsers/urdf.hpp
    parsers/urdf/utils.hpp
284
    parsers/urdf/types.hpp
285
    )
286

287
  ADD_DEFINITIONS(-DWITH_URDFDOM)
288
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_URDFDOM")
289
290
ENDIF(URDFDOM_FOUND)

291
292
LIST(APPEND ${PROJECT_NAME}_MULTIBODY_HEADERS
  multibody/fcl.hpp
293
  multibody/fcl.hxx
294
295
296
297
298
299
300
  multibody/geometry.hpp
  multibody/geometry.hxx
  )
LIST(APPEND ${PROJECT_NAME}_ALGORITHM_HEADERS
  algorithm/geometry.hpp
  algorithm/geometry.hxx
  )
301
IF(HPP_FCL_FOUND)
302
  LIST(APPEND ${PROJECT_NAME}_SPATIAL_HEADERS
303
304
    spatial/fcl-pinocchio-conversions.hpp
    )
305
306
307

  ADD_DEFINITIONS(-DWITH_HPP_FCL)
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_HPP_FCL")
308
309
ENDIF(HPP_FCL_FOUND)

310
IF(LUA5_FOUND)
311
312
313
  LIST(APPEND ${PROJECT_NAME}_PARSERS_HEADERS
    parsers/lua.hpp
    parsers/lua/lua_tables.hpp
jcarpent's avatar
jcarpent committed
314
315
    )

316
317
318
  ADD_DEFINITIONS(-DWITH_LUA5)
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_LUA5")
ENDIF(LUA5_FOUND)
jcarpent's avatar
jcarpent committed
319

320
321
322
323
324
SET(HEADERS
  ${${PROJECT_NAME}_MATH_HEADERS}
  ${${PROJECT_NAME}_TOOLS_HEADERS}
  ${${PROJECT_NAME}_SPATIAL_HEADERS}
  ${${PROJECT_NAME}_MULTIBODY_JOINT_HEADERS}
325
  ${${PROJECT_NAME}_MULTIBODY_LIEGROUP_HEADERS}
326
  ${${PROJECT_NAME}_MULTIBODY_HEADERS}
327
  ${${PROJECT_NAME}_PARSERS_HEADERS}
328
  ${${PROJECT_NAME}_ALGORITHM_HEADERS}
329
  ${${PROJECT_NAME}_CONTAINER_HEADERS}
330
331
  exception.hpp
  assert.hpp
332
  macros.hpp
333
334
335
 )
LIST(REMOVE_DUPLICATES HEADERS)

Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
336
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio")
337
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/math")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
338
339
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/spatial")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody")
340
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody/joint")
341
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody/liegroup")
342
343
344
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/parsers/lua")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/parsers")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/parsers/urdf")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
345
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/tools")
346
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/algorithm")
347
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/container")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
348

349
FOREACH(header ${HEADERS})
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
350
  GET_FILENAME_COMPONENT(headerName ${header} NAME)
351
352
353
354
355
  GET_FILENAME_COMPONENT(headerPath ${header} PATH)
  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E ${LINK}
    ${${PROJECT_NAME}_SOURCE_DIR}/src/${header}
    ${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}/${header})
  INSTALL(FILES ${${PROJECT_NAME}_SOURCE_DIR}/src/${header}
356
    DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/${headerPath}
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
357
358
359
          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
ENDFOREACH(header)

360
# --- MAIN LIBRARY -------------------------------------------------------------
361
ADD_SUBDIRECTORY(src)
362
363

# --- BINDINGS -----------------------------------------------------------------
364
SET(PYWRAP ${PROJECT_NAME}_pywrap)
365
366
ADD_SUBDIRECTORY(bindings)

367
# --- EXECUTABLES --------------------------------------------------------------
368
369
370
ADD_SUBDIRECTORY(utils)

# --- UNIT TESTS ---------------------------------------------------------------
371
ADD_SUBDIRECTORY(unittest)
372
373

# --- BENCHMARKS ---------------------------------------------------------------
374
ADD_SUBDIRECTORY(benchmark)
jcarpent's avatar
jcarpent committed
375

376
377
# --- PACKAGING ----------------------------------------------------------------
PKG_CONFIG_APPEND_LIBS (${PROJECT_NAME})
jcarpent's avatar
jcarpent committed
378
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_REQUIERED_COMPONENTS})
Nicolas Mansard's avatar
Nicolas Mansard committed
379

380
381
382
383
FOREACH(cflags ${CFLAGS_DEPENDENCIES})
  PKG_CONFIG_APPEND_CFLAGS(${cflags})
ENDFOREACH(cflags ${CFLAGS_DEPENDENCIES})

Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
384
SETUP_PROJECT_FINALIZE()