我正试图在我的一个项目中使用CMake函数protobuf_generate
。然而,我希望构建尽可能轻量级。如果可能的话,我想在不编译protobuf的源代码或在我的(windows(机器上安装一些包的情况下完成这项工作。
有没有一种方法可以下载二进制文件和标头并告诉CMake:";这是你需要的一切",所以我可以随时交换新的原型版本?
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.5)
project ("CMakeProject1")
set(TARGET_NAME CMakeProject1)
SET(PROTOBUF_INCLUDE_DIR "/path/to/include")
SET(PROTOBUF_LIBRARY "/path/to/libprotobuf.lib")
SET(PROTOBUF_PROTOC_EXECUTABLE "/path/to/protoc.exe")
find_package(Protobuf)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS path/to/some_object.proto)
add_library(${TARGET_NAME} STATIC ${PROTO_SRCS} ${PROTO_HDRS})