-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
126 lines (111 loc) · 5.16 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
cmake_minimum_required(VERSION 3.13)
project(Hoplite VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#if (MSVC)
# # warning level 4 and all warnings as errors
# add_compile_options(/W4)
#else()
# # lots of warnings and all warnings as errors
# add_compile_options(-Wall -Wextra -pedantic)
#endif()
# Cmake find modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(FindGRPC)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(Protobuf REQUIRED)
find_package(gRPC REQUIRED)
find_package(MPI REQUIRED)
message(STATUS "Using Protobuf ${Protobuf_VERSION}, gRPC ${gRPC_VERSION}")
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${gRPC_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_LIST_DIR}/src/)
protobuf_generate_cpp(HOPLITE_PROTO_SRCS HOPLITE_PROTO_HDRS src/protocol/object_store.proto)
protobuf_generate_python(HOPLITE_PROTO_PY src/protocol/object_store.proto)
grpc_generate_cpp(HOPLITE_GRPC_SRCS HOPLITE_GRPC_HDRS "${CMAKE_CURRENT_BINARY_DIR}" src/protocol/object_store.proto)
file(GLOB hoplite_common_SRC "src/common/*.h" "src/common/*.cc")
file(GLOB hoplite_utils_SRC "src/util/*.h" "src/util/*.cc")
add_library(hoplite_common ${hoplite_common_SRC})
add_library(hoplite_utils ${hoplite_utils_SRC})
file(GLOB hoplite_client_SRC "src/client/*.h" "src/client/*.cc")
add_library(hoplite_client ${hoplite_client_SRC}
${HOPLITE_PROTO_SRCS} ${HOPLITE_PROTO_HDRS}
${HOPLITE_GRPC_SRCS} ${HOPLITE_GRPC_HDRS})
add_library(hoplite_client_lib SHARED ${hoplite_client_SRC}
${HOPLITE_PROTO_SRCS} ${HOPLITE_PROTO_HDRS}
${HOPLITE_GRPC_SRCS} ${HOPLITE_GRPC_HDRS})
set_target_properties(hoplite_client_lib PROPERTIES
PUBLIC_HEADER src/client/distributed_object_store.h
POSITION_INDEPENDENT_CODE ON)
target_include_directories(hoplite_client_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/client)
target_link_libraries(hoplite_client_lib PRIVATE hoplite_utils hoplite_common
${Protobuf_LIBRARIES}
${gRPC_LIBRARIES}
gRPC::grpc++_reflection
protobuf::libprotobuf
PRIVATE Threads::Threads
${CMAKE_DL_LIBS})
# build executables
# object directory
file(GLOB object_directory_SRC "src/object_directory/*.h" "src/object_directory/*.cc")
add_executable(notification
${object_directory_SRC}
${HOPLITE_PROTO_SRCS} ${HOPLITE_PROTO_HDRS}
${HOPLITE_GRPC_SRCS} ${HOPLITE_GRPC_HDRS})
target_include_directories(notification PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/object_directory)
target_link_libraries(notification PRIVATE hoplite_utils hoplite_common
PRIVATE Threads::Threads
${CMAKE_DL_LIBS}
${Protobuf_LIBRARIES}
${gRPC_LIBRARIES}
gRPC::grpc++_reflection
protobuf::libprotobuf)
# tests
# TODO: notification_server_test
set(hoplite_communication_tests multicast_test reduce_test subset_reduce_test allreduce_test gather_test allgather_test)
foreach (testname ${hoplite_communication_tests})
add_executable(${testname} "src/tests/${testname}.cc")
set_target_properties(${testname}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests/"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests/"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests/"
COMPILE_FLAGS "${MPI_COMPILE_FLAGS}"
LINK_FLAGS "${MPI_LINK_FLAGS}")
target_include_directories(${testname} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/client
${MPI_INCLUDE_PATH})
target_link_libraries(${testname} PRIVATE hoplite_client hoplite_common hoplite_utils
Threads::Threads
${CMAKE_DL_LIBS}
${Protobuf_LIBRARIES}
${gRPC_LIBRARIES}
${MPI_LIBRARIES}
gRPC::grpc++_reflection
protobuf::libprotobuf)
endforeach (testname ${hoplite_communication_tests})
add_executable(reduce_dependency_test "src/tests/reduce_dependency_test.cc" "src/object_directory/reduce_dependency.cc")
target_link_libraries(reduce_dependency_test PRIVATE hoplite_common hoplite_utils
Threads::Threads
${CMAKE_DL_LIBS}
${Protobuf_LIBRARIES}
${gRPC_LIBRARIES}
gRPC::grpc++_reflection
protobuf::libprotobuf)
set_target_properties(reduce_dependency_test
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests/"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests/"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests/")
# install(TARGETS hoplite_client_lib
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
# PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#notification_server_test: $(PROTO_OBJS) $(UTILS_OBJS) $(COMMON_OBJS) src/notification_server_test.o
# $(CXX) $^ $(LDFLAGS) -o $@
#
#py_distributed_object_store: libdistributed_object_store.so
# python setup.py build_ext --inplace && cp *distributed_object_store*.so python/hoplite && cp notification python/hoplite