-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
136 lines (112 loc) · 3.64 KB
/
CMakeLists.txt
File metadata and controls
136 lines (112 loc) · 3.64 KB
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
131
132
133
134
135
136
cmake_minimum_required(VERSION 3.16)
project(DistributedIMSystem)
option(DIMS_BUILD_TESTING "Enable DistributedIMSystem building tests" ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "No CMAKE_BUILD_TYPE found, Set Release build as default.")
endif()
if("${CMAKE_BUILD_TYPE}" MATCHES "[Rr]elease")
message(STATUS "This is a Release build.")
set(TBB_TEST
OFF
CACHE BOOL "Disable oneTBB tests" FORCE)
set(DIMS_BUILD_TESTING
OFF
CACHE BOOL "Disable tests generation" FORCE)
else()
message(STATUS "This is a Debug build.")
set(DIMS_BUILD_TESTING
ON
CACHE BOOL "Disable tests generation" FORCE)
enable_testing()
add_subdirectory(tests)
endif()
if(NOT MSVC)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Found CCache: ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PROGRAM})
endif()
else()
# Enable MSVC exceptions (as above)
message(STATUS "MSVC detected, enabling /EHsc")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} /EHsc"
CACHE STRING "MSVC exception flag" FORCE)
add_compile_options(/EHsc)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(FETCHCONTENT_QUIET OFF)
# disable boringssl assembly language
set(OPENSSL_NO_ASM ON)
# disable boost assembly language
set(BOOST_NO_ASSEMBLY
ON
CACHE BOOL "Disable Boost Assembly")
# we have to disable this to prevent upb_alloc_global
set(protobuf_BUILD_LIBUPB OFF)
set(gRPC_SSL_PROVIDER package)
set(ABSL_ENABLE_INSTALL ON) # Very important!!!!
# Force to build protoc
set(gRPC_BUILD_TESTS OFF)
set(gRPC_INSTALL ON)
set(protobuf_BUILD_PROTOC_BINARIES ON)
set(protobuf_BUILD_TESTS OFF)
set(protobuf_USE_STATIC_LIBS OFF)
include(FetchContent)
set(BOOST_ENABLE_CMAKE
ON
CACHE BOOL "" FORCE)
set(BOOST_INCLUDE_LIBRARIES
asio
filesystem
uuid
system
beast
mysql
url
json)
# -----------------------------
# External Dependencies (FetchContent)
# -----------------------------
FetchContent_Declare(
boost
GIT_REPOSITORY https://github.com/boostorg/boost.git
GIT_TAG boost-1.84.0
GIT_SUBMODULES_RECURSE TRUE)
FetchContent_Declare(
gRPC
GIT_REPOSITORY https://github.com/grpc/grpc
GIT_TAG v1.50.2
GIT_SUBMODULES_RECURSE TRUE)
FetchContent_MakeAvailable(boost gRPC)
set(PROTOBUF_PROTOC_EXECUTABLE $<TARGET_FILE:protoc>)
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)
add_library(boost_common INTERFACE)
target_link_libraries(boost_common INTERFACE Boost::asio Boost::system
Boost::filesystem Boost::uuid)
add_library(boost_balance INTERFACE)
target_link_libraries(boost_balance INTERFACE boost_common)
add_library(boost_gateway INTERFACE)
target_link_libraries(
boost_gateway INTERFACE Boost::beast Boost::mysql boost_common Boost::url
Boost::json)
add_library(boost_chatting INTERFACE)
target_link_libraries(boost_chatting INTERFACE boost_common Boost::mysql
Boost::json)
add_library(boost_resources INTERFACE)
target_link_libraries(boost_resources INTERFACE boost_common Boost::mysql
Boost::json)
# Add external dependencies once
add_subdirectory(external/inifile)
add_subdirectory(external/spdlog)
add_subdirectory(external/hiredis)
add_subdirectory(external/oneTBB)
# Add submodules (servers)
add_subdirectory(gateway-server)
add_subdirectory(balance-server)
add_subdirectory(chatting-server)
add_subdirectory(resources-server)