如何使用cmake运行GRPC Python文件的原始protoc?
我有一个文件my.proto
,我想创建相应的my_pb2.py
和my_pb2_grpc.py
使用cmake。 (不幸的是,我无法使用其他构建系统)
通常,我使用grpcio-tools python模块的Protoc来做到这一点:
python3 -m grpc_tools.protoc -I. --grpc_python_out=. --python_out=. my.proto
cmake具有对Python Protobuf的一些支持,但对于我的用例,实现尚不清楚。
我的问题是:
- 如何在CMake中调用类似命令,
- 如何将生成的文件放在特定目的地中,
- 在运行Cmake(grpcio-tools/protobuf)之前,所需的依赖项是什么?
I have a file my.proto
and I want to create the corresponding my_pb2.py
and my_pb2_grpc.py
files using cmake. (Unfortunately, I cannot use other build system)
Normally, I use protoc from grpcio-tools python module to do so:
python3 -m grpc_tools.protoc -I. --grpc_python_out=. --python_out=. my.proto
cmake has some support for python protobuf, but implementing it is not clear for my use case.
My questions are:
- how to invoke a similar command in cmake
- how to put the generated file in a specific destination
- what are the required dependencies before running cmake (grpcio-tools/protobuf)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遵循@tsyvarev评论并进一步阅读CMAKE文档我得到以下
cmakelists.txt
content(位于my.proto
目录中)Following @Tsyvarev comment and further read of cmake doc I got the following
CMakeLists.txt
content (sits inmy.proto
directory)