Robotics StackExchange | Archived questions

catkin build protobuf?

Hi folks,

how can I get catkin to build and deploy the results of protobuf's .proto files? What's the SOTA in this regard? I've tried

find_package(Protobuf REQUIRED)  
include_directories(${Protobuf_INCLUDE_DIRS})  

protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS protobuf/imu_data.proto)  
protobuf_generate_python(PROTO_PY protobuf/imu_data.proto)  

But that does nothing. It finds Protobuf but the bottom two commands basically do nothing. Not even throw an error.

Is this the recommended way?

Thank you!

Cheers, Hendrik

PS: I'm using python-catkin-tools, say, catkin build instead of catkin_make. In case that's some vital information...

Update 1:

I managed to make it build by adding the line

add_custom_target(imu_sys_proto ALL DEPENDS ${PROTO_PY})

to the CMakeLists.txt. This makes catkin (or rather cmake) build the Python bindings for my .proto file. But it does not install it.

Question extension 1

So I'll extend my question to: what do I need to add to the CMakeLists.txt in order for catkin to copy the resulting ...pb2.pyfile(s) to the correct folder (whichever that might be)?

Asked by Hendrik Wiese on 2019-06-20 08:12:05 UTC

Comments

This is not a Catkin question, but a CMake one.

How would you do this with pure CMake?

Asked by gvdhoorn on 2019-06-20 09:27:09 UTC

Probably exactly like in the example. But it still does not seem to work... maybe it's CMake related. I thought there might be some catkin specific CMake commands for that.

Asked by Hendrik Wiese on 2019-06-20 09:28:53 UTC

I'm not aware of any protobuf specific infrastructure in Catkin.

I'd first get things working in a regular CMake context.

Then integrate that into a Catkin based CMakeList.txt.

In my experience it should just work and there is nothing different between the two contexts (wrt protobuf at least).

Asked by gvdhoorn on 2019-06-20 09:35:24 UTC

I've extended the question to be a little more catkin specific.

Asked by Hendrik Wiese on 2019-06-20 09:46:30 UTC

Answers