pythoncmakeprotocol-buffers

Compile protobuf to python, cmake command


I have some proto definitions that I compile to cpp.
To generate the corresponding make target I use cmake like this:
protobuf_generate_cpp(CPP_SOURCES PROTO_HEADERS ${PROTO_FILES})
And I use the CPP_SOURCES to build my lib.

Now I need to compile the same proto files for python also and I added this:
protobuf_generate_python(PY_SOURCES ${PROTO_FILES})
This alone has no effect, and I am not sure what I should / can add more in order to have some make target that will trigger also the protoc for python


Solution

  • You already answered your question, but here is a complete answer.

    The protobuf_generate_python() function add's a custom command. To trigger the command you need a define a target. So add a add_custom_target() like this

    add_custom_target(myTarget ALL 
                      DEPENDS ${PY_SOURCES})