-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCMakeLists.txt
325 lines (287 loc) · 14 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
# setup some things initially
cmake_minimum_required (VERSION 2.6)
project (Moby)
include (CheckIncludeFiles)
include (CheckLibraryExists)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules)
# setup include directories
include_directories ("include")
# setup library sources
set (SOURCES AABB.cpp ArticulatedBody.cpp Base.cpp BoundingSphere.cpp BoxPrimitive.cpp BV.cpp CCD.cpp CollisionDetection.cpp CollisionGeometry.cpp CompGeom.cpp ConePrimitive.cpp ConstraintSimulator.cpp ConstraintStabilization.cpp ContactParameters.cpp ControlledBody.cpp CylinderPrimitive.cpp DampingForce.cpp Dissipation.cpp FixedJoint.cpp Gears.cpp GJK.cpp GravityForce.cpp HeightmapPrimitive.cpp ImpactConstraintHandler.cpp ImpactConstraintHandlerNQP.cpp ImpactConstraintHandlerLCP.cpp ImpactConstraintHandlerQP.cpp IndexedTetraArray.cpp IndexedTriArray.cpp Joint.cpp LCP.cpp Log.cpp LP.cpp OBB.cpp OSGGroupWrapper.cpp PenaltyConstraintHandler.cpp PlanarJoint.cpp PlanePrimitive.cpp PolyhedralPrimitive.cpp Polyhedron.cpp Primitive.cpp PrismaticJoint.cpp RCArticulatedBody.cpp RevoluteJoint.cpp RigidBody.cpp SDFReader.cpp Simulator.cpp SparseJacobian.cpp SpherePrimitive.cpp SphericalJoint.cpp SignedDistDot.cpp SSL.cpp SSR.cpp StokesDragForce.cpp TessellatedPolyhedron.cpp Tetrahedron.cpp ThickTriangle.cpp TimeSteppingSimulator.cpp TorusPrimitive.cpp Triangle.cpp TriangleMeshPrimitive.cpp UnilateralConstraint.cpp UniversalJoint.cpp URDFReader.cpp Visualizable.cpp XMLReader.cpp XMLTree.cpp XMLWriter.cpp)
#set (SOURCES MCArticulatedBody.cpp)
# build options
option (BUILD_SHARED_LIBS "Build Moby as a shared library?" ON)
option (BUILD_TOOLS "Build the programs in the tools subdirectory?" ON)
option (USE_OSG "Build against OpenSceneGraph library?" ON)
option (USE_AP "Use the Anitescu-Potra contact model?" OFF)
option (USE_QLCPD "Build against QLCPD library?" OFF)
option (USE_QPOASES "Build against QPOASES library?" OFF)
option (VISUALIZE_INERTIA "Visualize moments of inertia?" OFF)
option (PROFILE "Build for profiling?" OFF)
option (USE_SIGNED_DIST_CONSTRAINT "Use signed distance constraint? (experimental)" OFF)
# look for QLCPD
find_library(QLCPD_FOUND qlcpd-dense /usr/local/lib /usr/lib)
if (USE_QLCPD AND QLCPD_FOUND)
set (SOURCES ${SOURCES} QLCPD.cpp)
set (EXTRA_LIBS qlcpd-dense)
set_source_files_properties(src/ImpactConstraintHandler.cpp PROPERTIES COMPILE_FLAGS -DUSE_QLCPD)
set_source_files_properties(src/ImpactConstraintHandlerQP.cpp PROPERTIES COMPILE_FLAGS -DUSE_QLCPD)
endif (USE_QLCPD AND QLCPD_FOUND)
find_package (QPOASES)
if (QPOASES_FOUND)
set (EXTRA_LIBS qpOASES)
set_source_files_properties(src/ImpactConstraintHandler.cpp PROPERTIES COMPILE_FLAGS -DUSE_QPOASES)
set_source_files_properties(src/ImpactConstraintHandlerQP.cpp PROPERTIES COMPILE_FLAGS -DUSE_QPOASES)
endif (QPOASES_FOUND)
# modify C++ flags
add_definitions (-DSAFESTATIC=static)
if (OMP)
find_package (OpenMP REQUIRED)
include_directories (${OPENMP_INCLUDE_DIRS})
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS})
endif (OMP)
if (PROFILE)
set_source_files_properties(programs/driver.cpp PROPERTIES COMPILE_FLAGS -DGOOGLE_PROFILER)
set (EXTRA_LIBS ${EXTRA_LIBS} profiler)
endif (PROFILE)
if (USE_SIGNED_DIST_CONSTRAINT)
set_source_files_properties(src/ImpactConstraintHandler.cpp PROPERTIES COMPILE_FLAGS -DUSE_SIGNED_DIST_CONSTRAINT)
set_source_files_properties(src/ImpactConstraintHandlerQP.cpp PROPERTIES COMPILE_FLAGS -DUSE_SIGNED_DIST_CONSTRAINT)
endif (USE_SIGNED_DIST_CONSTRAINT)
# fix the C++ linking error on 64-bit Linux
set (CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -ldl")
# find libraries
find_package (Ravelin REQUIRED)
find_package (LibXml2 REQUIRED)
find_package (Boost REQUIRED)
find_package (IPOPT)
get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
find_package (QHULL REQUIRED)
find_package (osg)
find_package (osgViewer)
find_package (osgDB)
find_package (osgGA)
find_package (osgFX)
find_package (osgUtil)
find_package (OpenThreads)
# see whether the Anitescu-Potra model should be activated
if (USE_AP)
set_source_files_properties(src/ImpactConstraintHandler.cpp PROPERTIES COMPILE_FLAGS -DUSE_AP_MODEL)
endif (USE_AP)
# see whether IPOPT was detected
if (USE_IPOPT AND IPOPT_FOUND)
add_definitions (-DHAVE_CSTDDEF)
add_definitions (-DHAVE_IPOPT)
include_directories (IPOPT_INCLUDE_DIRS)
link_directories (IPOPT_LIBRARY_DIRS)
if (APPLE)
find_package (BLAS REQUIRED)
else (APPLE)
find_package (CBLAS REQUIRED)
endif (APPLE)
# set (EXTRA_LIBS "${EXTRA_LIBS} ${BLAS_LIBRARIES}")
find_library(IPOPT ipopt /usr/local/lib /usr/lib)
find_library(IPOPT_MUMPS coinmumps /usr/local/lib /usr/lib)
find_library(IPOPT_METIS coinmetis /usr/local/lib /usr/lib)
# find_library(GFORTRAN gfortran /usr/local/lib /usr/lib)
# set (EXTRA_LIBS ${EXTRA_LIBS} ${IPOPT_MUMPS} ${IPOPT_METIS} ${GFORTRAN})
set (EXTRA_LIBS ${EXTRA_LIBS} ${IPOPT} ${IPOPT_MUMPS} ${IPOPT_METIS})
set (SOURCES ${SOURCES} LCP_IPOPT.cpp NQP_IPOPT.cpp)
endif (USE_IPOPT AND IPOPT_FOUND)
# setup OSG includes and additional sources
if (USE_OSG AND OSG_FOUND)
if (OSGDB_FOUND)
if (OSGVIEWER_FOUND)
if (OPENTHREADS_FOUND)
include_directories (${OSG_INCLUDE_DIR})
include_directories (${OSGDB_INCLUDE_DIR})
include_directories (${OSGGA_INCLUDE_DIR})
include_directories (${OSGVIEWER_INCLUDE_DIR})
include_directories (${OPENTHREADS_INCLUDE_DIR})
add_definitions (-DUSE_OSG)
set (SOURCES ${SOURCES} OsgTorus.cpp)
else (OPENTHREADS_FOUND)
unset (OSG_FOUND)
endif (OPENTHREADS_FOUND)
else (OSGVIEWER_FOUND)
unset (OSG_FOUND)
endif (OSGVIEWER_FOUND)
else (OSGDB_FOUND)
unset (OSG_FOUND)
endif (OSGDB_FOUND)
endif (USE_OSG AND OSG_FOUND)
if (NOT OSG_FOUND)
set (USE_OSG FALSE)
endif (NOT OSG_FOUND)
if (NOT USE_OSG)
set (VISUALIZE_INERTIA FALSE)
endif (NOT USE_OSG)
if (VISUALIZE_INERTIA)
add_definitions (-DVISUALIZE_INERTIA)
endif (VISUALIZE_INERTIA)
# setup include directories, compiler flags, and libraries for optional pkgs
if (LIBXML2_FOUND)
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${LIBXML2_DEFINITIONS})
include_directories (${LIBXML2_INCLUDE_DIR})
endif (LIBXML2_FOUND)
# setup include directories, compiler flags, and libraries for required pkgs
include_directories (${BOOST_INCLUDE_DIR})
include_directories (${QHULL_INCLUDE_DIR})
include_directories (${RAVELIN_INCLUDE_DIR})
# configure checks: optional libraries
CHECK_LIBRARY_EXISTS(odepack dlsode_ "" HAVE_ODEPACK)
# setup necessary library list
set (REQLIBS qhull)
# build against ODEPACK?
if (HAVE_ODEPACK)
add_definitions (-DUSE_ODEPACK)
set (EXTRA_LIBS ${EXTRA_LIBS} odepack)
endif (HAVE_ODEPACK)
# prepend "src/" to each source file
foreach (i ${SOURCES})
set (LIBSOURCES ${LIBSOURCES} "${CMAKE_SOURCE_DIR}/src/${i}")
endforeach (i)
# create the library
add_library(Moby "" "" ${LIBSOURCES})
target_link_libraries (Moby ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${QHULL_LIBRARIES} ${RAVELIN_LIBRARIES} ${EXTRA_LIBS})
# link optional libraries
if (OMP)
target_link_libraries (Moby ${OPENMP_LIBRARIES})
endif (OMP)
if (LIBXML2_FOUND)
target_link_libraries (Moby ${LIBXML2_LIBRARIES})
endif (LIBXML2_FOUND)
if (USE_OSG AND OSG_FOUND)
target_link_libraries (Moby ${OSG_LIBRARIES})
target_link_libraries (Moby ${OSGVIEWER_LIBRARIES})
target_link_libraries (Moby ${OSGDB_LIBRARIES})
target_link_libraries (Moby ${OSGGA_LIBRARIES})
target_link_libraries (Moby ${OPENTHREADS_LIBRARY})
target_link_libraries (Moby ${OSGUTIL_LIBRARIES})
target_link_libraries (Moby ${OSGMANIPULATOR_LIBRARIES})
endif (USE_OSG AND OSG_FOUND)
add_library(MobyDriver "" "" programs/driver.cpp)
target_link_libraries (MobyDriver Moby)
# build the tools?
if (BUILD_TOOLS)
add_executable(moby-driver programs/main.cpp)
if (USE_OSG AND OSG_FOUND)
add_executable(moby-view programs/view.cpp)
endif (USE_OSG AND OSG_FOUND)
# tools
add_executable(moby-render programs/render.cpp)
add_executable(moby-regress programs/regress.cpp)
add_executable(moby-compare-trajs programs/compare-trajs.cpp)
# add_executable(moby-conv-decomp programs/conv-decomp.cpp)
add_executable(moby-convexify programs/convexify.cpp)
add_executable(moby-adjust-center programs/adjust-center.cpp)
add_executable(moby-center programs/center.cpp)
target_link_libraries(moby-driver MobyDriver Moby)
if (USE_OSG AND OSG_FOUND)
target_link_libraries(moby-render ${OSG_LIBRARIES})
target_link_libraries(moby-render ${OSGVIEWER_LIBRARIES})
target_link_libraries(moby-render ${OSGDB_LIBRARIES})
target_link_libraries(moby-render ${OSGGA_LIBRARIES})
target_link_libraries(moby-render ${OPENTHREADS_LIBRARIES})
target_link_libraries(moby-view ${OSG_LIBRARIES})
target_link_libraries(moby-view ${OSGVIEWER_LIBRARIES})
target_link_libraries(moby-view ${OSGDB_LIBRARIES})
target_link_libraries(moby-view ${OSGGA_LIBRARIES})
target_link_libraries(moby-view ${OPENTHREADS_LIBRARIES})
endif (USE_OSG AND OSG_FOUND)
# tools
target_link_libraries(moby-render Moby)
target_link_libraries(moby-regress Moby)
target_link_libraries(moby-compare-trajs Moby)
# target_link_libraries(moby-conv-decomp Moby)
target_link_libraries(moby-convexify Moby)
# target_link_libraries(moby-output-symbolic Moby)
target_link_libraries(moby-adjust-center Moby)
target_link_libraries(moby-center Moby)
endif (BUILD_TOOLS)
# create environment variables file
file (WRITE ${CMAKE_BINARY_DIR}/setup.sh "#!/bin/bash\nexport MOBY_PLUGIN_PATH=${CMAKE_BINARY_DIR}\n\n")
# plugins
# box plugin
add_library(box-plugin MODULE example/simple-contact/box-plugin.cpp)
target_link_libraries(box-plugin Moby)
# ur10 plugin
add_library(ur10-plugin MODULE example/ur10/controller.cpp)
target_link_libraries(ur10-plugin Moby)
# rimless wheel plugins
add_library(rimless-wheel-coldet-plugin MODULE example/rimless-wheel/coldet-plugin.cpp)
add_library(rimless-wheel-init MODULE example/rimless-wheel/init.cpp)
target_link_libraries(rimless-wheel-init Moby)
target_link_libraries(rimless-wheel-coldet-plugin Moby)
# passive dynamic walker plugins
add_library(passive-walker-init MODULE example/passive-walker/init.cpp)
add_library(passive-walker-coldet-plugin MODULE example/passive-walker/coldet-plugin.cpp)
target_link_libraries(passive-walker-init Moby)
target_link_libraries(passive-walker-coldet-plugin Moby)
# contact constrained pendulum plugins
add_library(contact-constrained-pendulum-coldet-plugin MODULE example/contact-constrained-pendulum/contact-constrained-pendulum-coldet-plugin.cpp)
add_library(contact-constrained-pendulum-init MODULE example/contact-constrained-pendulum/contact-constrained-pendulum-init.cpp)
target_link_libraries(contact-constrained-pendulum-coldet-plugin Moby)
target_link_libraries(contact-constrained-pendulum-init Moby)
# qp solver examples
if (QP_OASES_FOUND)
add_executable(qp-example example/qp/qp.cpp)
target_link_libraries(qp-example Moby)
endif (QP_OASES_FOUND)
#sims-in-code examples
add_executable(sim-in-code-block example/sims-in-code/block.cpp)
target_link_libraries(sim-in-code-block Moby Ravelin)
add_executable(sim-in-code-pendulum example/sims-in-code/pendulum.cpp)
target_link_libraries(sim-in-code-pendulum Moby Ravelin)
add_executable(sim-in-code-pushpendulum example/sims-in-code/pushpendulum.cpp)
target_link_libraries(sim-in-code-pushpendulum Moby Ravelin)
add_executable(sim-in-code-doublependulum example/sims-in-code/doublependulum.cpp)
target_link_libraries(sim-in-code-doublependulum Moby Ravelin)
add_executable(sim-in-code-linearactuator example/sims-in-code/linearactuator.cpp)
target_link_libraries(sim-in-code-linearactuator Moby Ravelin)
#if (USE_OSG AND OSG_FOUND)
# target_link_libraries(sim-in-code-pendulum ${OSG_LIBRARIES})
# target_link_libraries(sim-in-code-pendulum ${OSGVIEWER_LIBRARIES})
# target_link_libraries(sim-in-code-pendulum ${OSGDB_LIBRARIES})
# target_link_libraries(sim-in-code-pendulum ${OSGGA_LIBRARIES})
# target_link_libraries(sim-in-code-pendulum ${OPENTHREADS_LIBRARIES})
#endif (USE_OSG AND OSG_FOUND)
# setup source file
install (CODE "file(WRITE setup.sh \"#!/bin/bash\nexport MOBY_PLUGIN_PATH=${CMAKE_INSTALL_PREFIX}/lib/Moby/plugins\n\n\")")
install (FILES ${CMAKE_BINARY_DIR}/setup.sh DESTINATION share/Moby)
install (FILES programs/render-movie.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install (FILES programs/render-movie-simple.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
# setup install locations for plugins
install (TARGETS passive-walker-init DESTINATION lib/Moby/plugins)
install (TARGETS passive-walker-coldet-plugin DESTINATION lib/Moby/plugins)
install (TARGETS contact-constrained-pendulum-coldet-plugin DESTINATION lib/Moby/plugins)
install (TARGETS contact-constrained-pendulum-init DESTINATION lib/Moby/plugins)
install (TARGETS passive-walker-init DESTINATION lib/Moby/plugins)
install (TARGETS passive-walker-coldet-plugin DESTINATION lib/Moby/plugins)
install (TARGETS rimless-wheel-init DESTINATION lib/Moby/plugins)
install (TARGETS rimless-wheel-coldet-plugin DESTINATION lib/Moby/plugins)
install (TARGETS box-plugin DESTINATION lib/Moby/plugins)
# setup install locations for library
install (TARGETS Moby DESTINATION lib)
install (TARGETS MobyDriver DESTINATION lib)
# setup install locations for binaries
install (TARGETS moby-driver DESTINATION bin)
if (USE_OSG AND OSG_FOUND)
install (TARGETS moby-view DESTINATION bin)
install (TARGETS moby-render DESTINATION bin)
endif (USE_OSG AND OSG_FOUND)
#install (TARGETS moby-conv-decomp DESTINATION bin)
install (TARGETS moby-convexify DESTINATION bin)
install (TARGETS moby-adjust-center DESTINATION bin)
install (TARGETS moby-center DESTINATION bin)
# setup install locations for headers
install (DIRECTORY ${CMAKE_SOURCE_DIR}/include/Moby DESTINATION include)
# setup install locations for examples
install (DIRECTORY ${CMAKE_SOURCE_DIR}/example/simple-contact DESTINATION share/Moby)
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/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)