我正在尝试让Cmake编译我的原型文件。我为此使用以下CMakeLists.txt。
include(FindProtobuf)
find_package(Protobuf REQUIRED)
# check if protobuf was found
if(PROTOBUF_FOUND)
message ("protobuf found")
else()
message (FATAL_ERROR "Cannot find Protobuf")
endif()
include_directories(${PROTOBUF_INCLUDE_DIR})
message(${PROTOBUF_INCLUDE_DIR})
set(PROTO_FILES
msg.proto)
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER ${PROTO_FILES})
message ("PROTO_SRC = ${PROTO_SRC}")
message ("PROTO_HEADER = ${PROTO_HEADER}")
add_library(proto ${PROTO_HEADER} ${PROTO_SRC})
我的文件夹结构:
cpp/
protos
msg.proto
CMakeLists.txt
build
debug
我从构建/调试中构建。找到了Protobuf。对于Proto_src和Proto_header,我发现:
PROTO_SRC = /home/mike/code/protos/cpp/build/debug/protos/msg.pb.cc
PROTO_HEADER = /home/mike/code/protos/cpp/build/debug/protos/msg.pb.h
但是在尝试编译时出现以下错误:
make[2]: *** No rule to make target '../../protos/msg.proto', needed by 'protos/msg.pb.h'. Stop.
我从https://github.com/shaochuan/cmake-protobuf-example那里获得了设置
我在这里看不到我想念的东西吗?