1/30/2024 0 Comments Cmake message![]() The newer version has the improved protobuf_generate function in it, though at the time of this writing it is already lagging behind the upstream ProtobufConfig.cmake in other regards. There are a couple of options: Update cmake Never gets executed as gRPC has already found the outdated one. Unfortunately, this gets completely ignored by cmake,īecause gRPC tries to be helpful by finding all its dependencies for us, thus our find_package for protobuf With protobuf, over its own (outdated) FindProtobuf.cmake module. With the CONFIG option, we are explicitly requesting cmake to prefer the ProtobufConfig.cmake that comes This might come as a surprise, since we explicitly use find_package(protobuf CONFIG REQUIRED) to find the protobuf If your cmake version isn’t up-to-date, the protobuf_generate command might not yet support the -plugin option, The versions provided by cmake can lag behind (sometimes severely) the ones that come with the libraries and so, One installed by cmake, the other installed as Which is the script that provides the protobuf_generate command. So why is this happening? The reason is that there could be two versions of the protobuf cmake script installed, grpc_out: protoc-gen-grpc: Plugin failed with status code 1. Please specify a program using absolute path or make sure the program is available in your PATH system variable Protoc-gen-grpc: program not found or is not executable proto files are c++ files and create a library target with them as source files: CMake debugging First, lets look at ways to debug a CMakeLists or other CMake file. Compiling the proto files into a libraryįor most of the time, you can just pretend that the. In the following I will only focus on the CMakeLists.txt file in the proto/ directory. This also helps with keeping all the dependencies in one place. Since the protobuf/gRPC code is shared among the client and the server, I decided to put the code into a CMake library target and then link the client and server to that library. When you look at the example project, you will see that it is split into three parts: proto files to your CMake project to automate these steps. Actually you have to run protoc twice: Once to generate the C++ files for the protobuf serialization and another time with the gRPC plugin to generate the server/client code.ĭoing this manually is error-prone and should be avoided. proto files, you will have to run the protoc compiler to convert them to C++ code. These specify not only the format of the protobuf messages that get sent by gRPC, but also the services (calls) provided by the server.Įvery time you update the. When you build gRPC clients or servers, you will specify their API in. The full example is available in my github account: gRPC CMake example Why? Now that I found the time, I want to write a bit about how to use this in your project to automatically generate C++ code from your protobuf files. A while back, I contributed plugin/grpc support to the CMake package that comes with protobuf.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |