CMake and Protoc with imports

25 views
Skip to first unread message

Christopher Pisz

unread,
Nov 2, 2020, 4:04:15 PM11/2/20
to grpc.io
The gRPC examples show use of one proto file and one output file. However, I was supplied a protofile that imports another, which in turn imports several from another directory.

Is the protoc supposed to produce headers and source files from the imported files? Or do you need to run the compiler on every single individual proto file?

Does anyone have an example cmake, where the proto files import?

Christopher Pisz

unread,
Nov 2, 2020, 5:04:28 PM11/2/20
to grpc.io

I've also tried:

# Generated Proto files
file(GLOB_RECURSE proto_files "${CMAKE_CURRENT_SOURCE_DIR}/*.proto")
PROTOBUF_GENERATE_CPP(proto_srcs proto_hdrs ${proto_files} PLUGIN protoc-gen-grpc=${GRPC_PLUGIN})
add_custom_target(proto_dep DEPENDS ${proto_srcs} ${proto_hdrs})
message(STATUS "Generated source files are ${proto_srcs}")

However, I do not see any .grpc.pb.cc files or know how to get the list of them to add to compilation of my library with add_library. If I understand the docs correctly, I have to compile the *.pb.cc files as well as the *.grpc.pb.cc files.

Aditya Vignesh

unread,
Apr 29, 2021, 5:45:07 AMApr 29
to grpc.io
Hi,

I am having the same problem. Did you manage to solve this problem?

nitish bhardwaj

unread,
Apr 29, 2021, 10:04:52 PMApr 29
to grpc.io
Hi, 

I would suggest using a building tool for your project which would take care of generating your code every time you build your project.

Reply all
Reply to author
Forward
0 new messages