ADD: added protobuf lib

This commit is contained in:
Henry Winkel
2022-10-22 16:00:58 +02:00
parent 22d06a02db
commit a9eb981de2
4 changed files with 69 additions and 2 deletions

View File

@@ -29,7 +29,11 @@ set(protobuf_BUILD_EXAMPLES OFF CACHE INTERNAL "")
add_subdirectory(libs/protobuf EXCLUDE_FROM_ALL) add_subdirectory(libs/protobuf EXCLUDE_FROM_ALL)
include(protobuf) 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 add_library(whisper-com STATIC
@@ -38,19 +42,36 @@ add_library(whisper-com STATIC
) )
target_link_libraries(whisper-com target_link_libraries(whisper-com
loguru loguru
cppzmq cppzmq
libzmq libzmq
libprotobuf
) )
add_dependencies(whisper-com protoc)
target_include_directories(whisper-com PUBLIC target_include_directories(whisper-com PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
src) 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 # Everything TEST related
# #
@@ -62,4 +83,6 @@ IF (${TEST_WHISPER_COMMUNICATION_LIBRARY})
target_link_libraries(test_test Catch2::Catch2 whisper-com loguru) target_link_libraries(test_test Catch2::Catch2 whisper-com loguru)
catch_discover_tests(test_test) catch_discover_tests(test_test)
add_dependencies(test_test protoc)
ENDIF() ENDIF()

View File

@@ -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;
}

12
src/main.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include <iostream>
#include "protos/join.pb.h"
int main()
{
}

16
src/protos/join.proto Normal file
View File

@@ -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;
}