大家好,我是最近发现羊肉泡馍还挺好吃的小鱼,今天分享下ROS2工程实践的另外一个小技巧
当你的工程中有很多的消息接口
像小鱼这个工程
差不多三十个接口
一个个在 CMakeLists.txt 中写显然很慢,偶尔有可能会漏
怎么办?
分享一下小鱼的CMakeLists.txt
find_package(rosidl_default_generators REQUIRED)
# Automatically discover and add all .msg files in the 'msg' folder
file(GLOB_RECURSE msg_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/msg *.msg)
list(TRANSFORM msg_files PREPEND "msg/")
# Automatically discover and add all .srv files in the 'srv' folder
file(GLOB_RECURSE srv_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/srv *.srv)
list(TRANSFORM srv_files PREPEND "srv/")
rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
${srv_files}
)