forked from SpectrumIM/spectrum2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
506 lines (440 loc) · 14.2 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
cmake_minimum_required(VERSION 2.6)
project(libtransport)
message(STATUS "Variables to override default places where to find libraries:")
message(STATUS "|- cppunit : -DCPPUNIT_INCLUDE_DIR, -DCPPUNIT_LIBRARY")
message(STATUS "|- swiften : -DSWIFTEN_INCLUDE_DIR, -DSWIFTEN_LIBRARY")
message(STATUS " |- zlib : -DZLIB_LIBRARY")
message(STATUS " |- expat : -DEXPAT_LIBRARY")
message(STATUS " |-libidn : -DLIBIDN_LIBRARY")
message(STATUS " |-libxml : -DLIBXML_LIBRARY")
message(STATUS "|- boost : -DBOOST_INCLUDEDIR, -DBOOST_LIBRARYDIR")
message(STATUS "|- protobuf: -DPROTOBUF_INCLUDE_DIR, -DPROTOBUF_LIBRARY")
message(STATUS " : -DPROTOBUF_PROTOC_EXECUTABLE")
message(STATUS "|- log4cxx : -DLOG4CXX_INCLUDE_DIR, -DLOG4CXX_LIBRARY")
message(STATUS "|- purple : -DPURPLE_INCLUDE_DIR, -DPURPLE_LIBRARY")
message(STATUS " : -DPURPLE_NOT_RUNTIME - enables compilation with libpurple.lib")
option(ENABLE_SQLITE3 "Build with SQLite3 support" ON)
option(ENABLE_MYSQL "Build with MySQL support" ON)
option(ENABLE_PQXX "Build with Postgres supoort" ON)
option(ENABLE_FROTZ "Build Frotz plugin" ON)
option(ENABLE_IRC "Build IRC plugin" ON)
option(ENABLE_PURPLE "Build Libpurple plugin" ON)
option(ENABLE_SMSTOOLS3 "Build SMSTools3 plugin" ON)
option(ENABLE_SKYPE "Build Skype plugin" ON)
option(ENABLE_SWIFTEN "Build Swiften plugin" ON)
option(ENABLE_TWITTER "Build Twitter plugin" ON)
option(ENABLE_YAHOO2 "Build Libyahoo2 plugin" ON)
option(ENABLE_DOCS "Build Docs" ON)
option(ENABLE_LOG "Build with logging using Log4cxx" ON)
option(ENABLE_TESTS "Build Tests using CppUnit" OFF)
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
IF (${value} STREQUAL ${value2})
SET(${var} TRUE)
ENDIF (${value} STREQUAL ${value2})
ENDFOREACH (value2)
ENDMACRO(LIST_CONTAINS)
if(NOT LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR "lib")
endif()
set(CMAKE_MODULE_PATH "cmake_modules")
###### Prerequisites ######
# FIND SWIFTEN
set(Swiften_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(Swiften)
if(NOT SWIFTEN_FOUND)
if (ZLIB_LIBRARY)
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} ${ZLIB_LIBRARY})
endif()
if (EXPAT_LIBRARY)
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} ${EXPAT_LIBRARY})
endif()
if (LIBIDN_LIBRARY)
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} ${LIBIDN_LIBRARY})
endif()
if (LIBXML_LIBRARY)
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} ${LIBXML_LIBRARY})
endif()
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Dnsapi")
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Crypt32")
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Secur32")
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Iphlpapi")
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Winscard")
message(STATUS "Using swiften: ${SWIFTEN_INCLUDE_DIR} ${SWIFTEN_LIBRARY}")
endif()
# FIND BOOST
set(Boost_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
if (WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals REQUIRED)
else(WIN32)
LIST_CONTAINS(contains -lboost_program_options ${SWIFTEN_LIBRARY})
if(contains)
message(STATUS "Using non-multithreaded boost")
set(Boost_USE_MULTITHREADED 0)
endif(contains)
set(Boost_FIND_QUIETLY ON)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread-mt signals)
if (NOT Boost_FOUND)
set(Boost_FIND_QUIETLY OFF)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals REQUIRED)
endif()
endif(WIN32)
message( STATUS "Found Boost: ${Boost_LIBRARIES}, ${Boost_INCLUDE_DIR}")
# FIND POPT
if (NOT WIN32)
set(popt_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(popt REQUIRED)
endif()
###### Database ######
# FIND SQLITE3
if (ENABLE_SQLITE3)
if (NOT CMAKE_COMPILER_IS_GNUCXX)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/msvc-deps/sqlite3)
else()
if (WIN32)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/msvc-deps/sqlite3)
else()
set(sqlite3_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(sqlite3)
endif()
endif()
endif()
# FIND MYSQL
if(ENABLE_MYSQL)
set(mysql_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(mysql)
endif()
# FIND PQXX
if(ENABLE_PQXX)
set(pqxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(pqxx)
endif()
###### Plugins ######
# FIND LIBPURPLE
if(ENABLE_PURPLE)
set(purple_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(purple)
if (WIN32)
if (PURPLE_NOT_RUNTIME)
add_definitions(-DPURPLE_RUNTIME=0)
else(PURPLE_NOT_RUNTIME)
add_definitions(-DPURPLE_RUNTIME=1)
endif(PURPLE_NOT_RUNTIME)
else()
add_definitions(-DPURPLE_RUNTIME=0)
endif()
# FIND LIBEVENT
set(event_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(event)
endif()
# FIND GLIB
if(ENABLE_SKYPE OR ENABLE_PURPLE)
# if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
# set(GLIB2_FOUND TRUE)
# else()
set(glib_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(glib)
# endif()
endif()
# FIND LIBXML2
# set(libxml2_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
# find_package(libxml2)
# FIND PROTOBUF
set(Protobuf_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(Protobuf REQUIRED)
if (NOT PROTOBUF_FOUND AND PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY)
set(PROTOBUF_FOUND 1)
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
if (PROTOBUF_PROTOC_EXECUTABLE)
else()
set(PROTOBUF_PROTOC_EXECUTABLE protoc)
endif()
message(STATUS "Using protobuf: ${PROTOBUF_INCLUDE_DIRS} ${PROTOBUF_LIBRARY}")
endif()
if (WIN32)
add_definitions(-DSWIFTEN_STATIC=1)
ADD_DEFINITIONS(-D_UNICODE)
ADD_DEFINITIONS(-DUNICODE)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(openssl_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(openssl)
endif()
if(ENABLE_IRC)
set(Communi_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(Communi)
INCLUDE(FindQt4)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtNetwork)
# ADD_DEFINITIONS(${SWIFTEN_CFLAGS})
ADD_DEFINITIONS(-DSUPPORT_LEGACY_CAPS)
# ADD_DEFINITIONS(-DBOOST_FILESYSTEM_VERSION=2)
endif()
set(event_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(event)
if (NOT WIN32 AND ENABLE_SKYPE)
set(dbus_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(dbus)
endif()
if(ENABLE_YAHOO2)
set(yahoo2_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(yahoo2)
endif()
####### Miscallanous ######
if(ENABLE_DOCS)
find_package(Doxygen)
endif()
if(ENABLE_LOG)
if(LOG4CXX_INCLUDE_DIR AND LOG4CXX_LIBRARY)
set(LOG4CXX_LIBRARIES ${LOG4CXX_LIBRARY})
set(LOG4CXX_FOUND 1)
message(STATUS "Using log4cxx: ${CPPUNIT_INCLUDE_DIR} ${LOG4CXX_INCLUDE_DIR}")
else()
set(log4cxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(log4cxx)
endif()
endif()
# FIND CPPUNIT
if(ENABLE_TESTS)
set(cppunit_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(cppunit)
if(NOT CPPUNIT_FOUND AND CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)
set(CCPUNIT_LIBRARIES ${CPPUNIT_LIBRARY})
set(CPPUNIT_FOUND 1)
message(STATUS "Using cppunit: ${CPPUNIT_INCLUDE_DIR} ${CPPUNIT_LIBRARIES}")
endif()
endif()
message(" Supported features")
message("-----------------------")
if (SPECTRUM_VERSION)
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
else (SPECTRUM_VERSION)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
if (NOT GIT_EXECUTABLE)
set (GIT_EXECUTABLE git)
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" rev-parse --short HEAD
OUTPUT_VARIABLE GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(SPECTRUM_VERSION 2.0.0-beta-git-${GIT_REVISION})
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
set(SPECTRUM_VERSION 2.0.0-alpha)
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
endif (SPECTRUM_VERSION)
message("Version : " ${SPECTRUM_VERSION})
if (SQLITE3_FOUND)
ADD_DEFINITIONS(-DWITH_SQLITE)
include_directories(${SQLITE3_INCLUDE_DIR})
message("SQLite3 : yes")
else (SQLITE3_FOUND)
if (WIN32)
ADD_DEFINITIONS(-DWITH_SQLITE)
include_directories("${CMAKE_SOURCE_DIR}/msvc-deps/sqlite3")
message("SQLite3 : bundled")
else()
set(SQLITE3_LIBRARIES "")
if(ENABLE_SQLITE3)
message("SQLite3 : no (install sqlite3)")
else(ENABLE_SQLITE3)
message("SQLite3 : no (user disabled)")
endif()
endif()
endif (SQLITE3_FOUND)
if (MYSQL_FOUND)
ADD_DEFINITIONS(-DWITH_MYSQL)
include_directories(${MYSQL_INCLUDE_DIR})
message("MySQL : yes")
else (MYSQL_FOUND)
set(MYSQL_LIBRARIES "")
if(ENABLE_MYSQL)
message("MySQL : no (install mysql-devel)")
else(ENABLE_MYSQL)
message("MySQL : no (user disabled)")
endif()
endif (MYSQL_FOUND)
if (PQXX_FOUND)
ADD_DEFINITIONS(-DWITH_PQXX)
include_directories(${PQXX_INCLUDE_DIR})
message("PostgreSQL : yes")
else (PQXX_FOUND)
set(PQXX_LIBRARY "")
set(PQ_LIBRARY "")
if(ENABLE_PQXX)
message("PostgreSQL : no (install libpqxx-devel)")
else(ENABLE_PQXX)
message("PostgreSQL : no (user disabled)")
endif()
endif (PQXX_FOUND)
if (PROTOBUF_FOUND)
ADD_DEFINITIONS(-DWITH_PROTOBUF)
include_directories(${PROTOBUF_INCLUDE_DIRS})
message("Network plugins : yes")
if(PURPLE_FOUND)
message("Libpurple plugin : yes")
include_directories(${PURPLE_INCLUDE_DIR})
include_directories(${GLIB2_INCLUDE_DIR})
else()
if(ENABLE_PURPLE)
message("Libpurple plugin : no (install libpurple)")
else(ENABLE_PURPLE)
message("Libpurple plugin : no (user disabled)")
endif()
endif()
if (HAVE_EVENT)
ADD_DEFINITIONS(-DWITH_LIBEVENT)
include_directories(${EVENT_INCLUDE_DIRS})
message(" libev eventloop : yes")
else()
if(ENABLE_PURPLE)
message(" libev eventloop : no (install libev-devel)")
endif()
endif()
if(IRC_FOUND)
ADD_DEFINITIONS(-DCOMMUNI_SHARED)
message("IRC plugin : yes")
include_directories(${QT_QTNETWORK_INCLUDE_DIR})
include_directories(${IRC_INCLUDE_DIR})
include(${QT_USE_FILE})
else()
if(ENABLE_IRC)
message("IRC plugin : no (install libCommuni and libprotobuf-dev)")
else(ENABLE_IRC)
message("IRC plugin : no (user disabled)")
endif()
endif()
if(ENABLE_TWITTER)
message("Twitter plugin : yes")
else(ENABLE_TWITTER)
message("Twitter plugin : no (user disabled)")
endif()
if (NOT WIN32)
if(ENABLE_FROTZ)
message("Frotz plugin : yes")
else()
message("Frotz plugin : no (user disabled)")
endif()
if(ENABLE_SMSTOOLS3)
message("SMSTools3 plugin : yes")
else()
message("SMSTools3 plugin : no (user disabled)")
endif()
if(${LIBDBUSGLIB_FOUND})
message("Skype plugin : yes")
include_directories(${LIBDBUSGLIB_INCLUDE_DIRS})
else()
if(ENABLE_SKYPE)
message("Skype plugin : no (install dbus-glib-devel)")
else(ENABLE_SKYPE)
message("Skype plugin : no (user disabled)")
endif()
endif()
else()
message("Frotz plugin : no (does not run on Win32)")
message("SMSTools3 plugin : no (does not run on Win32)")
message("Skype plugin : no (does not run on Win32)")
endif()
if(YAHOO2_FOUND)
message("Libyahoo2 plugin : yes")
include_directories(${YAHOO2_INCLUDE_DIR})
else()
if(ENABLE_YAHOO2)
message("Libyahoo2 plugin : no (install libyahoo2-devel)")
else(ENABLE_YAHOO2)
message("Libyahoo2 plugin : no (user disabled)")
endif()
endif()
if(ENABLE_SWIFTEN)
message("Swiften plugin : yes")
else()
message("Swiften plugin : no (user disabled)")
endif()
else()
message("Network plugins : no (install libprotobuf-dev)")
message("Libpurple plugin : no (install libpurple and libprotobuf-dev)")
message("IRC plugin : no (install libircclient-qt and libprotobuf-dev)")
message("Frotz plugin : no (install libprotobuf-dev)")
message("SMSTools3 plugin : no (install libprotobuf-dev)")
message("Swiften plugin : no (install libprotobuf-dev)")
message("Twitter plugin : no (install libprotobuf-dev)")
endif()
if (LOG4CXX_FOUND)
message("Log4cxx : yes")
include_directories(${LOG4CXX_INCLUDE_DIR})
ADD_DEFINITIONS(-DWITH_LOG4CXX)
else()
set(LOG4CXX_LIBRARIES "")
if(ENABLE_LOG)
message("Log4cxx : no (install log4cxx-devel)")
else(ENABLE_LOG)
message("Log4cxx : no (user disabled)")
endif()
endif()
if (WIN32)
ADD_DEFINITIONS(-DLOG4CXX_STATIC)
ADD_DEFINITIONS(-D_WIN32_WINNT=0x501)
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
ADD_DEFINITIONS(-DBOOST_USE_WINDOWS_H)
ADD_DEFINITIONS(-DBOOST_THREAD_USE_LIB)
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
if (CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-O0)
ADD_DEFINITIONS(-ggdb)
endif()
ADD_DEFINITIONS(-DDEBUG)
message("Debug : yes")
else(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug : no (run \"cmake . -DCMAKE_BUILD_TYPE=Debug\")")
endif(CMAKE_BUILD_TYPE MATCHES Debug)
SET(TRANSPORT_VERSION 2.0)
SET(PROJECT_VERSION 2.0)
include_directories(include)
include_directories(${EVENT_INCLUDE_DIRS})
include_directories(${SWIFTEN_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS})
if (CMAKE_COMPILER_IS_GNUCXX)
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(plugin)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(spectrum)
ADD_SUBDIRECTORY(backends)
if (NOT WIN32)
ADD_SUBDIRECTORY(spectrum_manager)
# ADD_SUBDIRECTORY(spectrum2_send_message)
endif()
if (CPPUNIT_FOUND)
message("tests : yes")
include_directories(${CPPUNIT_INCLUDE_DIR})
else()
if(ENABLE_TESTS)
message("tests : no (install CPPUnit)")
else(ENABLE_TESTS)
message("tests : no (user disabled)")
endif()
endif()
if(DOXYGEN_FOUND)
message("Docs : yes")
ADD_SUBDIRECTORY(docs)
else(DOXYGEN_FOUND)
if(ENABLE_DOCS)
message("Docs : no (install doxygen)")
else(ENABLE_DOCS)
message("Docs : no (user disabled)")
endif()
endif(DOXYGEN_FOUND)
message("----------------------")
if(NOT SQLITE3_FOUND AND NOT MYSQL_FOUND AND NOT PQXX_FOUND)
if(ENABLE_SQLITE3 OR ENABLE_MYSQL OR ENABLE_PQXX)
message("Could not find any database - Please install at least one of sqlite3-devel, mysql-devel or pqxx-devel if you want to use transport mode.")
else(ENABLE_SQLITE3 OR ENABLE_MYSQL OR ENABLE_PQXX)
message("Please enable at least one of SQLITE3, MYSQL, PQXX databases to use transport mode.")
endif()
endif()