-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
222 lines (172 loc) · 6.33 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
cmake_minimum_required(VERSION 3.5)
project(TikTakToe LANGUAGES CXX)
find_package(
snodec COMPONENTS http-server-express websocket-server net-in-stream-legacy
net-in-stream-tls
)
if(snodec_FOUND)
configure_file(config.h.in config.h @ONLY)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_program(iwyu_path NAMES include-what-you-use iwyu)
if(iwyu_path)
option(CHECK_INCLUDES "Check used headers")
set(iwyu_path_and_options
${iwyu_path}
-Xiwyu
--verbose=1
-Xiwyu
--cxx17ns
-Xiwyu
--quoted_includes_first
-Xiwyu
--check_also='${PROJECT_SOURCE_DIR}/*'
)
if(CHECK_INCLUDES)
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path_and_options})
endif(CHECK_INCLUDES)
else()
message(
AUTHOR_WARNING "Could not find the program include-what-you-use"
)
endif()
add_compile_options(
-Werror
-Wall
-Wextra
-Wno-psabi # needed for RaspberryPi
-Wconversion
-Wpedantic
-pedantic-errors
-fexec-charset=UTF-8
)
set(TIKTAKTOE_SUBPROTOCOL_SOURCES
TikTakToeSubProtocolFactory.cpp TikTakToeSubProtocol.cpp
TikTakToeGameModel.cpp
)
# ##########################################################################
#
# Subprotocol as library
#
# ##########################################################################
add_library(tiktaktoeplugin SHARED ${TIKTAKTOE_SUBPROTOCOL_SOURCES})
target_link_libraries(tiktaktoeplugin PUBLIC snodec::websocket-server)
set_target_properties(
tiktaktoeplugin PROPERTIES OUTPUT_NAME "snodec-websocket-tiktaktoe-server"
SOVERSION "${SNODEC_SOVERSION}" # PREFIX "ssp"
)
target_include_directories(
tiktaktoeplugin PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
install(TARGETS tiktaktoeplugin
LIBRARY DESTINATION ${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR}
)
# ##########################################################################
#
# Inline linked target
#
# ##########################################################################
add_executable(
tiktaktoe-inline tiktaktoe.cpp ${TIKTAKTOE_SUBPROTOCOL_SOURCES}
)
target_compile_definitions(tiktaktoe-inline PRIVATE LINK_SUBPROTOCOL_STATIC)
target_include_directories(
tiktaktoe-inline PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(
tiktaktoe-inline
PUBLIC snodec::http-server-express snodec::websocket-server
snodec::net-in-stream-legacy snodec::net-in-stream-tls
)
set_target_properties(
tiktaktoe-inline
PROPERTIES
INSTALL_RPATH
"${CMAKE_INSTALL_PREFIX}/${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR}"
)
install(TARGETS tiktaktoe-inline RUNTIME DESTINATION bin)
# ##########################################################################
#
# Full dynamically linked target
#
# ##########################################################################
add_executable(tiktaktoe-dynamic tiktaktoe.cpp)
target_compile_definitions(
tiktaktoe-dynamic PRIVATE LINK_SUBPROTOCOL_STATIC
)
target_include_directories(
tiktaktoe-dynamic PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(
tiktaktoe-dynamic
PUBLIC snodec::http-server-express snodec::websocket-server
snodec::net-in-stream-legacy snodec::net-in-stream-tls
tiktaktoeplugin
)
target_link_directories(
tiktaktoe-dynamic PRIVATE
${WEBSOCKET_SUBPROTOCOL_SERVER_INSTALL_LIBDIR}
)
set_target_properties(
tiktaktoe-dynamic
PROPERTIES
INSTALL_RPATH
"${CMAKE_INSTALL_PREFIX}/${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR}"
)
install(TARGETS tiktaktoe-dynamic RUNTIME DESTINATION bin)
# ##########################################################################
#
# Half dynamically linked target - tiktaktoe library must be dlopened
#
# ##########################################################################
add_executable(tiktaktoe-half tiktaktoe.cpp)
target_compile_definitions(tiktaktoe-half PRIVATE LINK_WEBSOCKET_STATIC)
target_include_directories(
tiktaktoe-half PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(
tiktaktoe-half
PUBLIC snodec::http-server-express snodec::websocket-server
snodec::net-in-stream-legacy snodec::net-in-stream-tls
)
set_target_properties(
tiktaktoe-half
PROPERTIES
INSTALL_RPATH
"${WEBSOCKET_SUBPROTOCOL_INSTALL_LIBDIR}"
)
install(TARGETS tiktaktoe-half RUNTIME DESTINATION bin)
# ##########################################################################
#
# Non linked target - websocket and tiktaktoe libraries must be dlopened
#
# ##########################################################################
add_executable(tiktaktoe tiktaktoe.cpp)
target_compile_definitions(tiktaktoe PRIVATE)
target_include_directories(tiktaktoe PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(
tiktaktoe PUBLIC snodec::http-server-express
snodec::net-in-stream-legacy snodec::net-in-stream-tls
)
install(TARGETS tiktaktoe RUNTIME DESTINATION bin)
# ##########################################################################
#
# Custom targets: format and uninstall
#
# ##########################################################################
add_custom_target(format DEPENDS format-cmds)
add_custom_command(
OUTPUT format-cmds
COMMENT "Auto formatting of all source and all cmake files"
)
include("cmake/clang-cpp-checks.cmake")
include("cmake/cmake-format.cmake")
add_custom_target(
uninstall
COMMAND sudo xargs rm -v < install_manifest.txt
COMMAND sudo xargs -L1 dirname < install_manifest.txt | sort | uniq |
sudo xargs rmdir -v --ignore-fail-on-non-empty -p
COMMENT "Uninstall project"
)
endif(snodec_FOUND)
# xargs rm < install_manifest.txt 140