catkin build protobuf?

asked 2019-06-20 08:12:05 -0500

Hendrik Wiese gravatar image

updated 2019-06-20 09:46:06 -0500

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)?

edit retag flag offensive close merge delete

Comments

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

How would you do this with pure CMake?

gvdhoorn gravatar imagegvdhoorn ( 2019-06-20 09:27:09 -0500 )edit

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.

Hendrik Wiese gravatar imageHendrik Wiese ( 2019-06-20 09:28:53 -0500 )edit

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).

gvdhoorn gravatar imagegvdhoorn ( 2019-06-20 09:35:24 -0500 )edit

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

Hendrik Wiese gravatar imageHendrik Wiese ( 2019-06-20 09:46:30 -0500 )edit