1set(_dumpstate_CXX_FLAGS -Wall -Werror -std=c++17)
2
3include(${trout_SRC_ROOT}/cmake/googletest.cmake)
4include(${trout_SRC_ROOT}/cmake/grpc.cmake)
5include(${trout_SRC_ROOT}/cmake/protobuf.cmake)
6include(${trout_SRC_ROOT}/cmake/utils/grpc_cpp_generator.cmake)
7
8find_package(LibXml2 REQUIRED)
9
10get_filename_component(dumpstate_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. ABSOLUTE)
11
12if (NOT trout_GENS_DIR)
13  set(trout_GENS_DIR ${PROJECT_BINARY_DIR}/gens)
14endif()
15
16trout_generate_grpc_cpp_from_proto(
17    SRCS
18    ${dumpstate_SRC_ROOT}/proto/DumpstateServer.proto)
19
20# ========== Protobuf generated code ==================
21
22add_library(dumpstate_protobuf_gen
23    ${trout_GENS_DIR}/DumpstateServer.pb.cc
24    ${trout_GENS_DIR}/DumpstateServer.grpc.pb.cc
25)
26
27target_link_libraries(dumpstate_protobuf_gen
28    ${trout_GRPCXX_LIBRARIES}
29)
30
31target_compile_options(dumpstate_protobuf_gen PRIVATE ${_dumpstate_CXX_FLAGS} -Wno-array-bounds)
32
33# ========== dumpstate_grpc_server ==============
34
35set(_dumpstate_sources
36    ${dumpstate_SRC_ROOT}/DumpstateServer.cpp
37    ${dumpstate_SRC_ROOT}/DumpstateGrpcServer.cpp
38    ${dumpstate_SRC_ROOT}/ServiceDescriptor.cpp
39    ${dumpstate_SRC_ROOT}/ServiceSupplier.cpp
40    ${dumpstate_SRC_ROOT}/config/dumpstate_hal_configuration_V1_0.cpp
41    ${dumpstate_SRC_ROOT}/config/XmlServiceSupplier.cpp
42)
43
44add_executable(dumpstate_grpc_server
45    ${_dumpstate_sources}
46    ${dumpstate_SRC_ROOT}/server_main.cpp
47)
48
49target_include_directories(dumpstate_grpc_server
50    PRIVATE ${trout_GENS_DIR}
51    ${dumpstate_SRC_ROOT}
52    ${LIBXML2_INCLUDE_DIR}
53)
54
55target_link_libraries(dumpstate_grpc_server
56    dumpstate_protobuf_gen
57    ${LIBXML2_LIBRARIES}
58)
59
60target_compile_options(dumpstate_grpc_server PRIVATE ${_dumpstate_CXX_FLAGS})
61
62add_executable(dumpstate_tests
63    ${_dumpstate_sources}
64    ${dumpstate_SRC_ROOT}/tests/test_main.cpp
65    ${dumpstate_SRC_ROOT}/tests/tests.cpp
66)
67
68target_include_directories(dumpstate_tests
69    PRIVATE ${trout_GENS_DIR}
70    ${dumpstate_SRC_ROOT}
71    ${LIBXML2_INCLUDE_DIR}
72)
73
74target_link_libraries(dumpstate_tests
75    dumpstate_protobuf_gen
76    ${trout_GOOGLETEST_LIBRARIES}
77    ${LIBXML2_LIBRARIES}
78)
79
80target_compile_options(dumpstate_tests PRIVATE ${_dumpstate_CXX_FLAGS})
81