我正在使用protobuf_generate_cpp()以便从* .proto文件生成* .cc和* .h文件,但未得到执行。我没有收到任何错误消息,只是跳过了行。 CMakeLists.txt文件如下所示:
cmake_minimum_required(VERSION 3.1.2)
cmake_policy(SET CMP0028 NEW)
project(ProjectName CXX C)
execute_process(COMMAND conan install . WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY})
include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
find_package(Protobuf REQUIRED)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS /path/to/NAME.proto)
add_custom_command(
OUTPUT NAME.pbs.h
OUTPUT NAME.pbs.cc
DEPENDS NAME.proto
COMMAND protoc --cpp_out=$(CMAKE_BINARY_SOURCE_DIR) --proto_path=../path/to/NAME.proto
)
set(ProjectName-HeaderFiles
${ProjectName-HeaderFiles}
<list of all header files>
)
set(ProjectName-SourceFiles
${ProjectName-SourceFiles}
<list of all source files>
)
add_executable(ProjectName ${PROTO_SRCS} ${PROTO_HDRS}
<list of all other executables>
)
add_definitions(
-D_CONSOLE
-DWIN32
-D_DEBUG
-DSTANDALONE_PROGRAM
)
include_directories(
<list of all include paths>
)
target_link_libraries( ProjectName
PUBLIC
CONAN_PKG::Protobuf
LIB1
LIB2
)
我的解决方案是在位置CMAKE_BINARY_SOURCE_DIR上创建的,但未创建NAME.pb.h和NAME.pb.cc文件。有人可以让我知道可能是什么问题吗?任何建议表示赞赏。