-
Notifications
You must be signed in to change notification settings - Fork 47
/
CMakeLists.txt
281 lines (239 loc) · 9.21 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
SET ( RBDL_VERSION_MAJOR 3 )
SET ( RBDL_VERSION_MINOR 1 )
SET ( RBDL_VERSION_PATCH 3 )
SET ( RBDL_VERSION
${RBDL_VERSION_MAJOR}.${RBDL_VERSION_MINOR}.${RBDL_VERSION_PATCH}
)
SET ( RBDL_SO_VERSION
${RBDL_VERSION_MAJOR}.${RBDL_VERSION_MINOR}.${RBDL_VERSION_PATCH}
)
SET (PROJECT_VERSION ${RBDL_VERSION})
PROJECT (RBDL VERSION ${RBDL_VERSION})
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake )
INCLUDE_DIRECTORIES (
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_SOURCE_DIR}/tests
)
# SET (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
INCLUDE(GNUInstallDirs)
SET_TARGET_PROPERTIES ( ${PROJECT_EXECUTABLES} PROPERTIES
LINKER_LANGUAGE CXX
)
# Set a default build type to 'Release' if none was specified
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
MESSAGE(STATUS "Setting build type to 'Release' as none was specified.")
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
ENDIF()
IF (MSVC)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /permissive- /std:c++17")
ENDIF (MSVC)
IF(APPLE)
SET(CMAKE_CXX_STANDARD 17)
INCLUDE_DIRECTORIES("/usr/local/include")
ENDIF(APPLE)
IF ( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )
ADD_DEFINITIONS (-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
ELSE( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )
ADD_COMPILE_DEFINITIONS (_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
ENDIF( ${CMAKE_VERSION} VERSION_LESS 3.12.0 )
SET (RBDL_BUILD_COMPILER_ID ${CMAKE_CXX_COMPILER_ID})
SET (RBDL_BUILD_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
# Options
SET (RBDL_BUILD_STATIC_DEFAULT OFF)
OPTION (RBDL_BUILD_STATIC "Build statically linked library (otherwise dynamiclly linked)" ${RBDL_BUILD_STATIC_DEFAULT})
OPTION (RBDL_BUILD_TESTS "Build the test executables" OFF)
OPTION (RBDL_ENABLE_LOGGING "Enable logging (warning: major impact on performance!)" OFF)
OPTION (RBDL_STORE_VERSION "Enable storing of version information in the library (requires build from valid repository)" OFF)
OPTION (RBDL_BUILD_ADDON_URDFREADER "Build the (experimental) urdf reader" OFF)
OPTION (RBDL_BUILD_ADDON_BENCHMARK "Build the benchmarking tool" OFF)
OPTION (RBDL_BUILD_ADDON_LUAMODEL "Build the lua model reader" OFF)
OPTION (RBDL_BUILD_PYTHON_WRAPPER "Build experimental python wrapper" OFF)
OPTION (RBDL_BUILD_ADDON_GEOMETRY "Build the geometry library" OFF)
OPTION (RBDL_BUILD_ADDON_MUSCLE "Build the muscle library" OFF)
OPTION (RBDL_BUILD_ADDON_MUSCLE_FITTING "Build muscle library fitting functions (requires Ipopt)" OFF)
OPTION (RBDL_BUILD_ADDON_BALANCE "Build balance library" OFF)
OPTION (RBDL_BUILD_EXECUTABLES "Build addon executables, disable this if you only want to build the libraries." ON)
OPTION (RBDL_USE_PYTHON_2 "Use python 2 instead of python 3" OFF)
OPTION (RBDL_USE_CASADI_MATH "Use the CasADi backend" OFF)
OPTION (RBDL_VCPKG_BUILD "Building RBDL in vcpkg environment" OFF)
# Find and use the system's Eigen3 library
FIND_PACKAGE (Eigen3 3.0.0)
IF (NOT EIGEN3_FOUND)
MESSAGE (WARNING "Could not find Eigen3 on your system. Please install it!")
ENDIF (NOT EIGEN3_FOUND)
INCLUDE_DIRECTORIES (${EIGEN3_INCLUDE_DIR})
# Addons
IF (RBDL_BUILD_ADDON_URDFREADER)
ADD_SUBDIRECTORY ( addons/urdfreader )
ENDIF (RBDL_BUILD_ADDON_URDFREADER)
IF (RBDL_BUILD_ADDON_BENCHMARK)
ADD_SUBDIRECTORY ( addons/benchmark )
ENDIF (RBDL_BUILD_ADDON_BENCHMARK)
IF (RBDL_USE_CASADI_MATH)
ADD_SUBDIRECTORY( casadi )
ENDIF (RBDL_USE_CASADI_MATH)
IF(RBDL_BUILD_ADDON_MUSCLE)
SET(RBDL_BUILD_ADDON_GEOMETRY ON CACHE BOOL "Build the geometry library" FORCE)
IF (RBDL_BUILD_ADDON_MUSCLE_FITTING)
SET(CUSTOM_IPOPT_PATH "" CACHE PATH "Path to specific IPOPT Installation")
ENDIF (RBDL_BUILD_ADDON_MUSCLE_FITTING)
ADD_SUBDIRECTORY ( addons/muscle )
IF(RBDL_BUILD_TESTS)
ADD_SUBDIRECTORY ( addons/muscle/tests )
ENDIF(RBDL_BUILD_TESTS)
ENDIF(RBDL_BUILD_ADDON_MUSCLE)
IF(RBDL_BUILD_ADDON_GEOMETRY)
ADD_SUBDIRECTORY ( addons/geometry )
IF(RBDL_BUILD_TESTS)
ADD_SUBDIRECTORY ( addons/geometry/tests )
ENDIF(RBDL_BUILD_TESTS)
ENDIF(RBDL_BUILD_ADDON_GEOMETRY)
IF(RBDL_BUILD_ADDON_BALANCE)
ADD_SUBDIRECTORY ( addons/balance )
IF(RBDL_BUILD_TESTS)
ADD_SUBDIRECTORY ( addons/balance/tests )
ENDIF(RBDL_BUILD_TESTS)
ENDIF(RBDL_BUILD_ADDON_BALANCE)
IF (RBDL_BUILD_ADDON_LUAMODEL)
ADD_SUBDIRECTORY ( addons/luamodel )
IF(RBDL_BUILD_TESTS)
ADD_SUBDIRECTORY ( addons/luamodel/tests )
ENDIF(RBDL_BUILD_TESTS)
ENDIF (RBDL_BUILD_ADDON_LUAMODEL)
IF (RBDL_BUILD_TESTS)
ADD_SUBDIRECTORY ( tests )
ENDIF (RBDL_BUILD_TESTS)
# Source files for RBDL
SET ( RBDL_SOURCES
src/rbdl_version.cc
src/rbdl_mathutils.cc
src/rbdl_utils.cc
src/rbdl_errors.cc
src/Constraints.cc
src/Constraint_Contact.cc
src/Constraint_Loop.cc
src/Dynamics.cc
src/Logging.cc
src/Joint.cc
src/Model.cc
src/Kinematics.cc
)
# Static / dynamic builds
IF (RBDL_BUILD_STATIC)
ADD_LIBRARY ( rbdl-static STATIC ${RBDL_SOURCES} )
TARGET_INCLUDE_DIRECTORIES(rbdl-static PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
IF (NOT WIN32)
SET_TARGET_PROPERTIES ( rbdl-static PROPERTIES PREFIX "lib")
ENDIF (NOT WIN32)
SET_TARGET_PROPERTIES ( rbdl-static PROPERTIES OUTPUT_NAME "rbdl")
IF (RBDL_BUILD_ADDON_LUAMODEL)
TARGET_LINK_LIBRARIES ( rbdl-static
rbdl_luamodel-static
)
ENDIF (RBDL_BUILD_ADDON_LUAMODEL)
IF (RBDL_BUILD_ADDON_URDFREADER)
TARGET_LINK_LIBRARIES ( rbdl-static
rbdl_urdfreader-static
)
ENDIF (RBDL_BUILD_ADDON_URDFREADER)
IF (RBDL_USE_CASADI_MATH)
TARGET_LINK_LIBRARIES ( rbdl-static
${Casadi_LIBRARY}
)
ENDIF (RBDL_USE_CASADI_MATH)
INSTALL (TARGETS rbdl-static
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
ELSE (RBDL_BUILD_STATIC)
ADD_LIBRARY ( rbdl SHARED ${RBDL_SOURCES} )
TARGET_INCLUDE_DIRECTORIES(rbdl PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include)
SET_TARGET_PROPERTIES ( rbdl PROPERTIES
VERSION ${RBDL_VERSION}
SOVERSION ${RBDL_SO_VERSION}
)
IF (RBDL_USE_CASADI_MATH)
TARGET_LINK_LIBRARIES ( rbdl
${Casadi_LIBRARY}
)
ENDIF (RBDL_USE_CASADI_MATH)
INSTALL (TARGETS rbdl
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
ENDIF (RBDL_BUILD_STATIC)
IF (RBDL_STORE_VERSION)
# Set versioning information that can be queried during runtime
EXECUTE_PROCESS(COMMAND "git" "rev-parse" "HEAD"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE RBDL_BUILD_COMMIT)
STRING(REGEX REPLACE "\n$" "" RBDL_BUILD_COMMIT "${RBDL_BUILD_COMMIT}")
EXECUTE_PROCESS(COMMAND "git" "describe" "--all" "--dirty" "--long"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE RBDL_BUILD_BRANCH)
STRING(REGEX REPLACE "\n$" "" RBDL_BUILD_BRANCH "${RBDL_BUILD_BRANCH}")
SET (RBDL_BUILD_TYPE ${CMAKE_BUILD_TYPE})
ELSE (RBDL_STORE_VERSION)
SET (RBDL_BUILD_COMMIT "unknown")
SET (RBDL_BUILD_BRANCH "unknown")
SET (RBDL_BUILD_TYPE "unknown")
ENDIF (RBDL_STORE_VERSION)
CONFIGURE_FILE (
"${CMAKE_CURRENT_SOURCE_DIR}/include/rbdl/rbdl_config.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/include/rbdl/rbdl_config.h"
)
# Python wrapper
IF (RBDL_BUILD_PYTHON_WRAPPER)
add_subdirectory ( python )
ENDIF (RBDL_BUILD_PYTHON_WRAPPER)
# Installation
FILE ( GLOB headers
${CMAKE_CURRENT_SOURCE_DIR}/include/rbdl/*.h
${CMAKE_CURRENT_BINARY_DIR}/include/rbdl/rbdl_config.h
)
INSTALL ( FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rbdl )
# pkg-config
CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/share/rbdl.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/rbdl.pc @ONLY
)
INSTALL (
FILES ${CMAKE_CURRENT_BINARY_DIR}/rbdl.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
# Prepare share
if(WIN32 AND NOT CYGWIN AND NOT RBDL_VCPKG_BUILD)
set(CMAKE_SHARE_DIR cmake)
else()
set(CMAKE_SHARE_DIR lib/cmake/RBDL)
endif()
include(CMakePackageConfigHelpers)
configure_package_config_file(
share/RBDLConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/RBDLConfig.cmake
INSTALL_DESTINATION ${CMAKE_SHARE_DIR}
)
INSTALL (
FILES ${CMAKE_CURRENT_BINARY_DIR}/RBDLConfig.cmake
DESTINATION ${CMAKE_SHARE_DIR}
)
# Packaging
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Martin Felis <martin@fysx.org>")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "the Rigid Body Dynamics Library (RBDL)")
SET(CPACK_PACKAGE_VENDOR "Martin Felis")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_VERSION_MAJOR ${RBDL_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${RBDL_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${RBDL_VERSION_PATCH})
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CPACK_PACKAGE ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
SET(CPACK_PACKAGE_FILE_NAME "rbdl-${CMAKE_LIBRARY_ARCHITECTURE}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_PACKAGE_EXECUTABLES "rbdl_luamodel_util;RBDL Lua Model Utility")
INCLUDE(CPack)