-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
179 lines (154 loc) · 4.32 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
project(darlingserver)
cmake_minimum_required(VERSION 3.13)
option(DSERVER_TOOLS "Build darlingserver tools (for debugging)" OFF)
option(DSERVER_ASAN "Build darlingserver with ASAN" OFF)
option(DSERVER_UBSAN "Build darlingserver with UBSAN" OFF)
if (DSERVER_TOOLS)
add_subdirectory(tools)
endif()
if (DSERVER_ASAN)
add_compile_definitions(
DSERVER_ASAN=1
)
else()
add_compile_definitions(
DSERVER_ASAN=0
)
endif()
if (DSERVER_UBSAN)
add_compile_definitions(
DSERVER_UBSAN=1
)
else()
add_compile_definitions(
DSERVER_UBSAN=0
)
endif()
set(dserver_sanitizers "")
if (DSERVER_ASAN)
if (NOT (dserver_sanitizers STREQUAL ""))
set(dserver_sanitizers "${dserver_sanitizers},")
endif()
set(dserver_sanitizers "${dserver_sanitizers}address")
endif()
if (DSERVER_UBSAN)
if (NOT (dserver_sanitizers STREQUAL ""))
set(dserver_sanitizers "${dserver_sanitizers},")
endif()
set(dserver_sanitizers "${dserver_sanitizers}undefined")
endif()
option(DSERVER_EXTENDED_DEBUG "Build darlingserver with extended debugging support" OFF)
if (DSERVER_EXTENDED_DEBUG)
add_compile_definitions(
DSERVER_EXTENDED_DEBUG=1
)
else()
add_compile_definitions(
DSERVER_EXTENDED_DEBUG=0
)
endif()
option(DSERVER_SINGLE_THREADED "Only use a single thread per workqueue in darlingserver" ON)
if (DSERVER_SINGLE_THREADED)
add_compile_definitions(
DSERVER_SINGLE_THREADED=1
)
else()
add_compile_definitions(
DSERVER_SINGLE_THREADED=0
)
endif()
add_subdirectory(duct-tape)
set(DARLINGSERVER_INIT_PROCESS "/sbin/launchd" CACHE STRING "The init process darlingserver should execute (default is \"/sbin/launchd\")")
set(DARLINGSERVER_XDG_USER_DIR_CMD "xdg-user-dir" CACHE STRING "The xdg-user-dir binary darlingserver should execute (default is \"xdg-user-dir\")")
include_directories(
include
internal-include
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/internal-include
${CMAKE_BINARY_DIR}/src/startup # for `rtsig.h`
)
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/include/darlingserver/rpc.h
${CMAKE_CURRENT_BINARY_DIR}/internal-include/darlingserver/rpc.internal.h
${CMAKE_CURRENT_BINARY_DIR}/src/rpc.c
COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate-rpc-wrappers.py
${CMAKE_CURRENT_BINARY_DIR}/include/darlingserver/rpc.h
${CMAKE_CURRENT_BINARY_DIR}/internal-include/darlingserver/rpc.internal.h
${CMAKE_CURRENT_BINARY_DIR}/src/rpc.c
\"../include/darlingserver/rpc.h\"
VERBATIM
MAIN_DEPENDENCY
${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate-rpc-wrappers.py
)
add_custom_target(generate_dserver_rpc_wrappers
ALL
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/include/darlingserver/rpc.h
${CMAKE_CURRENT_BINARY_DIR}/internal-include/darlingserver/rpc.internal.h
${CMAKE_CURRENT_BINARY_DIR}/src/rpc.c
)
add_executable(darlingserver
src/darlingserver.cpp
src/server.cpp
src/message.cpp
src/call.cpp
src/registry.cpp
src/logging.cpp
src/process.cpp
src/thread.cpp
src/utility.cpp
src/kqchan.cpp
src/async-writer.cpp
src/stack-pool.cpp
)
add_dependencies(darlingserver
generate_dserver_rpc_wrappers
rtsig_h
)
target_link_libraries(darlingserver PRIVATE
darlingserver_duct_tape
)
target_compile_options(darlingserver PRIVATE
-pthread
-std=c++17
)
target_link_options(darlingserver PRIVATE
-pthread
-Wl,--gc-sections
)
if (DSERVER_ASAN OR DSERVER_UBSAN)
target_compile_options(darlingserver PRIVATE
-fsanitize=${dserver_sanitizers}
-fsanitize-recover=all
-fno-omit-frame-pointer
-g
-Og
)
target_link_options(darlingserver PRIVATE
-fsanitize=${dserver_sanitizers}
-fsanitize-recover=all
)
endif()
if (DSERVER_EXTENDED_DEBUG)
target_compile_options(darlingserver PRIVATE
-fno-omit-frame-pointer
)
endif()
install(TARGETS darlingserver DESTINATION bin)
#file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${DARLING_SDK_RELATIVE_PATH}/usr/include/darlingserver")
#create_symlink(
# "${DARLING_ROOT_RELATIVE_TO_SDK}/../../../src/darlingserver/include/darlingserver/rpc.h"
# "${CMAKE_BINARY_DIR}/${DARLING_SDK_RELATIVE_PATH}/usr/include/darlingserver/rpc.h"
#)
if (NOT "${DARLINGSERVER_INIT_PROCESS}" STREQUAL "")
target_compile_definitions(darlingserver PRIVATE
DARLINGSERVER_INIT_PROCESS="${DARLINGSERVER_INIT_PROCESS}"
)
endif()
if (NOT "${DARLINGSERVER_XDG_USER_DIR_CMD}" STREQUAL "")
target_compile_definitions(darlingserver PRIVATE
DARLINGSERVER_XDG_USER_DIR_CMD="${DARLINGSERVER_XDG_USER_DIR_CMD}"
)
endif()