forked from boston-dynamics/spot-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
333 lines (305 loc) · 13.8 KB
/
Copy pathCMakeLists.txt
File metadata and controls
333 lines (305 loc) · 13.8 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
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
325
326
327
328
329
330
331
332
333
# Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved.
#
# Downloading, reproducing, distributing or otherwise using the SDK Software
# is subject to the terms and conditions of the Boston Dynamics Software
# Development Kit License (20191101-BDSDK-SL).
# This file is autogenerated.
cmake_minimum_required (VERSION 3.10.2)
project (bosdyn VERSION 5.1.0)
# Dependencies:
find_package(Protobuf REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GRPC REQUIRED grpc)
pkg_check_modules(GRPCPP REQUIRED grpc++)
find_program(GRPC_CPP_PLUGIN_LOCATION grpc_cpp_plugin REQUIRED)
find_package(CLI11 REQUIRED)
find_package(Threads REQUIRED)
include_directories(SYSTEM $<TARGET_PROPERTY:CLI11::CLI11,INTERFACE_INCLUDE_DIRECTORIES>)
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
# Command-line arguments:
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(BUILD_CHOREOGRAPHY_LIBS "Boolean to control whether choreography proto libraries are built" ON)
option(BUILD_EXAMPLES "Boolean to control whether examples are built" OFF)
IF (NOT UNIX)
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Build using shared libraries" FORCE)
ENDIF (NOT UNIX)
include(GNUInstallDirs)
### API protos LIBRARY ###
get_filename_component(API_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../protos/ ABSOLUTE)
file(GLOB_RECURSE bosdyn_protos_files CONFIGURE_DEPENDS "${API_protos_PATH}/*.proto")
set(protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/protos)
file(MAKE_DIRECTORY ${protos_OUTPUT_DIR})
if (bosdyn_protos_files)
add_library(bosdyn_api_obj OBJECT ${bosdyn_protos_files})
set_property(TARGET bosdyn_api_obj PROPERTY POSITION_INDEPENDENT_CODE 1)
target_link_libraries(bosdyn_api_obj PUBLIC protobuf::libprotobuf ${GRPC_LINK_LIBRARIES} ${GRPCPP_LINK_LIBRARIES})
target_include_directories(bosdyn_api_obj PUBLIC
${GRPC_INCLUDE_DIRS} ${GRPCPP_INCLUDE_DIRS}
$<BUILD_INTERFACE:${protos_OUTPUT_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
protobuf_generate(TARGET bosdyn_api_obj LANGUAGE cpp
IMPORT_DIRS ${API_protos_PATH}
PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
)
protobuf_generate(TARGET bosdyn_api_obj
LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION}"
IMPORT_DIRS ${API_protos_PATH}
PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
)
#set install params
install(
TARGETS bosdyn_api_obj
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if (BUILD_SHARED_LIBS)
add_library(bosdyn_api SHARED $<TARGET_OBJECTS:bosdyn_api_obj>)
target_link_libraries(bosdyn_api INTERFACE bosdyn_api_obj)
install(
TARGETS bosdyn_api
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endif()
add_library(bosdyn_api_static STATIC $<TARGET_OBJECTS:bosdyn_api_obj>)
target_link_libraries(bosdyn_api_static INTERFACE bosdyn_api_obj)
install(
TARGETS bosdyn_api_static
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install the gnerated protobuf and grpc header files
install(DIRECTORY ${protos_OUTPUT_DIR}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
endif()
if (BUILD_CHOREOGRAPHY_LIBS)
### API choreography_protos LIBRARY ###
get_filename_component(API_choreography_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../choreography_protos/ ABSOLUTE)
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH}/*.proto")
set(choreography_protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/choreography_protos)
file(MAKE_DIRECTORY ${choreography_protos_OUTPUT_DIR})
file(GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH}/*.proto")
if (bosdyn_choreography_protos_files)
add_library(bosdyn_choreography_protos_obj OBJECT ${bosdyn_choreography_protos_files})
set_property(TARGET bosdyn_choreography_protos_obj PROPERTY POSITION_INDEPENDENT_CODE 1)
target_link_libraries(bosdyn_choreography_protos_obj PUBLIC bosdyn_api)
target_include_directories(bosdyn_choreography_protos_obj PUBLIC
$<BUILD_INTERFACE:${choreography_protos_OUTPUT_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
protobuf_generate(TARGET bosdyn_choreography_protos_obj LANGUAGE cpp
IMPORT_DIRS ${API_choreography_protos_PATH}
PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR})
protobuf_generate(TARGET bosdyn_choreography_protos_obj
LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION}"
IMPORT_DIRS ${API_choreography_protos_PATH}
PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR}
)
#set install params
install(
TARGETS bosdyn_choreography_protos_obj
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if (BUILD_SHARED_LIBS)
add_library(bosdyn_choreography_protos SHARED $<TARGET_OBJECTS:bosdyn_choreography_protos_obj>)
target_link_libraries(bosdyn_choreography_protos INTERFACE bosdyn_choreography_protos_obj)
install(
TARGETS bosdyn_choreography_protos
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endif()
add_library(bosdyn_choreography_protos_static STATIC $<TARGET_OBJECTS:bosdyn_choreography_protos_obj>)
target_link_libraries(bosdyn_choreography_protos_static INTERFACE bosdyn_choreography_protos_obj)
install(
TARGETS bosdyn_choreography_protos_static
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install the gnerated protobuf and grpc header files
install(DIRECTORY ${choreography_protos_OUTPUT_DIR}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
endif()
endif()
### CLIENT LIBRARY ###
file(GLOB_RECURSE bosdyn_client_SRC CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/bosdyn/*")
if (BUILD_SHARED_LIBS)
add_library (bosdyn_client SHARED ${bosdyn_client_SRC})
set_property(TARGET bosdyn_client PROPERTY POSITION_INDEPENDENT_CODE 1)
target_compile_features(bosdyn_client PUBLIC cxx_std_17)
target_link_libraries(bosdyn_client PUBLIC bosdyn_api Eigen3::Eigen)
target_include_directories(bosdyn_client PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(
TARGETS bosdyn_client
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
endif()
add_library (bosdyn_client_static STATIC ${bosdyn_client_SRC})
set_property(TARGET bosdyn_client_static PROPERTY POSITION_INDEPENDENT_CODE 1)
target_compile_features(bosdyn_client_static PUBLIC cxx_std_17)
target_link_libraries(bosdyn_client_static PUBLIC bosdyn_api_static Eigen3::Eigen)
target_include_directories(bosdyn_client_static PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(
TARGETS bosdyn_client_static
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
#extract the header files from the src dir and install them
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bosdyn
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
include(CMakePackageConfigHelpers)
### EXAMPLE EXECUTABLES ###
if(BUILD_EXAMPLES)
link_directories(
${PROTOBUF_LIB_DIR}
)
add_executable(arm_grasp_carry_overrides ${CMAKE_CURRENT_SOURCE_DIR}/examples/arm_grasp_carry_overrides/arm_grasp_carry_overrides.cpp)
target_compile_features(arm_grasp_carry_overrides PUBLIC cxx_std_17)
target_include_directories(arm_grasp_carry_overrides PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
)
target_link_libraries(arm_grasp_carry_overrides PUBLIC bosdyn_client_static)
install(TARGETS arm_grasp_carry_overrides DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(arm_manipulation_api_walk_to ${CMAKE_CURRENT_SOURCE_DIR}/examples/arm_manipulation_api_walk_to/arm_manipulation_api_walk_to.cpp)
target_compile_features(arm_manipulation_api_walk_to PUBLIC cxx_std_17)
target_include_directories(arm_manipulation_api_walk_to PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
$<TARGET_PROPERTY:CLI11::CLI11,INTERFACE_INCLUDE_DIRECTORIES>
)
target_link_libraries(arm_manipulation_api_walk_to PUBLIC bosdyn_client_static)
install(TARGETS arm_manipulation_api_walk_to DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(basic_robot_command ${CMAKE_CURRENT_SOURCE_DIR}/examples/basic_robot_command/basic_robot_command.cpp)
target_compile_features(basic_robot_command PUBLIC cxx_std_17)
target_include_directories(basic_robot_command PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
)
target_link_libraries(basic_robot_command PUBLIC bosdyn_client_static)
install(TARGETS basic_robot_command DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(get_image ${CMAKE_CURRENT_SOURCE_DIR}/examples/get_image/get_image.cpp)
target_compile_features(get_image PUBLIC cxx_std_17)
target_include_directories(get_image PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
)
target_link_libraries(get_image PUBLIC bosdyn_client_static)
install(TARGETS get_image DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(hello_spot ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello_spot/hello_spot.cpp)
target_compile_features(hello_spot PUBLIC cxx_std_17)
target_include_directories(hello_spot PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
)
target_link_libraries(hello_spot PUBLIC bosdyn_client_static)
install(TARGETS hello_spot DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(inverse_kinematics_reachability ${CMAKE_CURRENT_SOURCE_DIR}/examples/inverse_kinematics_reachability/inverse_kinematics_reachability.cpp)
target_compile_features(inverse_kinematics_reachability PUBLIC cxx_std_17)
target_include_directories(inverse_kinematics_reachability PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
)
target_link_libraries(inverse_kinematics_reachability PUBLIC bosdyn_client_static)
install(TARGETS inverse_kinematics_reachability DESTINATION ${CMAKE_INSTALL_BINDIR})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/joint_control)
add_executable(spot_cam ${CMAKE_CURRENT_SOURCE_DIR}/examples/spot_cam/ptz_example.cpp)
target_compile_features(spot_cam PUBLIC cxx_std_17)
target_include_directories(spot_cam PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROTOBUF_INCLUDE_DIR}
)
target_link_libraries(spot_cam PUBLIC bosdyn_client_static)
install(TARGETS spot_cam DESTINATION ${CMAKE_INSTALL_BINDIR})
# Save a version file in the project's binary directory
set(VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
write_basic_package_version_file("${VERSION_FILE}"
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
endif()
# This defines the instructions to generate a relocatable targets file at install time
set(PROJECT_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(EXPORTS_FILE "UseInstall${PROJECT_NAME}.cmake")
install(
EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
FILE ${EXPORTS_FILE}
DESTINATION ${PROJECT_CONFIG_PATH}
)
# Define Variables needed by package config file
set(PACKAGE_INSTALL_PREFIX /opt/spot-cpp-sdk)
#this generates a relocatable config file for install, but it gets invoked at build time,
#so the output has to be saved in a way that will not conflict with the export config
set(CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}InstallConfig.cmake")
configure_package_config_file( "cmake/ProjectConfig.cmake.in"
${CONFIG_FILE}
INSTALL_DESTINATION ${PROJECT_CONFIG_PATH}
)
#and because the config is a file in the build dir, it has to be installed explicitly
install(
FILES "${CONFIG_FILE}"
RENAME ${PROJECT_NAME}Config.cmake
DESTINATION "${PROJECT_CONFIG_PATH}"
)
set(EXPORTS_FILE "UseExport${PROJECT_NAME}.cmake")
# Provide a targets script for the build dir
export(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
FILE ${EXPORTS_FILE}
)
set(MAKE_PLUGIN_FILE "cmake/make_plugin.cmake")
set(MAKE_APP_FILE "cmake/make_standard_app.cmake")
#export requires a config.cmake to play well with find_package, so that gets made here
configure_package_config_file( "cmake/ProjectConfig.cmake.in"
${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}
)
# Stick build location in the central CMake user package registry, so that
# it may be easily found.
message(STATUS "Location of this build will be exported. Set ENABLE_EXPORT to OFF if you do not want this and delete ~/.cmake/projects/${PROJECT_NAME} ")
export(PACKAGE ${PROJECT_NAME})
if (UNIX)
# Packaging logic
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "spot-cpp-sdk")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libcli11-dev (>=2.1.2), libgrpc++-dev (>=1.30.2), libprotobuf-dev (>=3.12.4)") # not picked up by shlibdeps, thus listed explicitly
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Boston Dynamics SDK Publisher <bd-sdk-publisher@bostondynamics.com>")
set(CPACK_PACKAGE_VENDOR "Boston Dynamics")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Boston Dynamics Spot C++ SDK")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGING_INSTALL_PREFIX "${PACKAGE_INSTALL_PREFIX}")
include(CPack)
endif()