-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathFRI_Client_SDK_Cpp.cmake
136 lines (109 loc) · 7.43 KB
/
FRI_Client_SDK_Cpp.cmake
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
# Sets up KUKA Sunrise FRI Cpp SDK with KUKA connectivity suite
# Variables
# FRI_Client_SDK_Cpp_zip_PATH - Path to folder containing FRI-Client-SDK_Cpp.zip
#
# Targets
# KukaFRIClient - KukaFRIClient Libraries you should link to to use Kuka FRI APIs
# nanopb - nanopb library used to communicate with FRI on Kuka controller
# friUdpConnection - UDP components for demo code (not needed by github.com/ahundt/grl)
#
# Author: Andrew Hundt <[email protected]>
# Sets up KUKA Sunrise FRI Cpp SDK with KUKA connectivity suite
message(STATUS "Looking for File Path to FRI-Client-SDK_Cpp.zip KUKA FRI C++ API zip file from sunrise connectivity suite v1.9")
set(FRI_Client_SDK_Cpp_zip_PATH "${CMAKE_SOURCE_DIR}/data/" CACHE FILEPATH "File Path to FRI-Client-SDK_Cpp.zip KUKA FRI C++ API zip file from sunrise connectivity suite v1.11")
find_path(FRI_Client_SDK_Cpp_zip_FILEPATH FRI-Client-SDK_Cpp.zip HINTS ${FRI_Client_SDK_Cpp_zip_PATH} ${CMAKE_PROJECT_DIR}/data/ ${CMAKE_CURRENT_PROJECT_DIR}/data/ )
if(EXISTS "${FRI_Client_SDK_Cpp_zip_FILEPATH}/FRI-Client-SDK_Cpp.zip")
message(STATUS "Found FRI-Client-SDK_Cpp.zip in ${FRI_Client_SDK_Cpp_zip_FILEPATH}/FRI-Client-SDK_Cpp.zip")
# directory where fri code will be extracted
set(FRI_DIR ${CMAKE_BINARY_DIR}/FRI_Client_SDK_Cpp)
set(FRI_SRC_DIR ${FRI_DIR}/src)
message(STATUS "extracting FRI C++ SDK... ${FRI_Client_SDK_Cpp_zip_FILEPATH}/FRI-Client-SDK_Cpp.zip to ${CMAKE_CURRENT_BINARY_DIR}")
file(REMOVE_RECURSE "${FRI_DIR}")
file(MAKE_DIRECTORY ${FRI_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${FRI_Client_SDK_Cpp_zip_FILEPATH}/FRI-Client-SDK_Cpp.zip
WORKING_DIRECTORY ${FRI_DIR}
RESULT_VARIABLE rv)
if(NOT rv EQUAL 0)
message(STATUS "extracting... FRI-Client-SDK_Cpp [error clean up]")
file(REMOVE_RECURSE "${FRI_DIR}")
message(FATAL_ERROR "error: extract of '${FRI_Client_SDK_Cpp_zip_FILEPATH}/FRI-Client-SDK_Cpp.zip' failed")
else()
# TODO: DONT HARDCODE DEFINITIONS, Use cmake CHECK_INCLUDE_FILE() to dynamically configure compile definitions
set(FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS
"-DHAVE_SOCKLEN_T;-DPB_SYSTEM_HEADER=\"pb_syshdr.h\";-DPB_FIELD_16BIT;-DHAVE_STDINT_H;-DHAVE_STDDEF_H;-DHAVE_STDBOOL_H;-DHAVE_STDLIB_H;-DHAVE_STRING_H"
)
if(Nanopb_FOUND)
basis_include_directories(${NANOPB_INCLUDE_DIRS})
else()
message(STATUS "Using internal nanopb, this should be ok. If you also use nanopb and there are linker errors set NANOPB_SRC_ROOT_FOLDER. Consult FRI-Client-SDK_Cpp/config/FindNanopb.cmake for details.")
basis_include_directories(nanopb-0.2.8)
basis_add_library(nanopb
${FRI_SRC_DIR}/nanopb-0.2.8/pb_encode.c
${FRI_SRC_DIR}/nanopb-0.2.8/pb_decode.c
)
target_compile_definitions(nanopb PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
target_include_directories(nanopb PUBLIC $<BUILD_INTERFACE:${FRI_SRC_DIR}/nanopb-0.2.8/>)
set(Nanopb_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIRS/nanopb-0.2.8})
set(Nanopb_LIBRARIES nanopb)
basis_install_directory(nanopb-0.2.8)
endif()
basis_include_directories(${FRI_DIR}/include ${FRI_SRC_DIR}/base ${FRI_SRC_DIR}/protobuf ${FRI_SRC_DIR}/protobuf_gen)
basis_install_directory(FRI_Client_SDK_Cpp/src/protobuf)
basis_install_directory(FRI_Client_SDK_Cpp/src/protobuf_gen)
basis_add_library(KukaFRIClient
${FRI_SRC_DIR}/protobuf/friCommandMessageEncoder.cpp
${FRI_SRC_DIR}/protobuf/friMonitoringMessageDecoder.cpp
${FRI_SRC_DIR}/protobuf/pb_frimessages_callbacks.c
${FRI_SRC_DIR}/protobuf_gen/FRIMessages.pb.c
${FRI_SRC_DIR}/client_lbr/friLBRClient.cpp
${FRI_SRC_DIR}/client_lbr/friLBRCommand.cpp
${FRI_SRC_DIR}/client_lbr/friLBRState.cpp
${FRI_SRC_DIR}/base/friClientApplication.cpp
${FRI_SRC_DIR}/client_trafo/friTransformationClient.cpp
#${FRI_SRC_DIR}/client_trafo/friTransformationContainer.cpp # uncomment for sunrise connectivity 1.9
)
target_compile_definitions(KukaFRIClient PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
target_include_directories(KukaFRIClient PUBLIC
$<BUILD_INTERFACE:${FRI_DIR}/include>
$<BUILD_INTERFACE:${FRI_SRC_DIR}/base>
$<BUILD_INTERFACE:${FRI_SRC_DIR}/client_lbr>
$<BUILD_INTERFACE:${FRI_SRC_DIR}/client_trafo>
$<BUILD_INTERFACE:${FRI_SRC_DIR}/connection>
$<BUILD_INTERFACE:${FRI_SRC_DIR}/protobuf>
$<BUILD_INTERFACE:${FRI_SRC_DIR}/protobuf_gen>
)
if(UNIX)
basis_add_library(friUdpConnection ${FRI_SRC_DIR}/connection/friUdpConnection.cpp)
target_compile_definitions(friUdpConnection PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
endif()
basis_target_link_libraries(KukaFRIClient nanopb)
# LBRJointSineOverlayApp
basis_add_executable(${FRI_DIR}/example/LBRJointSineOverlay/LBRJointSineOverlayApp.cpp
${FRI_DIR}/example/LBRJointSineOverlay/LBRJointSineOverlayClient.cpp)
basis_target_link_libraries(LBRJointSineOverlayApp KukaFRIClient nanopb friUdpConnection)
target_compile_definitions(LBRJointSineOverlayApp PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
# LBRTorqueSineOverlayApp
basis_add_executable(${FRI_DIR}/example/LBRTorqueSineOverlay/LBRTorqueSineOverlayApp.cpp
${FRI_DIR}/example/LBRTorqueSineOverlay/LBRTorqueSineOverlayClient.cpp)
basis_target_link_libraries(LBRTorqueSineOverlayApp KukaFRIClient nanopb friUdpConnection)
target_compile_definitions(LBRTorqueSineOverlayApp PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
# LBRWrenchSineOverlayApp
basis_add_executable(${FRI_DIR}/example/LBRWrenchSineOverlay/LBRWrenchSineOverlayApp.cpp
${FRI_DIR}/example/LBRWrenchSineOverlay/LBRWrenchSineOverlayClient.cpp)
basis_target_link_libraries(LBRWrenchSineOverlayApp KukaFRIClient nanopb friUdpConnection)
target_compile_definitions(LBRWrenchSineOverlayApp PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
# SimulatedTransformationProviderApp
basis_add_executable(${FRI_DIR}/example/SimulatedTransformationProvider/SimulatedTransformationProviderApp.cpp
${FRI_DIR}/example/SimulatedTransformationProvider/SimulatedTransformationProviderClient.cpp)
basis_target_link_libraries(SimulatedTransformationProviderApp KukaFRIClient nanopb friUdpConnection)
target_compile_definitions(SimulatedTransformationProviderApp PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
# TransformationProviderApp
basis_add_executable(${FRI_DIR}/example/TransformationProvider/TransformationProviderApp.cpp
${FRI_DIR}/example/TransformationProvider/TransformationProviderClient.cpp)
basis_target_link_libraries(TransformationProviderApp KukaFRIClient nanopb friUdpConnection)
target_compile_definitions(TransformationProviderApp PUBLIC ${FRI_Client_SDK_Cpp_COMPILE_DEFINITIONS})
endif()
set(FRI_Client_SDK_Cpp_FOUND TRUE PARENT_SCOPE)
else()
message(AUTHOR_WARNING "FRI-Client-SDK_Cpp.zip NOT_FOUND, skipping...")
endif()