角色在cmake和make中逃脱不同
背景
我使用CMAKE 3.18有一个C ++项目,并且效果很好。该项目取决于Protobuf 3.17。由于某些原因,我想将Protobuf 3.17降低至3.5.2。我只是修改了我想在findprotobuf.cmake
中使用的Protobuf版本:
FetchContent_Declare(
protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
GIT_TAG b5fbb742af122b565925987e65c08957739976a7 #3.5.2
)
然后我得到了编译错误:
ir/CMakeFiles/lib_ir_proto.dir/build.make:79: *** target pattern contains no `%'. Stop.
我打开此文件,然后在lib_ir_ir_proto.dir/build.make.make < /code>:
ir/proto/data_type.pb.cc: ir/protobuf::protoc
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
似乎使得无法弄清楚::
。我将build.make
手动更改,并在其他地方打破了protobuf :: protoc
。有很多地方使用它,所以我不能一个一个一个更改它。
# mannualy change
ir/proto/data_type.pb.cc: ir/protobuf\:\:protoc
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
Protobuf :: Protoc
是由Protobuf官方编译CMakelist产生的CMAKE目标,我在findprotobuf.cmake.cmake.cmake.cmake.cmake.cmake.cmake.cmake
以这种方式使用:
set(PROTOC_EXE protobuf::protoc)
然后使用该编译器来编译原始文件。
我试图在cmake中逃脱:
set(PROTOC_EXE protobuf\\:\\:protoc)
但是仍然使用lib_ir_proto.dir/build.make
的相同行遇到
ir/proto/data_type.pb.cc: ir/protobuf/:/:protoc
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
错误通缉。有人有一些建议吗?
PS: 使用更高的Protobuf,一切都很好。生成的制作文件:
ir/proto/data_type.pb.cc: _deps/protobuf-build/protoc-3.17.0.0
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
找到右ptoroc
。
Background
I have a C++ project using CMAKE 3.18, and it works well. This project depends on protobuf 3.17 by source. For some reasons, I want to degrade the protobuf 3.17 to 3.5.2. I just modify the version of protobuf I want to use in FindProtoBuf.cmake
:
FetchContent_Declare(
protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
GIT_TAG b5fbb742af122b565925987e65c08957739976a7 #3.5.2
)
Then I got compiling error:
ir/CMakeFiles/lib_ir_proto.dir/build.make:79: *** target pattern contains no `%'. Stop.
I open this file, and find the line in lib_ir_proto.dir/build.make
:
ir/proto/data_type.pb.cc: ir/protobuf::protoc
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
It seems make cannot figure out ::
. I change the build.make
manually and the compiling goes on and broke on another place of having protobuf::protoc
. There are many places using it so I can't change it one by one.
# mannualy change
ir/proto/data_type.pb.cc: ir/protobuf\:\:protoc
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
protobuf::protoc
is a cmake target produced by protobuf's official compiling cmakelist, I use it in FindProtobuf.cmake
this way:
set(PROTOC_EXE protobuf::protoc)
And then this compiler was used to compile proto files.
I tried to escape in CMake:
set(PROTOC_EXE protobuf\\:\\:protoc)
But still get error with the same line of lib_ir_proto.dir/build.make
:
ir/proto/data_type.pb.cc: ir/protobuf/:/:protoc
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
make file doesn't have a \
escaping backslash as I wanted. Does anyone has some suggestions?
PS:
With higher protobuf, It all goes well.The generated make file:
ir/proto/data_type.pb.cc: _deps/protobuf-build/protoc-3.17.0.0
ir/proto/data_type.pb.cc: ../ir/proto/data_type.proto
The right ptoroc
was found.It seems in lower protobuf, protoc target change?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如评论所说,
protobuf :: Protoc
只是protoc
的别名。因此,只需在cmakelists.txt中使用protoc
目标名称即可。As the comment said,
protobuf::protoc
is just an alias ofprotoc
. So just useprotoc
target name in CMakeLists.txt is ok.