Locate and configure the Google Protocol Buffers library.
The following variables can be set and are optional:
PROTOBUF_SRC_ROOT_FOLDER
PROTOBUF_IMPORT_DIRS
Defines the following variables:
PROTOBUF_FOUND
PROTOBUF_INCLUDE_DIRS
PROTOBUF_LIBRARIES
PROTOBUF_PROTOC_LIBRARIES
PROTOBUF_LITE_LIBRARIES
The following cache variables are also available to set or use:
PROTOBUF_LIBRARY
PROTOBUF_PROTOC_LIBRARY
PROTOBUF_INCLUDE_DIR
PROTOBUF_PROTOC_EXECUTABLE
PROTOBUF_LIBRARY_DEBUG
PROTOBUF_PROTOC_LIBRARY_DEBUG
PROTOBUF_LITE_LIBRARY
PROTOBUF_LITE_LIBRARY_DEBUG
Example:
find_package(Protobuf REQUIRED) include_directories(${PROTOBUF_INCLUDE_DIRS}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto) protobuf_generate_python(PROTO_PY foo.proto) add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS}) target_link_libraries(bar ${PROTOBUF_LIBRARIES})
Note
The protobuf_generate_cpp
and protobuf_generate_python
functions and add_executable()
or add_library()
calls only work properly within the same directory.
protobuf_generate_cpp
Add custom commands to process .proto
files to C++:
protobuf_generate_cpp (<SRCS> <HDRS> [<ARGN>...])
SRCS
HDRS
ARGN
.proto
filesprotobuf_generate_python
Add custom commands to process .proto
files to Python:
protobuf_generate_python (<PY> [<ARGN>...])
PY
ARGN
.proto
filess
© 2000–2016 Kitware, Inc.
© 2000–2011 Insight Software Consortium
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.5/module/FindProtobuf.html