-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
266 lines (222 loc) · 6.25 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
254
255
256
257
258
259
260
261
262
263
264
265
266
cmake_minimum_required (VERSION 2.8)
set (PROJECT gpsinformer)
project (${PROJECT})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if (NOT MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
endif ()
if (UNIX OR CYGWIN)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif ()
# Uncomment this if Boost static linking will fail
# add_definitions (-DBOOST_LOG_DYN_LINK)
if (MSVC)
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
endif ()
set (SQLITE3_SOURCES
dep/sqlite3/sqlite3.c
)
set (SQLITE3_HEADERS
dep/sqlite3/include/sqlite3.h
dep/sqlite3/include/sqlite3ext.h
)
set (TGBOT_SOURCES
src/tgbot/TgTypeParser.cpp
)
set (TGBOT_HEADERS
src/tgbot/TgTypeParser.h
)
set (TGBOT_TYPES_SOURCES
src/tgbot/types/InlineQueryResult.cpp
src/tgbot/types/InputFile.cpp
)
set (TGBOT_TYPES_HEADERS
src/tgbot/types/Audio.h
src/tgbot/types/CallbackQuery.h
src/tgbot/types/Chat.h
src/tgbot/types/ChatMember.h
src/tgbot/types/ChosenInlineResult.h
src/tgbot/types/Contact.h
src/tgbot/types/Document.h
src/tgbot/types/File.h
src/tgbot/types/ForceReply.h
src/tgbot/types/GenericReply.h
src/tgbot/types/InlineKeyboardButton.h
src/tgbot/types/InlineKeyboardMarkup.h
src/tgbot/types/InlineQuery.h
src/tgbot/types/InlineQueryResult.h
src/tgbot/types/InlineQueryResultArticle.h
src/tgbot/types/InlineQueryResultAudio.h
src/tgbot/types/InlineQueryResultCachedAudio.h
src/tgbot/types/InlineQueryResultCachedDocument.h
src/tgbot/types/InlineQueryResultCachedGif.h
src/tgbot/types/InlineQueryResultCachedMpeg4Gif.h
src/tgbot/types/InlineQueryResultCachedPhoto.h
src/tgbot/types/InlineQueryResultCachedSticker.h
src/tgbot/types/InlineQueryResultCachedVideo.h
src/tgbot/types/InlineQueryResultCachedVoice.h
src/tgbot/types/InlineQueryResultContact.h
src/tgbot/types/InlineQueryResultDocument.h
src/tgbot/types/InlineQueryResultGame.h
src/tgbot/types/InlineQueryResultGif.h
src/tgbot/types/InlineQueryResultLocation.h
src/tgbot/types/InlineQueryResultMpeg4Gif.h
src/tgbot/types/InlineQueryResultPhoto.h
src/tgbot/types/InlineQueryResultVenue.h
src/tgbot/types/InlineQueryResultVideo.h
src/tgbot/types/InlineQueryResultVoice.h
src/tgbot/types/InputContactMessageContent.h
src/tgbot/types/InputFile.h
src/tgbot/types/InputLocationMessageContent.h
src/tgbot/types/InputMessageContent.h
src/tgbot/types/InputTextMessageContent.h
src/tgbot/types/InputVenueMessageContent.h
src/tgbot/types/KeyboardButton.h
src/tgbot/types/Location.h
src/tgbot/types/Message.h
src/tgbot/types/MessageEntity.h
src/tgbot/types/PhotoSize.h
src/tgbot/types/ReplyKeyboardMarkup.h
src/tgbot/types/ReplyKeyboardRemove.h
src/tgbot/types/ResponseParameters.h
src/tgbot/types/Sticker.h
src/tgbot/types/Update.h
src/tgbot/types/User.h
src/tgbot/types/UserProfilePhotos.h
src/tgbot/types/Venue.h
src/tgbot/types/Video.h
src/tgbot/types/Voice.h
src/tgbot/types/WebhookInfo.h
)
set (SOURCES
src/Application.cpp
src/ApplicationCommands.cpp
src/ApplicationDatabase.cpp
src/ApplicationEvents.cpp
src/ApplicationReceiver.cpp
src/ApplicationTelegram.cpp
src/ApplicationTransmitter.cpp
src/Device.cpp
src/HttpParser.cpp
src/HttpRequest.cpp
src/HttpsClient.cpp
src/Main.cpp
src/SslClient.cpp
src/StdAfx.cpp
src/TcpClient.cpp
src/TcpServer.cpp
src/TcpSession.cpp
src/TelegramBot.cpp
src/Url.cpp
src/Utilities.cpp
)
set (HEADERS
src/Application.h
src/ChatCommand.h
src/Device.h
src/GpsMessage.h
src/HttpClientHandler.h
src/HttpParser.h
src/HttpReqArg.h
src/HttpRequest.h
src/HttpsClient.h
src/SslClient.h
src/StdAfx.h
src/TcpClient.h
src/TcpClientHandler.h
src/TcpServer.h
src/TcpSession.h
src/TcpSessionHandler.h
src/TelegramBot.h
src/TelegramBotHandler.h
src/Url.h
src/User.h
src/UserSettings.h
src/Utilities.h
)
# Threads
find_package (Threads REQUIRED)
# OpenSSL
if (MSVC)
set (MBEDTLS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dep/mbedtls")
find_path(MBEDTLS_INCLUDE_DIR
NAMES mbedtls/ssl.h
PATH_SUFFIXES include
HINTS ${MBEDTLS_ROOT_DIR}
NO_CMAKE_FIND_ROOT_PATH)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (MBEDTLS_LIB_SUFFIX lib64)
else()
set (MBEDTLS_LIB_SUFFIX lib)
endif()
find_library(MBEDTLS_LIBRARY
NAMES mbedtls
PATH_SUFFIXES ${MBEDTLS_LIB_SUFFIX}
HINTS ${MBEDTLS_ROOT_DIR}
NO_CMAKE_FIND_ROOT_PATH)
find_library(MBEDTLS_CRYPTO_LIBRARY
NAMES mbedcrypto
PATH_SUFFIXES ${MBEDTLS_LIB_SUFFIX}
HINTS ${MBEDTLS_ROOT_DIR}
NO_CMAKE_FIND_ROOT_PATH)
find_library(MBEDTLS_X509_LIBRARY
NAMES mbedx509
PATH_SUFFIXES ${MBEDTLS_LIB_SUFFIX}
HINTS ${MBEDTLS_ROOT_DIR}
NO_CMAKE_FIND_ROOT_PATH)
set (MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDTLS_CRYPTO_LIBRARY} ${MBEDTLS_X509_LIBRARY})
set (MBEDTLS_FOUND TRUE)
else ()
find_package (MbedTLS REQUIRED)
endif ()
if(NOT MBEDTLS_FOUND)
message(FATAL_ERROR "mbedTLS libraries not found")
else()
message(STATUS "Found mbedTLS libraries")
endif()
# Boost
set (Boost_USE_MULTITHREADED ON)
set (Boost_USE_STATIC_LIBS ON)
find_package (Boost REQUIRED COMPONENTS system log log_setup date_time thread filesystem program_options REQUIRED)
include_directories (dep/sqlite3/include src)
include_directories (${MBEDTLS_INCLUDE_DIR})
include_directories (${Boost_INCLUDE_DIR})
link_directories (${Boost_LIBRARY_DIRS})
set (LIB_LIST
${LIB_LIST}
${CMAKE_THREAD_LIBS_INIT}
${MBEDTLS_LIBRARIES}
)
# Visual Studio supports auto-linking of Boost Libraries
if (NOT MSVC)
set (LIB_LIST
${LIB_LIST}
${Boost_LIBRARIES}
)
endif ()
if (UNIX AND NOT CYGWIN)
set (LIB_LIST
${LIB_LIST}
-ldl
)
endif ()
set (FULL_SOURCES
${SQLITE3_SOURCES}
${TGBOT_SOURCES}
${TGBOT_TYPES_SOURCES}
${SOURCES}
)
set (FULL_HEADERS
${SQLITE3_HEADERS}
${TGBOT_HEADERS}
${TGBOT_TYPES_HEADERS}
${HEADERS}
)
source_group ("Dependencies\\SQLite 3" FILES ${SQLITE3_SOURCES} ${SQLITE3_HEADERS})
source_group ("Dependencies\\TgBot" FILES ${TGBOT_SOURCES} ${TGBOT_HEADERS})
source_group ("Dependencies\\TgBot\\Types" FILES ${TGBOT_TYPES_SOURCES} ${TGBOT_TYPES_HEADERS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
add_executable (${PROJECT} ${FULL_SOURCES} ${FULL_HEADERS})
target_link_libraries (${PROJECT} ${LIB_LIST})