This repository was archived by the owner on Aug 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
253 lines (210 loc) · 6.56 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#######################################################################
#
# General
#
########################################################################
# CMake minimum version
cmake_minimum_required(VERSION 2.8)
# Project name
project(BriocheBot)
# Default build type is debug
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif()
# Setup some folders
set(SRC_DIR "${CMAKE_SOURCE_DIR}/src")
set(RES_DIR "${CMAKE_SOURCE_DIR}/data")
set(LIB_DIR "${CMAKE_SOURCE_DIR}/lib")
set(BIN_DIR "${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}")
# Change CMake module path
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Change CMake output path
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BIN_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BIN_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BIN_DIR}/bin")
# Setup CMake compilation flags
set(CMAKE_C_FLAGS "-std=gnu89")
set(CMAKE_CXX_FLAGS "-std=c++0x")
# Add some definitions on windows
if(WIN32)
add_definitions("-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600")
endif()
########################################################################
#
# hiredis
#
########################################################################
# Get hiredis directory
set(HIREDIS_DIR "${LIB_DIR}/hiredis")
# Include hiredis directory
include_directories("${HIREDIS_DIR}")
# Get hiredis sources
file(GLOB_RECURSE HIREDIS_SRC "${HIREDIS_DIR}/*.[ch]")
########################################################################
#
# jsoncpp
#
########################################################################
# Get jsoncpp directory
set(JSONCPP_DIR "${LIB_DIR}/jsoncpp")
# Include jsoncpp directory
include_directories("${JSONCPP_DIR}")
# Get jsoncpp sources
file(GLOB_RECURSE JSONCPP_SRC "${JSONCPP_DIR}/*.h" "${JSONCPP_DIR}/*.cpp")
########################################################################
#
# HappyHttp
#
########################################################################
# Get happyhttp directory
set(HAPPYHTTP_DIR "${LIB_DIR}/happyhttp")
# Include happyhttp directory
include_directories("${HAPPYHTTP_DIR}")
# Get happyhttp sources
file(GLOB_RECURSE HAPPYHTTP_SRC "${HAPPYHTTP_DIR}/*.cpp" "${HAPPYHTTP_DIR}/*.h")
########################################################################
#
# libuv
#
########################################################################
# Get libuv directory
set(LIBUV_DIR "${LIB_DIR}/libuv")
# Include libuv directory
include_directories("${LIBUV_DIR}")
# Platform specific directives
if(WIN32)
# Include win directory on windows
include_directories("${LIBUV_DIR}/win")
# Include sources in src and src/win directories
file(GLOB LIBUV_SRC "${LIBUV_DIR}/*.[ch]" "${LIBUV_DIR}/win/*.[ch]")
else()
# Include unix directory on unix
include_directories("${LIBUV_DIR}/unix")
# Include sources in src and src/unix directories
file(GLOB LIBUV_SRC "${LIBUV_DIR}/*.[ch]" "${LIBUV_DIR}/unix/*.[ch]")
endif()
########################################################################
#
# Lua
#
########################################################################
# Get lua directory
set(LUA_DIR "${LIB_DIR}/lua")
# Include lua directory
include_directories("${LUA_DIR}")
# Get lua sources
file(GLOB_RECURSE LUA_SRC "${LUA_DIR}/*.[ch]")
########################################################################
#
# Sources
#
########################################################################
# Header folder
include_directories("${SRC_DIR}")
# Executable name
set(EXECUTABLE "BriocheBot")
# Extra executable name
set(EXTRA "BriocheBotExtra")
# Get sources
file(GLOB_RECURSE EXECUTABLE_SOURCES
"${SRC_DIR}/ini/*.[hc]"
"${SRC_DIR}/ini/*.cc"
"${SRC_DIR}/irc/*.h"
"${SRC_DIR}/irc/*.cc"
"${SRC_DIR}/lua/*.h"
"${SRC_DIR}/lua/*.cc"
"${SRC_DIR}/models/*.h"
"${SRC_DIR}/models/*.cc"
"${SRC_DIR}/osu/*.h"
"${SRC_DIR}/osu/*.cc"
"${SRC_DIR}/scripts/*.h"
"${SRC_DIR}/scripts/*.cc"
"${SRC_DIR}/server/*.h"
"${SRC_DIR}/server/*.cc"
"${SRC_DIR}/utils/*.h"
"${SRC_DIR}/utils/*.cc"
"${SRC_DIR}/uv/*.h"
"${SRC_DIR}/uv/*.cc"
"${SRC_DIR}/main.cc"
)
# Get extra executable sources
file(GLOB_RECURSE EXTRA_SOURCES
"${SRC_DIR}/ini/*.[hc]"
"${SRC_DIR}/ini/*.cc"
"${SRC_DIR}/irc/*.h"
"${SRC_DIR}/irc/*.cc"
"${SRC_DIR}/lua/*.h"
"${SRC_DIR}/lua/*.cc"
"${SRC_DIR}/models/*.h"
"${SRC_DIR}/models/*.cc"
"${SRC_DIR}/osu/*.h"
"${SRC_DIR}/osu/*.cc"
"${SRC_DIR}/scripts/*.h"
"${SRC_DIR}/scripts/*.cc"
"${SRC_DIR}/server/*.h"
"${SRC_DIR}/server/*.cc"
"${SRC_DIR}/utils/*.h"
"${SRC_DIR}/utils/*.cc"
"${SRC_DIR}/uv/*.h"
"${SRC_DIR}/uv/*.cc"
"${SRC_DIR}/extra.cc"
)
# Add executable
add_executable(${EXECUTABLE}
${LIBIRCCLIENT_SRC}
${HIREDIS_SRC}
${JSONCPP_SRC}
${HAPPYHTTP_SRC}
${LIBUV_SRC}
${LUA_SRC}
${EXECUTABLE_SOURCES}
)
# Add the extra executable
add_executable(${EXTRA}
${LIBIRCCLIENT_SRC}
${HIREDIS_SRC}
${JSONCPP_SRC}
${HAPPYHTTP_SRC}
${LIBUV_SRC}
${LUA_SRC}
${EXTRA_SOURCES}
)
# If we're building on windows
if(WIN32)
# Add the -mconsole compilation flag
set_target_properties(${EXECUTABLE} PROPERTIES COMPILE_FLAGS "-mconsole")
set_target_properties(${EXTRA} PROPERTIES COMPILE_FLAGS "-mconsole")
# Else, if we're building on unix
elseif(UNIX)
# Add the pthread flag
set_target_properties(${EXECUTABLE} PROPERTIES COMPILE_FLAGS "-pthread")
set_target_properties(${EXTRA} PROPERTIES COMPILE_FLAGS "-pthread")
endif()
########################################################################
#
# Other libraries
#
########################################################################
# If compiling on windows
if(WIN32)
# Link with windows libraries
target_link_libraries(${EXECUTABLE} "ws2_32")
target_link_libraries(${EXECUTABLE} "wldap32")
target_link_libraries(${EXECUTABLE} "iphlpapi")
target_link_libraries(${EXECUTABLE} "psapi")
target_link_libraries(${EXECUTABLE} "userenv")
# Link the extra executable with windows libraries
target_link_libraries(${EXTRA} "ws2_32")
target_link_libraries(${EXTRA} "wldap32")
target_link_libraries(${EXTRA} "iphlpapi")
target_link_libraries(${EXTRA} "psapi")
target_link_libraries(${EXTRA} "userenv")
# Else, if unix
elseif(UNIX)
# Link with unix libraries
target_link_libraries(${EXECUTABLE} "dl")
target_link_libraries(${EXECUTABLE} "pthread")
# Link the extra executable with unix libraries
target_link_libraries(${EXTRA} "dl")
target_link_libraries(${EXTRA} "pthread")
endif()