@@ -10,12 +10,16 @@ cmake_minimum_required (VERSION 3.10.2)
1010project (bosdyn VERSION 5.1.1)
1111
1212# Dependencies:
13- find_package (protobuf REQUIRED )
13+ find_package (Protobuf REQUIRED )
1414find_package (Eigen3 REQUIRED )
15- find_package (gRPC REQUIRED )
15+
16+ find_package (PkgConfig REQUIRED )
17+ pkg_check_modules (GRPC REQUIRED grpc )
18+ pkg_check_modules (GRPCPP REQUIRED grpc++ )
19+ find_program (GRPC_CPP_PLUGIN_LOCATION grpc_cpp_plugin REQUIRED )
1620find_package (CLI11 REQUIRED )
1721find_package (Threads REQUIRED )
18- get_target_property (grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)
22+
1923include_directories (SYSTEM $<TARGET_PROPERTY :CLI11 ::CLI11 ,INTERFACE_INCLUDE_DIRECTORIES >)
2024
2125set (CMAKE_EXPORT_COMPILE_COMMANDS true )
@@ -24,37 +28,35 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS true)
2428set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE )
2529option (BUILD_SHARED_LIBS "Build using shared libraries" ON )
2630option (BUILD_CHOREOGRAPHY_LIBS "Boolean to control whether choreography proto libraries are built" ON )
31+ option (BUILD_EXAMPLES "Boolean to control whether examples are built" OFF )
2732
2833IF (NOT UNIX )
2934 SET (BUILD_SHARED_LIBS OFF CACHE BOOL "Build using shared libraries" FORCE )
3035ENDIF (NOT UNIX )
3136
3237include (GNUInstallDirs )
3338
34-
3539### API protos LIBRARY ###
36- set (API_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR } /build/protos/)
37- # Copy protos folders to build folder so they are in a subdirectory from the cpp folder (necessary for the proto cpp files generation).
38- file (COPY ${CMAKE_CURRENT_SOURCE_DIR } /../protos/ DESTINATION ${API_protos_PATH} )
40+ get_filename_component (API_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR } /../protos/ ABSOLUTE )
41+ file (GLOB_RECURSE bosdyn_protos_files CONFIGURE_DEPENDS "${API_protos_PATH} /*.proto" )
3942set (protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR } /protos)
4043file (MAKE_DIRECTORY ${protos_OUTPUT_DIR} )
41- file (GLOB_RECURSE bosdyn_protos_files CONFIGURE_DEPENDS
42- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR } "${API_protos_PATH} /*.proto" )
43-
4444if (bosdyn_protos_files)
4545 add_library (bosdyn_api_obj OBJECT ${bosdyn_protos_files} )
4646 set_property (TARGET bosdyn_api_obj PROPERTY POSITION_INDEPENDENT_CODE 1)
47- target_link_libraries (bosdyn_api_obj PUBLIC protobuf::libprotobuf gRPC::grpc gRPC::grpc++ )
47+ target_link_libraries (bosdyn_api_obj PUBLIC protobuf::libprotobuf ${GRPC_LINK_LIBRARIES} ${GRPCPP_LINK_LIBRARIES} )
4848 target_include_directories (bosdyn_api_obj PUBLIC
49+ ${GRPC_INCLUDE_DIRS} ${GRPCPP_INCLUDE_DIRS}
4950 $<BUILD_INTERFACE :${protos_OUTPUT_DIR} >
5051 $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >
5152 )
5253 protobuf_generate (TARGET bosdyn_api_obj LANGUAGE cpp
53- IMPORT_DIRS ${API_protos_PATH}
54- PROTOC_OUT_DIR ${protos_OUTPUT_DIR} )
54+ IMPORT_DIRS ${API_protos_PATH}
55+ PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
56+ )
5557 protobuf_generate (TARGET bosdyn_api_obj
5658 LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
57- PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location } "
59+ PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION } "
5860 IMPORT_DIRS ${API_protos_PATH}
5961 PROTOC_OUT_DIR ${protos_OUTPUT_DIR}
6062 )
@@ -93,13 +95,11 @@ endif()
9395if (BUILD_CHOREOGRAPHY_LIBS)
9496
9597### API choreography_protos LIBRARY ###
96- set (API_choreography_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR } /build/choreography_protos/)
97- # Copy choreography_protos folders to build folder so they are in a subdirectory from the cpp folder (necessary for the proto cpp files generation).
98- file (COPY ${CMAKE_CURRENT_SOURCE_DIR } /../choreography_protos/ DESTINATION ${API_choreography_protos_PATH} )
98+ get_filename_component (API_choreography_protos_PATH ${CMAKE_CURRENT_SOURCE_DIR } /../choreography_protos/ ABSOLUTE )
99+ file (GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH} /*.proto" )
99100set (choreography_protos_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR } /choreography_protos)
100101file (MAKE_DIRECTORY ${choreography_protos_OUTPUT_DIR} )
101- file (GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS
102- RELATIVE ${CMAKE_CURRENT_SOURCE_DIR } "${API_choreography_protos_PATH} /*.proto" )
102+ file (GLOB_RECURSE bosdyn_choreography_protos_files CONFIGURE_DEPENDS "${API_choreography_protos_PATH} /*.proto" )
103103
104104if (bosdyn_choreography_protos_files)
105105 add_library (bosdyn_choreography_protos_obj OBJECT ${bosdyn_choreography_protos_files} )
@@ -114,7 +114,7 @@ if (bosdyn_choreography_protos_files)
114114 PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR} )
115115 protobuf_generate (TARGET bosdyn_choreography_protos_obj
116116 LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc
117- PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location } "
117+ PLUGIN "protoc-gen-grpc=${GRPC_CPP_PLUGIN_LOCATION } "
118118 IMPORT_DIRS ${API_choreography_protos_PATH}
119119 PROTOC_OUT_DIR ${choreography_protos_OUTPUT_DIR}
120120 )
@@ -193,7 +193,11 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bosdyn
193193)
194194
195195
196+ include (CMakePackageConfigHelpers )
197+
196198### EXAMPLE EXECUTABLES ###
199+ if (BUILD_EXAMPLES)
200+
197201link_directories (
198202 ${PROTOBUF_LIB_DIR}
199203)
@@ -210,6 +214,7 @@ target_compile_features(arm_manipulation_api_walk_to PUBLIC cxx_std_17)
210214target_include_directories (arm_manipulation_api_walk_to PUBLIC
211215 ${CMAKE_CURRENT_SOURCE_DIR }
212216 ${PROTOBUF_INCLUDE_DIR}
217+ $<TARGET_PROPERTY :CLI11 ::CLI11 ,INTERFACE_INCLUDE_DIRECTORIES >
213218)
214219target_link_libraries (arm_manipulation_api_walk_to PUBLIC bosdyn_client_static )
215220install (TARGETS arm_manipulation_api_walk_to DESTINATION ${CMAKE_INSTALL_BINDIR} )
@@ -255,12 +260,12 @@ target_include_directories(spot_cam PUBLIC
255260target_link_libraries (spot_cam PUBLIC bosdyn_client_static )
256261install (TARGETS spot_cam DESTINATION ${CMAKE_INSTALL_BINDIR} )
257262# Save a version file in the project's binary directory
258- include (CMakePackageConfigHelpers )
259263set (VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR } /${PROJECT_NAME } ConfigVersion.cmake" )
260264write_basic_package_version_file ("${VERSION_FILE} "
261265 VERSION ${PACKAGE_VERSION}
262266 COMPATIBILITY AnyNewerVersion
263267)
268+ endif ()
264269
265270# This defines the instructions to generate a relocatable targets file at install time
266271set (PROJECT_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR} /cmake/${PROJECT_NAME } " )
@@ -274,7 +279,6 @@ install(
274279
275280# Define Variables needed by package config file
276281set (PACKAGE_INSTALL_PREFIX /opt/spot-cpp-sdk)
277- set (DEP_INSTALL_PATH ${PACKAGE_INSTALL_PREFIX} /external)
278282
279283#this generates a relocatable config file for install, but it gets invoked at build time,
280284#so the output has to be saved in a way that will not conflict with the export config
@@ -323,6 +327,5 @@ if (UNIX)
323327 set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR } /../LICENSE" )
324328 set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR } /README.md" )
325329 set (CPACK_PACKAGING_INSTALL_PREFIX "${PACKAGE_INSTALL_PREFIX} " )
326- set (CPACK_INSTALLED_DIRECTORIES "${VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /;${DEP_INSTALL_PATH} /" )
327330 include (CPack )
328331endif ()
0 commit comments