Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
161 lines (128 loc) · 4.07 KB
/
Copy pathCMakeLists.txt
File metadata and controls
161 lines (128 loc) · 4.07 KB
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
cmake_minimum_required(VERSION 3.20)
project(xbot2_interface LANGUAGES CXX VERSION 1.2.1)
option(XBOT2_IFC_BUILD_PINOCCHIO "Build Pinocchio implementation" ON)
option(XBOT2_IFC_BUILD_RBDL "Build RBDL implementation" OFF)
option(XBOT2_IFC_BUILD_ROS "Build ROS implementation" ON)
option(XBOT2_IFC_BUILD_ROS2 "Build ROS2 implementation" OFF)
option(XBOT2_IFC_BUILD_COLLISION "Build collision support (required hpp-fcl)" ON)
option(XBOT2_IFC_BUILD_TESTS "Build tests" OFF)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_RPATH $ORIGIN)
set(CMAKE_BUILD_RPATH "$ORIGIN;$ORIGIN/pinocchio;$ORIGIN/rbdl;$ORIGIN/ros")
set(Boost_USE_DEBUG_RUNTIME OFF) # hack: needed to avoid boost configuration errors
find_package(urdf REQUIRED)
find_package(urdfdom REQUIRED)
find_package(srdfdom REQUIRED)
find_package(Eigen3 REQUIRED)
include(GNUInstallDirs)
add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
# internal fmt
add_subdirectory(external/fmt-10.2.1 EXCLUDE_FROM_ALL)
add_library(xbot2_interface SHARED
src/state_interface.cpp
src/xbotinterface2.cpp
src/robotinterface2.cpp
src/chain.cpp
src/joint.cpp
src/types.cpp
src/utils.cpp
src/sensor.cpp
src/imu.cpp
src/gripper.cpp
src/force_torque.cpp
src/logger.cpp
)
add_library(xbot2_interface::xbot2_interface ALIAS xbot2_interface)
target_link_libraries(xbot2_interface
PRIVATE
fmt::fmt-header-only
PUBLIC
${urdf_LIBRARIES}
${srdfdom_LIBRARIES}
Eigen3::Eigen)
# on ros2, we need to use targets for linking
# otherwise we use variables
if(TARGET srdfdom::srdfdom)
target_link_libraries(xbot2_interface
PUBLIC
srdfdom::srdfdom
urdf::urdf)
else()
target_include_directories(xbot2_interface
SYSTEM PUBLIC
${srdfdom_INCLUDE_DIRS}
${urdf_INCLUDE_DIRS}
)
endif()
# if urdfdom 4.x is used, we need to switch to different
# code for printing urdfs
if(urdfdom_VERSION_MAJOR GREATER_EQUAL 4)
add_definitions(-DXBOT2IFC_URDFDOM_USES_TINIXML2)
endif()
if(urdfdom_VERSION VERSION_GREATER_EQUAL 5)
find_package(tinyxml2 REQUIRED)
target_sources(xbot2_interface PRIVATE src/urdf_export_compat.cpp)
target_link_libraries(xbot2_interface PRIVATE tinyxml2::tinyxml2)
target_compile_definitions(xbot2_interface PRIVATE XBOT2IFC_URDFDOM_NO_EXPORT)
if(urdfdom_VERSION VERSION_GREATER_EQUAL 5.1)
target_compile_definitions(xbot2_interface PRIVATE XBOT2IFC_URDFDOM_HAS_CAPSULE)
endif()
if(urdfdom_VERSION VERSION_GREATER_EQUAL 6)
target_compile_definitions(xbot2_interface PRIVATE XBOT2IFC_URDFDOM_HAS_EXTENDED_LIMITS)
endif()
endif()
target_compile_options(xbot2_interface
PUBLIC
PRIVATE
-fvisibility-inlines-hidden
-fvisibility=hidden)
target_compile_definitions(xbot2_interface
PUBLIC
PRIVATE
-DXBOT2IFC_DLL
-DXBOT2IFC_DLL_EXPORTS)
target_include_directories(xbot2_interface
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
)
target_include_directories(xbot2_interface
SYSTEM PUBLIC
${srdfdom_INCLUDE_DIRS}
)
set_target_properties(xbot2_interface PROPERTIES
SOVERSION ${xbot2_interface_VERSION_MAJOR}.${xbot2_interface_VERSION_MINOR})
install(
TARGETS xbot2_interface
EXPORT ${PROJECT_NAME}Targets
DESTINATION lib
)
install(DIRECTORY include/xbot2_interface
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xbot2_interface
)
if(${XBOT2_IFC_BUILD_PINOCCHIO})
add_subdirectory(pinocchio/)
endif()
if(${XBOT2_IFC_BUILD_RBDL})
add_subdirectory(rbdl/)
endif()
if(${XBOT2_IFC_BUILD_ROS})
add_subdirectory(ros/)
endif()
if(${XBOT2_IFC_BUILD_ROS2})
add_subdirectory(ros2/)
endif()
if(${XBOT2_IFC_BUILD_COLLISION})
add_subdirectory(src/collision/)
endif()
add_subdirectory(python)
add_subdirectory(examples)
if(${XBOT2_IFC_BUILD_TESTS})
enable_testing()
add_subdirectory(test)
endif()
include(cmake/ExportProject.cmake)
export_project()
include(cmake/GenerateDeb.cmake)