CMakeLists.txt 11.7 KB
Newer Older
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
1
#
2
# Copyright (c) 2015-2016 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
23
24
25
26

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/eigen.cmake)
INCLUDE(cmake/python.cmake)

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.4.2")
83

84
# Spetcial care of Eigen3 greater than 3.2.10
85
IF(EIGEN3_FOUND)
86
  IF(${EIGEN3_VERSION} VERSION_GREATER "3.2.10")
87
    ADD_DEFINITIONS(-DEIGEN3_FUTURE)
88
    SET(EIGEN3_FUTURE TRUE)
89
    PKG_CONFIG_APPEND_CFLAGS("-DEIGEN3_FUTURE")
90
  ELSE(${EIGEN3_VERSION} VERSION_GREATER "3.2.10")
jcarpent's avatar
jcarpent committed
91
    SET(EIGEN3_FUTURE FALSE)
92
  ENDIF(${EIGEN3_VERSION} VERSION_GREATER "3.2.10")
93
94
ENDIF(EIGEN3_FOUND)

95
# Special care of urdfdom version
96
97
IF(URDFDOM_FOUND)
  IF(${URDFDOM_VERSION} VERSION_LESS "0.3.0")
98
    ADD_DEFINITIONS(-DURDFDOM_COLLISION_WITH_GROUP_NAME)
99
    PKG_CONFIG_APPEND_CFLAGS("-DURDFDOM_COLLISION_WITH_GROUP_NAME")
100
  ENDIF(${URDFDOM_VERSION} VERSION_LESS "0.3.0")
101
102
103
104
105
106
107
108
109
110
111
112

  # 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")
113
114
ENDIF(URDFDOM_FOUND)

115
116
# 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
117
118
119
IF(BUILD_WITH_LUA_SUPPORT)
  ADD_OPTIONAL_DEPENDENCY("lua5.2")
  IF(LUA5_2_FOUND)
120
    SET(LUA5_FOUND TRUE)
jcarpent's avatar
jcarpent committed
121
122
123
124
125
126
127
128
129
130
131
132
133
    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)
134

jcarpent's avatar
jcarpent committed
135
136
137
138
SET(BOOST_REQUIERED_COMPONENTS filesystem system)
SET(BOOST_BUILD_COMPONENTS unit_test_framework)
SET(BOOST_OPTIONAL_COMPONENTS "")

139
IF(BUILD_PYTHON_INTERFACE)
jcarpent's avatar
jcarpent committed
140
  SET(BOOST_OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS} python)
141
  FINDPYTHON(2.7 EXACT REQUIRED)
jcarpent's avatar
jcarpent committed
142
  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) 
143
144
ENDIF(BUILD_PYTHON_INTERFACE)

jcarpent's avatar
jcarpent committed
145
SET(BOOST_COMPONENTS ${BOOST_REQUIERED_COMPONENTS} ${BOOST_OPTIONAL_COMPONENTS} ${BOOST_BUILD_COMPONENTS})
146
SEARCH_FOR_BOOST()
147

148
149
150
# Variable containing all the cflags definition relative to optional dependencies
SET(CFLAGS_DEPENDENCIES)

151
152
153
# Path to boost headers
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})

Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
154
155
156
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
157
158

SET(${PROJECT_NAME}_MATH_HEADERS
159
  math/fwd.hpp
160
  math/sincos.hpp
161
  math/quaternion.hpp
162
  math/matrix.hpp
163
164
165
  )

SET(${PROJECT_NAME}_TOOLS_HEADERS
166
  tools/timer.hpp
167
  tools/string-generator.hpp
168
  tools/file-explorer.hpp
169
170
171
  )

SET(${PROJECT_NAME}_SPATIAL_HEADERS
172
  spatial/symmetric3.hpp
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
173
174
175
176
177
178
  spatial/se3.hpp
  spatial/motion.hpp
  spatial/force.hpp
  spatial/inertia.hpp
  spatial/fwd.hpp
  spatial/skew.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
179
  spatial/act-on-set.hpp
180
  spatial/explog.hpp
181
182
  )

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

203
204
205
SET(${PROJECT_NAME}_MULTIBODY_LIEGROUP_HEADERS
  multibody/liegroup/liegroup.hpp
  multibody/liegroup/operation-base.hpp
206
  multibody/liegroup/operation-base.hxx
207
208
209
210
211
212
  multibody/liegroup/vector-space.hpp
  multibody/liegroup/cartesian-product.hpp
  multibody/liegroup/special-orthogonal.hpp
  multibody/liegroup/special-euclidean.hpp
  ) 

213
SET(${PROJECT_NAME}_MULTIBODY_HEADERS
214
  multibody/fwd.hpp
215
216
  multibody/constraint.hpp
  multibody/force-set.hpp
217
  multibody/frame.hpp
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
218
  multibody/model.hpp
219
  multibody/model.hxx
220
  multibody/visitor.hpp
221
222
223
  )

SET(${PROJECT_NAME}_ALGORITHM_HEADERS
jcarpent's avatar
jcarpent committed
224
  algorithm/aba.hpp
225
  algorithm/aba.hxx
226
  algorithm/rnea.hpp
227
  algorithm/rnea.hxx
228
  algorithm/crba.hpp
229
  algorithm/crba.hxx
230
231
  algorithm/finite-differences.hpp
  algorithm/finite-differences.hxx
Nicolas Mansard's avatar
Nicolas Mansard committed
232
  algorithm/jacobian.hpp
233
  algorithm/jacobian.hxx
Nicolas Mansard's avatar
Nicolas Mansard committed
234
  algorithm/cholesky.hpp
235
  algorithm/cholesky.hxx
236
  algorithm/kinematics.hpp
237
  algorithm/kinematics.hxx
238
  algorithm/dynamics.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
239
  algorithm/center-of-mass.hpp
240
  algorithm/center-of-mass.hxx
241
  algorithm/joint-configuration.hpp
242
  algorithm/energy.hpp
243
  algorithm/frames.hpp
244
  algorithm/compute-all-terms.hpp
Nicolas Mansard's avatar
Nicolas Mansard committed
245
  algorithm/copy.hpp
246
  algorithm/check.hpp
247
248
  algorithm/check.hxx
  algorithm/default-check.hpp
249
  )
250

251
252
253
254
SET(${PROJECT_NAME}_CONTAINER_HEADERS
  container/aligned-vector.hpp
  )

255
256
257
258
259
260
SET(${PROJECT_NAME}_PARSERS_HEADERS
  parsers/sample-models.hpp
  parsers/utils.hpp
  parsers/srdf.hpp
  ) 

261
IF(URDFDOM_FOUND)
262
263
264
  LIST(APPEND ${PROJECT_NAME}_PARSERS_HEADERS
    parsers/urdf.hpp
    parsers/urdf/utils.hpp
265
    parsers/urdf/types.hpp
266
    )
267

268
  ADD_DEFINITIONS(-DWITH_URDFDOM)
269
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_URDFDOM")
270
271
ENDIF(URDFDOM_FOUND)

272
273
LIST(APPEND ${PROJECT_NAME}_MULTIBODY_HEADERS
  multibody/fcl.hpp
274
  multibody/fcl.hxx
275
276
277
278
279
280
281
  multibody/geometry.hpp
  multibody/geometry.hxx
  )
LIST(APPEND ${PROJECT_NAME}_ALGORITHM_HEADERS
  algorithm/geometry.hpp
  algorithm/geometry.hxx
  )
282
IF(HPP_FCL_FOUND)
283
  LIST(APPEND ${PROJECT_NAME}_SPATIAL_HEADERS
284
285
    spatial/fcl-pinocchio-conversions.hpp
    )
286
287
288

  ADD_DEFINITIONS(-DWITH_HPP_FCL)
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_HPP_FCL")
289
290
ENDIF(HPP_FCL_FOUND)

291
IF(LUA5_FOUND)
292
293
294
  LIST(APPEND ${PROJECT_NAME}_PARSERS_HEADERS
    parsers/lua.hpp
    parsers/lua/lua_tables.hpp
jcarpent's avatar
jcarpent committed
295
296
    )

297
298
299
  ADD_DEFINITIONS(-DWITH_LUA5)
  LIST(APPEND CFLAGS_DEPENDENCIES "-DWITH_LUA5")
ENDIF(LUA5_FOUND)
jcarpent's avatar
jcarpent committed
300

301
302
303
304
305
SET(HEADERS
  ${${PROJECT_NAME}_MATH_HEADERS}
  ${${PROJECT_NAME}_TOOLS_HEADERS}
  ${${PROJECT_NAME}_SPATIAL_HEADERS}
  ${${PROJECT_NAME}_MULTIBODY_JOINT_HEADERS}
306
  ${${PROJECT_NAME}_MULTIBODY_LIEGROUP_HEADERS}
307
  ${${PROJECT_NAME}_MULTIBODY_HEADERS}
308
  ${${PROJECT_NAME}_PARSERS_HEADERS}
309
  ${${PROJECT_NAME}_ALGORITHM_HEADERS}
310
  ${${PROJECT_NAME}_CONTAINER_HEADERS}
311
312
313
314
315
  exception.hpp
  assert.hpp
 )
LIST(REMOVE_DUPLICATES HEADERS)

Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
316
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio")
317
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/math")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
318
319
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/spatial")
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody")
320
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody/joint")
321
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/multibody/liegroup")
322
323
324
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
325
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/tools")
326
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/algorithm")
327
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio/container")
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
328

329
FOREACH(header ${HEADERS})
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
330
  GET_FILENAME_COMPONENT(headerName ${header} NAME)
331
332
333
334
335
  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}
336
    DESTINATION ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME}/${headerPath}
Nicolas Mansard's avatar
IVIGIT.  
Nicolas Mansard committed
337
338
339
          PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
ENDFOREACH(header)

340
# --- MAIN LIBRARY -------------------------------------------------------------
341
ADD_SUBDIRECTORY(src)
342
343

# --- BINDINGS -----------------------------------------------------------------
344
SET(PYWRAP ${PROJECT_NAME}_pywrap)
345
346
ADD_SUBDIRECTORY(bindings)

347
# --- EXECUTABLES --------------------------------------------------------------
348
349
350
ADD_SUBDIRECTORY(utils)

# --- UNIT TESTS ---------------------------------------------------------------
351
ADD_SUBDIRECTORY(unittest)
352
353

# --- BENCHMARKS ---------------------------------------------------------------
354
ADD_SUBDIRECTORY(benchmark)
jcarpent's avatar
jcarpent committed
355

356
357
# --- PACKAGING ----------------------------------------------------------------
PKG_CONFIG_APPEND_LIBS (${PROJECT_NAME})
jcarpent's avatar
jcarpent committed
358
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_REQUIERED_COMPONENTS})
Nicolas Mansard's avatar
Nicolas Mansard committed
359

360
361
362
363
FOREACH(cflags ${CFLAGS_DEPENDENCIES})
  PKG_CONFIG_APPEND_CFLAGS(${cflags})
ENDFOREACH(cflags ${CFLAGS_DEPENDENCIES})

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