角色在cmake和make中逃脱不同

发布于 2025-02-12 08:09:50 字数 1756 浏览 0 评论 0原文

背景

我使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南风几经秋 2025-02-19 08:09:50

正如评论所说,protobuf :: Protoc只是protoc的别名。因此,只需在cmakelists.txt中使用protoc目标名称即可。

As the comment said, protobuf::protoc is just an alias of protoc. So just use protoc target name in CMakeLists.txt is ok.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文