From a9eb981de225e07b52fa01a7d909ca4b1da98da8 Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Sat, 22 Oct 2022 16:00:58 +0200 Subject: [PATCH] ADD: added protobuf lib --- CMakeLists.txt | 27 ++++++++++++++++++++-- include/WHISPER/Messages/Protos/join.proto | 16 +++++++++++++ src/main.cpp | 12 ++++++++++ src/protos/join.proto | 16 +++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 include/WHISPER/Messages/Protos/join.proto create mode 100644 src/main.cpp create mode 100644 src/protos/join.proto diff --git a/CMakeLists.txt b/CMakeLists.txt index a182c33..e0bc20e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,11 @@ set(protobuf_BUILD_EXAMPLES OFF CACHE INTERNAL "") add_subdirectory(libs/protobuf EXCLUDE_FROM_ALL) include(protobuf) -protobuf_generate_cpp(PROTO_PATH tests/protos CPP_PATH tests/protos/src HPP_PATH tests/protos/include) + +if(protobuf_VERBOSE) + message(STATUS "Using Protocol Buffers ${protobuf_VERSION}") +endif() + add_library(whisper-com STATIC @@ -38,19 +42,36 @@ add_library(whisper-com STATIC ) + target_link_libraries(whisper-com loguru cppzmq libzmq + libprotobuf ) -add_dependencies(whisper-com protoc) target_include_directories(whisper-com PUBLIC $ $ src) + add_executable(main + + src/main.cpp + + ) + + add_dependencies(main protoc) + + target_link_libraries(main + whisper-com + loguru + libprotobuf + ) + protobuf_generate_cpp(PROTO_PATH protos CPP_PATH include/WHISPER/Messages/Protos HPP_PATH include/WHISPER/Messages/Protos) + + # # Everything TEST related # @@ -62,4 +83,6 @@ IF (${TEST_WHISPER_COMMUNICATION_LIBRARY}) target_link_libraries(test_test Catch2::Catch2 whisper-com loguru) catch_discover_tests(test_test) + add_dependencies(test_test protoc) + ENDIF() diff --git a/include/WHISPER/Messages/Protos/join.proto b/include/WHISPER/Messages/Protos/join.proto new file mode 100644 index 0000000..4f5881d --- /dev/null +++ b/include/WHISPER/Messages/Protos/join.proto @@ -0,0 +1,16 @@ + +// [START declaration] +syntax = "proto3"; +package messages.join; + +import "google/protobuf/timestamp.proto"; +// [END declaration] + + +// [START messages] +message Join { + int32 id = 1; + int32 port = 2; + string address = 3; +} + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..c9232b5 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,12 @@ +#include + + +#include "protos/join.pb.h" + + +int main() +{ + + + +} \ No newline at end of file diff --git a/src/protos/join.proto b/src/protos/join.proto new file mode 100644 index 0000000..4f5881d --- /dev/null +++ b/src/protos/join.proto @@ -0,0 +1,16 @@ + +// [START declaration] +syntax = "proto3"; +package messages.join; + +import "google/protobuf/timestamp.proto"; +// [END declaration] + + +// [START messages] +message Join { + int32 id = 1; + int32 port = 2; + string address = 3; +} +