The CMake FindProtobuf module FindProtobuf provide this function with the PROTOBUF_GENERATE_CPP function.
You can transfer multiple .proto files in one call, for example
file(GLOB ProtoFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.proto") PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
Note that even if the CMakeLists.txt file that calls find_package(Protobuf) may be at the top, the CMakeLists.txt file that calls this function must be in the same directory as the .proto files.
Fraser
source share