-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
129 lines (110 loc) · 3.49 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
cmake_minimum_required(VERSION 3.14.0)
project(faabric)
option(FAABRIC_WASM_BUILD "Build Faabric wasm library" OFF)
option(FAABRIC_BUILD_TESTS "Build Faabric tests" ON)
# Top-level CMake config
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Compile comamnds for clang tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Global include dir
set(FAABRIC_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include)
# Output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# External libraries
include(cmake/ExternalProjects.cmake)
# Library funcs
function(faabric_lib lib_name lib_deps)
# "Normal" library used for linking internally
add_library(${lib_name} ${lib_deps})
target_include_directories(${lib_name}
PUBLIC ${FAABRIC_INCLUDE_DIR}
PUBLIC ${PISTACHE_INCLUDE_DIR}
PUBLIC ${SPDLOG_INCLUDE_DIR}
PUBLIC ${RAPIDJSON_INCLUDE_DIR}
PUBLIC ${CPPCODEC_INCLUDE_DIR}
)
# Object library for bundling everything together (should have the same
# include dirs and dependencies as the normal library)
add_library(${lib_name}_obj OBJECT ${lib_deps})
target_include_directories(${lib_name}_obj
PUBLIC ${FAABRIC_INCLUDE_DIR}
PUBLIC ${PISTACHE_INCLUDE_DIR}
PUBLIC ${SPDLOG_INCLUDE_DIR}
PUBLIC ${RAPIDJSON_INCLUDE_DIR}
PUBLIC ${CPPCODEC_INCLUDE_DIR}
)
target_link_libraries(${lib_name}_obj ${lib_name})
if(BUILD_SHARED_LIBS)
target_compile_options(${lib_name} PRIVATE "-fPIC")
target_compile_options(${lib_name}_obj PRIVATE "-fPIC")
endif()
endfunction()
add_subdirectory(src/endpoint)
add_subdirectory(src/flat)
add_subdirectory(src/mpi)
add_subdirectory(src/mpi_native)
add_subdirectory(src/proto)
add_subdirectory(src/redis)
add_subdirectory(src/runner)
add_subdirectory(src/rpc)
add_subdirectory(src/scheduler)
add_subdirectory(src/snapshot)
add_subdirectory(src/state)
add_subdirectory(src/util)
# Wrapper library - note we want to include all the _object_ targets in this
# library to ensure it's all bundled in together
if(BUILD_SHARED_LIBS)
set(FAABRIC_LIB_TYPE SHARED)
else()
set(FAABRIC_LIB_TYPE STATIC)
endif()
add_library(faabric
${FAABRIC_LIB_TYPE}
faabric.cpp
$<TARGET_OBJECTS:endpoint_obj>
$<TARGET_OBJECTS:flat_obj>
$<TARGET_OBJECTS:proto_obj>
$<TARGET_OBJECTS:redis_obj>
$<TARGET_OBJECTS:rpc_obj>
$<TARGET_OBJECTS:runner_obj>
$<TARGET_OBJECTS:scheduler_obj>
$<TARGET_OBJECTS:snapshot_obj>
$<TARGET_OBJECTS:state_obj>
$<TARGET_OBJECTS:util_obj>
)
add_dependencies(faabric pistache spdlog_ext)
target_link_libraries(faabric PUBLIC
${Protobuf_LIBRARIES}
faabricmpi
gRPC::grpc++
gRPC::grpc++_reflection
hiredis
pistache
boost_system
boost_filesystem
zstd::libzstd_static
)
target_include_directories(faabric PUBLIC
${FAABRIC_INCLUDE_DIR}
${CMAKE_INSTALL_PREFIX}/include
)
# Tests - only include in static builds _and_ when requested
if(BUILD_SHARED_LIBS)
message(STATUS "Skipping test build with shared libs")
elseif(FAABRIC_BUILD_TESTS)
add_subdirectory(tests/dist)
add_subdirectory(tests/test)
add_subdirectory(tests/utils)
endif()
# Install headers
install(
DIRECTORY ${FAABRIC_INCLUDE_DIR}/faabric
DESTINATION include
)
install(TARGETS faabric)