-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
130 lines (98 loc) · 3.25 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
129
130
project(reef)
cmake_minimum_required(VERSION 3.2)
add_compile_options(-std=c++11)
add_definitions(-D__REEF_HIP_GPU__)
add_definitions(-DRESOURCE_DIR="${CMAKE_CURRENT_LIST_DIR}/resource")
# GRPC and Protocol Buffers libraries location
list(APPEND CMAKE_PREFIX_PATH "/opt/rocm")
# Cmake find modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# For grpc
include("${CMAKE_CURRENT_LIST_DIR}/cmake/common.cmake")
get_filename_component(reef_proto "${CMAKE_CURRENT_LIST_DIR}/src/reef/protos/reef.proto" ABSOLUTE)
get_filename_component(reef_proto_path "${reef_proto}" PATH)
set(GRPC_GENERATE_DIR "${PROJECT_SOURCE_DIR}/src/reef/rpc" )
set(reef_proto_srcs "${GRPC_GENERATE_DIR}/reef.pb.cc")
set(reef_proto_hdrs "${GRPC_GENERATE_DIR}/reef.pb.h")
set(reef_grpc_srcs "${GRPC_GENERATE_DIR}/reef.grpc.pb.cc")
set(reef_grpc_hdrs "${GRPC_GENERATE_DIR}/reef.grpc.pb.h")
add_custom_command(
OUTPUT "${reef_proto_srcs}" "${reef_proto_hdrs}" "${reef_grpc_srcs}" "${reef_grpc_hdrs}"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${GRPC_GENERATE_DIR}"
--cpp_out "${GRPC_GENERATE_DIR}"
-I "${reef_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${reef_proto}"
DEPENDS "${reef_proto}")
include_directories("${GRPC_GENERATE_DIR}")
# reef_grpc_proto
add_library(reef_grpc_proto
${reef_grpc_srcs}
${reef_grpc_hdrs}
${reef_proto_srcs}
${reef_proto_hdrs})
target_link_libraries(reef_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
# REEF codes
find_package(hip REQUIRED)
find_package(GTest REQUIRED)
find_package(glog REQUIRED)
SET(CMAKE_CXX_COMPILER "/opt/rocm/bin/hipcc")
set(CMAKE_CXX_FLAGS "-g -O0 ${CMAKE_CXX_FLAGS}")
include_directories(${HIP_INCLUDE_DIRS})
include_directories("${PROJECT_SOURCE_DIR}/src")
AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/src/reef/client" client)
AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/src/reef/executor" executor)
AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/src/reef/executor/hip" hip_impl)
AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/src/reef/server" server)
AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/src/reef/util" util)
AUX_SOURCE_DIRECTORY("${PROJECT_SOURCE_DIR}/src/reef/test" test)
add_library(reef_util
${util}
)
add_library(reef_server_lib
${server}
${executor}
${hip_impl}
)
add_library(reef_client_lib
${client}
)
add_executable(unit_test
${test}
)
target_link_libraries(unit_test
reef_util
reef_server_lib
reef_client_lib
reef_grpc_proto
glog::glog
${GTEST_BOTH_LIBRARIES}
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
pthread
)
function (add_executable_app app_name app_path)
add_executable(${app_name}
${app_path}
)
target_link_libraries(${app_name}
reef_util
reef_server_lib
reef_client_lib
reef_grpc_proto
glog::glog
${GTEST_BOTH_LIBRARIES}
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF}
pthread
)
endfunction()
add_executable_app(reef_client "${PROJECT_SOURCE_DIR}/src/example/rpc_client.cpp")
add_executable_app(reef_client_cont "${PROJECT_SOURCE_DIR}/src/example/rpc_client_cont.cpp")
add_executable_app(reef_server "${PROJECT_SOURCE_DIR}/src/example/rpc_server.cpp")