-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
213 lines (176 loc) · 6.94 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
SET ( RBDL_VERSION_MAJOR 2 )
SET ( RBDL_VERSION_MINOR 6 )
SET ( RBDL_VERSION_PATCH 0 )
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
)
# 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()
# Find and use the system's Eigen3 library
FIND_PACKAGE (Eigen3 3.0.0)
IF (NOT EIGEN3_FOUND AND NOT RBDL_USE_SIMPLE_MATH)
MESSAGE (WARNING "Could not find Eigen3 on your system. Install it or use the slower SimpleMath library by enabling RBDL_USE_SIMPLE_MATH.")
ENDIF (NOT EIGEN3_FOUND AND NOT RBDL_USE_SIMPLE_MATH)
IF (EIGEN3_FOUND AND NOT RBDL_USE_SIMPLE_MATH)
INCLUDE_DIRECTORIES (${EIGEN3_INCLUDE_DIR})
ENDIF (EIGEN3_FOUND AND NOT RBDL_USE_SIMPLE_MATH)
# Options
SET (RBDL_BUILD_STATIC_DEFAULT OFF)
IF (MSVC)
SET (RBDL_BUILD_STATIC_DEFAULT ON)
ENDIF (MSVC)
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_USE_SIMPLE_MATH "Use slow math instead of the fast Eigen3 library (faster compilation)" 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)
# 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_BUILD_ADDON_LUAMODEL)
ADD_SUBDIRECTORY ( addons/luamodel )
ENDIF (RBDL_BUILD_ADDON_LUAMODEL)
IF(RBDL_BUILD_ADDON_MUSCLE)
SET(RBDL_BUILD_ADDON_GEOMETRY ON CACHE BOOL "Build the geometry library" FORCE)
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_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/Constraints.cc
src/Dynamics.cc
src/Logging.cc
src/Joint.cc
src/Model.cc
src/Kinematics.cc
)
IF (MSVC AND NOT RBDL_BUILD_STATIC)
MESSAGE (FATAL_ERROR, "Compiling RBDL as a DLL currently not supported. Please enable RBDL_BUILD_STATIC.")
ENDIF (MSVC AND NOT RBDL_BUILD_STATIC)
# Static / dynamic builds
IF (RBDL_BUILD_STATIC)
ADD_LIBRARY ( rbdl-static STATIC ${RBDL_SOURCES} )
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)
INSTALL (TARGETS rbdl-static
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
ELSE (RBDL_BUILD_STATIC)
ADD_LIBRARY ( rbdl SHARED ${RBDL_SOURCES} )
SET_TARGET_PROPERTIES ( rbdl PROPERTIES
VERSION ${RBDL_VERSION}
SOVERSION ${RBDL_SO_VERSION}
)
INSTALL (TARGETS rbdl
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
ENDIF (RBDL_BUILD_STATIC)
IF (RBDL_STORE_VERSION)
# Set versioning information that can be queried during runtime
EXEC_PROGRAM("hg" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "id -i"
OUTPUT_VARIABLE RBDL_BUILD_REVISION)
EXEC_PROGRAM("hg" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "branch"
OUTPUT_VARIABLE RBDL_BUILD_BRANCH)
SET (RBDL_BUILD_TYPE ${CMAKE_BUILD_TYPE})
ELSE (RBDL_STORE_VERSION)
SET (RBDL_BUILD_REVISION "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 )
# Setup of SimpleMath install settings
IF (RBDL_USE_SIMPLE_MATH)
INSTALL ( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/rbdl/SimpleMath"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rbdl
)
ENDIF (RBDL_USE_SIMPLE_MATH)
# pkg-config
CONFIGURE_FILE (
${CMAKE_CURRENT_SOURCE_DIR}/rbdl.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/rbdl.pc @ONLY
)
INSTALL (
FILES ${CMAKE_CURRENT_BINARY_DIR}/rbdl.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
# Packaging
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Martin Felis <[email protected]>")
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)