【发布时间】:2022-11-23 18:21:28
【问题描述】:
我想在我的 C++ 库中使用 protobuf。到目前为止,所有依赖项都使用 cmake 的 FetchContent 模块包含在内。我想对protobuf 做同样的事情。但是,我遇到了以下问题:Unknown CMake command "protobuf_generate_cpp". 关于如何解决这个问题的任何提示?
我的CMakeLists.txt 的摘录:
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 9.0.0)
FetchContent_Declare(protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
GIT_TAG v21.4)
FetchContent_MakeAvailable(fmt protobuf)
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS message.proto)
【问题讨论】:
标签: cmake protocol-buffers fetchcontent