-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
179 lines (112 loc) · 5.46 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
# Set cmake minimum version
cmake_minimum_required(VERSION 3.27)
# Set project name
project(GodotSimulation)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/godot_proj/bin/gen)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/godot_proj/bin/gen)
find_package(protobuf REQUIRED)
# set(gRPC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/build) find_package(Threads
# REQUIRED)
find_package(gRPC REQUIRED)
#Print gRPC_INCLUDE_DIRS
message(STATUS "*******************gRPC_INCLUDE_DIRS : " ${gRPC_INCLUDE_DIRS})
find_package(Boost COMPONENTS filesystem REQUIRED)
# Get ros libraries through glob on /opt/ros/noetic/lib
file(GLOB_RECURSE ros_libs "/opt/ros/noetic/lib/*.a" "/opt/ros/noetic/lib/*.so")
message(STATUS "************ ros_libs : ${ros_libs}")
set(ros_include_base /opt/ros/noetic/include)
file(
GLOB ros_include_path
LIST_DIRECTORIES true
"${ros_include_base}" "${ros_include_base}/*")
message(STATUS "*******************ros_include_path : " ${ros_include_path})
# Get godot-cpp dependency
# Get ros1 node executable source files
set(ros1_node_src_file src/ros1_nodes/ros1_pub_node.cpp)
file(GLOB grpc_interface_src src/grpc_interface/gen_protoc/*.cpp
src/grpc_interface/gen_protoc/*.cc)
# Pring grpc_interface_src
message(
STATUS "\n********\ngrpc_interface_src: ${grpc_interface_src} \n ********")
# Get godot-cpp target
add_subdirectory(deps/godot-cpp)
##### Set target for ros 1 publisher node
add_executable(ros1_pub_node ${ros1_node_src_file} ${grpc_interface_src})
target_include_directories(ros1_pub_node PRIVATE ${CMAKE_SOURCE_DIR}/src
/opt/ros/noetic/include/
$<$<CONFIG:Debug>:${gRPC_INCLUDE_DIRS}>
)
target_link_libraries(ros1_pub_node PRIVATE ${ros_libs} gRPC::grpc++ )
######
# #### Target join velocity node conroller
# file(GLOB grpc_gen_joint_vel_src
# ${CMAKE_SOURCE_DIR}/src/grpc_interface/gen_protoc/joint_vel*.cc
# ${CMAKE_SOURCE_DIR}/src/grpc_interface/gen_protoc/commonMessages*.cc
# )
# add_executable(ros1_ros_control_joint_vel
# src/ros1_nodes/ros1_ros_control_joint_vel.cpp
# ${grpc_gen_joint_vel_src}
# )
# target_include_directories(ros1_ros_control_joint_vel PRIVATE ${CMAKE_SOURCE_DIR}/src
# /opt/ros/noetic/include/
# $<$<CONFIG:Debug>:${gRPC_INCLUDE_DIRS}>
# )
# target_link_libraries(ros1_ros_control_joint_vel PRIVATE ${ros_libs} gRPC::grpc++)
# ######
# Add ros_manager library
add_library(ros_manager SHARED src/ros_manager/ros_manager.cpp)
# Get GDExtension src files
file(
GLOB_RECURSE
gd_extension_src
"src/godot_register_types/*.cpp"
"src/grpc_interface/*.cpp"
"src/grpc_interface/*.cc"
"src/ros_interface/*.cpp"
"src/virtual_sensors/*.cpp"
"src/ros_gui/*.cpp"
)
# Pring gd_extension_src message(STATUS "\n********\ngd_extension_src:
# ${gd_extension_src} \n ********")
add_library(godot_ros_extension SHARED ${gd_extension_src})
target_link_libraries(godot_ros_extension PRIVATE gRPC::grpc++ godot::cpp
Boost::filesystem
ros_manager
)
target_include_directories(godot_ros_extension PRIVATE ${CMAKE_SOURCE_DIR}/src
# /opt/ros/noetic/include/
$<$<CONFIG:Debug>:${gRPC_INCLUDE_DIRS}>
)
##### Target shared library to manage ROS1
add_library(ros1_system_manager SHARED "src/ros_interface/ros1/ros1_system_manager/ros1_system_manager.cpp")
target_include_directories(ros1_system_manager PRIVATE ${CMAKE_SOURCE_DIR}/src
/opt/ros/noetic/include/
$<$<CONFIG:Debug>:${gRPC_INCLUDE_DIRS}>
)
target_link_libraries(ros1_system_manager PRIVATE ${ros_libs} gRPC::grpc++)
#####
# Create custom target to run custom command before build
add_custom_target(compile_gRPC)
# Set custom command to compile protoc files
add_custom_command(
TARGET compile_gRPC
PRE_BUILD
WORKING_DIRECTORY $<TARGET_FILE_DIR:gRPC::grpc_cpp_plugin>
#Command to remove old files
COMMAND rm -rf ${CMAKE_SOURCE_DIR}/src/grpc_interface/gen_protoc/*
COMMAND
protobuf::protoc -I=${CMAKE_SOURCE_DIR}/src/grpc_interface/proto
--cpp_out=${CMAKE_SOURCE_DIR}/src/grpc_interface/gen_protoc
--grpc_out=${CMAKE_SOURCE_DIR}/src/grpc_interface/gen_protoc
--plugin=protoc-gen-grpc=$<TARGET_FILE_NAME:gRPC::grpc_cpp_plugin>
${CMAKE_SOURCE_DIR}/src/grpc_interface/proto/*.proto
COMMENT "Generating gRPC files")
add_dependencies(godot_ros_extension compile_gRPC)
add_dependencies(ros1_pub_node compile_gRPC)
add_dependencies(ros1_system_manager compile_gRPC)
# add_dependencies(ros1_ros_control_joint_vel compile_gRPC)
# add_custom_target(build_all DEPENDS ros1_pub_node godot_ros_extension)
# Add test project
add_executable(test_main test_main.cpp)
target_link_libraries(test_main gRPC::grpc++ ${ros_libs})
add_dependencies(test_main compile_gRPC)