I'm trying to make it same way I made it for boost :
find_package(Boost COMPONENTS system filesystem REQUIRED) find_package(ProtocolBuffers) ## Compiler flags if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "-O2") set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread") endif() target_link_libraries(complex ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${PROTOBUF_LIBRARY} )
(googled it somewhere) but got bad output:
CMake Warning at complex/CMakeLists.txt:18 (find_package): Could not find module FindProtocolBuffers.cmake or a configuration file for package ProtocolBuffers. Adjust CMAKE_MODULE_PATH to find FindProtocolBuffers.cmake or set ProtocolBuffers_DIR to the directory containing a CMake configuration file for ProtocolBuffers. The file will have one of the following names: ProtocolBuffersConfig.cmake protocolbuffers-config.cmake
How can I link it with cmake? or maybe I even can compile .proto file using cmake?
Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.
The protobuf_generate_cpp function is responsible for executing the protoc and populating the PROTO_SRCS and PROTO_HDRS variables with their generated files. Without this functionality, you would need to manually add the protoc command and the required arguments.
You can certainly send even a binary payload with an HTTP request, or in an HTTP response. Just write the bytes of the protocol buffer directly into the request/response, and make sure to set the content type to "application/octet-stream". The client, and server, should be able to take care of the rest easily.
You could try CMake's FindProtobuf
module:
include(FindProtobuf) find_package(Protobuf REQUIRED) include_directories(${PROTOBUF_INCLUDE_DIR}) ... target_link_libraries(complex ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${PROTOBUF_LIBRARY} )
For further info, run
cmake --help-module FindProtobuf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With