-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
128 lines (110 loc) · 4.78 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cmake_minimum_required(VERSION 3.17)
project(MailTaxi CXX)
set(CMAKE_CXX_STANDARD 17)
find_package(Boost 1.74.0 REQUIRED thread )
find_package(LibCDS CONFIG REQUIRED PATHS /home/anton/vcpkg/packages/libcds_x64-linux/share/libcds)
include_directories(${Boost_INCLUDE_DIRS})
# Protobuf
set(protobuf_MODULE_COMPATIBLE TRUE)
find_package(Protobuf CONFIG REQUIRED)
message(STATUS "Using protobuf ${protobuf_VERSION}")
# gRPC
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
# gRPC C++ plugin
get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin
IMPORTED_LOCATION_RELEASE)
set(_GRPC_GRPCPP gRPC::grpc++)
set(_REFLECTION gRPC::grpc++_reflection)
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin)
function(PROTOBUF_GENERATE_GRPC_CPP SRCS HDRS)
if(NOT ARGN)
message(SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files")
return()
endif()
if(PROTOBUF_GENERATE_CPP_APPEND_PATH) # This variable is common for all types of output.
# Create an include path for each file specified
foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
if(${_contains_already} EQUAL -1)
list(APPEND _protobuf_include_path -I ${ABS_PATH})
endif()
endforeach()
else()
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(DEFINED PROTOBUF_IMPORT_DIRS)
foreach(DIR ${Protobuf_IMPORT_DIRS})
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
if(${_contains_already} EQUAL -1)
list(APPEND _protobuf_include_path -I ${ABS_PATH})
endif()
endforeach()
endif()
set(${SRCS})
set(${HDRS})
foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.cc")
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.h")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.cc"
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.grpc.pb.h"
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
ARGS --grpc_out=${CMAKE_CURRENT_BINARY_DIR}
--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN}
${_protobuf_include_path} ${ABS_FIL}
DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL}"
VERBATIM)
endforeach()
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
endfunction()
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories(GeoIndexer/include)
include_directories(Authorization/include)
include_directories(OrderManagement/include)
include_directories(CashTable/include)
include_directories(CDSHelper/include)
include_directories(GeoIndexClient/include)
include_directories(/home/anton/libpq/src/interfaces/libpq)
include_directories(/home/anton/libpq/src/include)
PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders protos/GeoData.proto protos/TaxiFacilities.proto protos/GeoIndex.proto
protos/OrderManagement.proto protos/Authorization.proto)
PROTOBUF_GENERATE_GRPC_CPP(ProtoGRPCSources ProtoGRPCHeaders protos/GeoIndex.proto protos/OrderManagement.proto protos/Authorization.proto)
file(GLOB SrcAuthorization "Authorization/src/*.cpp")
add_executable(Authorization ${SrcAuthorization} GeoIndexClient/src/GeoIndexClient.cpp
${ProtoSources}
${ProtoGRPCSources})
target_link_libraries(Authorization
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
${PostgreSQL_LIBRARIES}
Boost::thread LibCDS::cds-s
/home/anton/libpq/build/libpq.so)
file(GLOB SrcGeoIndexer "GeoIndexer/src/*.cpp")
add_executable(GeoIndexer ${SrcGeoIndexer}
${ProtoSources}
${ProtoGRPCSources})
target_link_libraries(GeoIndexer
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
Boost::thread LibCDS::cds-s)
file(GLOB SrcOrderManagement "OrderManagement/src/*.cpp")
add_executable(OrderManagement ${SrcOrderManagement} GeoIndexClient/src/GeoIndexClient.cpp
${ProtoSources}
${ProtoGRPCSources})
target_link_libraries(OrderManagement
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
Boost::thread LibCDS::cds-s)