-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
472 lines (406 loc) · 16.7 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
################################################################################
# CMakeLists.txt
# Copyright (C) 2017-2018 Belledonne Communications, Grenoble France
#
################################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
################################################################################
cmake_minimum_required(VERSION 3.1)
project(linphoneqt VERSION 4.1.1)
set(APP_LIBRARY app-library)
set(EXECUTABLE_NAME linphone)
set(TESTER_EXECUTABLE_NAME "${EXECUTABLE_NAME}-tester")
set(TARGET_NAME linphone-qt)
set(TESTER_TARGET_NAME "${TARGET_NAME}-tester")
set(CMAKE_CXX_STANDARD 11)
set(ASSETS_DIR assets)
option(ENABLE_DBUS "Enable single instance handling via DBus." NO)
option(ENABLE_UPDATE_CHECK "Enable update check." NO)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
# Use automatically moc from Qt5.
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Avoid cmake warning if CMP0071 is not set.
if (POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
endif ()
if (NOT WIN32)
check_cxx_compiler_flag("-Wsuggest-override" SUGGEST_OVERRIDE)
set(CUSTOM_FLAGS "\
-Wall \
-Wcast-align \
-Wconversion \
-Werror=old-style-cast \
-Werror=return-type \
-Wextra \
-Wfloat-equal \
-Winit-self \
-Wnon-virtual-dtor \
-Woverloaded-virtual \
-Wpointer-arith \
-Wsign-conversion \
-Wuninitialized \
-Wunused \
")
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CUSTOM_FLAGS "${CUSTOM_FLAGS} -Wlogical-op")
endif ()
if (SUGGEST_OVERRIDE)
set(CUSTOM_FLAGS "${CUSTOM_FLAGS} -Wsuggest-override -Werror=suggest-override")
endif ()
endif ()
set(CUSTOM_FLAGS "${CUSTOM_FLAGS} -DQT_NO_EXCEPTIONS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CUSTOM_FLAGS}")
# See: http://stackoverflow.com/a/1372836
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WINSOCKAPI_")
endif ()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -DQT_NO_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG")
# ------------------------------------------------------------------------------
# Define packages, libs, sources, headers, resources and languages.
# ------------------------------------------------------------------------------
set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2 Svg LinguistTools Concurrent Network)
if (ENABLE_DBUS)
list(APPEND QT5_PACKAGES DBus)
endif ()
set(QT5_PACKAGES_OPTIONAL TextToSpeech)
if (LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_linphone_CONFIG_DIR}/wrappers/cpp/LinphoneCxxConfig.cmake")
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
include("${EP_belcard_CONFIG_DIR}/BelcardConfig.cmake")
include("${EP_ms2_CONFIG_DIR}/Mediastreamer2Config.cmake")
else ()
find_package(LinphoneCxx REQUIRED)
find_package(BcToolbox REQUIRED)
find_package(Belcard REQUIRED)
find_package(Mediastreamer2 REQUIRED)
endif ()
set(SOURCES
src/app/App.cpp
src/app/AppController.cpp
src/app/cli/Cli.cpp
src/app/logger/Logger.cpp
src/app/paths/Paths.cpp
src/app/providers/AvatarProvider.cpp
src/app/providers/ImageProvider.cpp
src/app/providers/ThumbnailProvider.cpp
src/app/translator/DefaultTranslator.cpp
src/components/assistant/AssistantModel.cpp
src/components/authentication/AuthenticationNotifier.cpp
src/components/call/CallModel.cpp
src/components/calls/CallsListModel.cpp
src/components/calls/CallsListProxyModel.cpp
src/components/camera/Camera.cpp
src/components/camera/CameraPreview.cpp
src/components/camera/MSFunctions.cpp
src/components/chat/ChatModel.cpp
src/components/chat/ChatProxyModel.cpp
src/components/codecs/AbstractCodecsModel.cpp
src/components/codecs/AudioCodecsModel.cpp
src/components/codecs/VideoCodecsModel.cpp
src/components/conference/ConferenceAddModel.cpp
src/components/conference/ConferenceHelperModel.cpp
src/components/conference/ConferenceModel.cpp
src/components/contact/ContactModel.cpp
src/components/contact/VcardModel.cpp
src/components/contacts/ContactsListModel.cpp
src/components/contacts/ContactsListProxyModel.cpp
src/components/core/CoreHandlers.cpp
src/components/core/CoreManager.cpp
src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.cpp
src/components/notifier/Notifier.cpp
src/components/other/clipboard/Clipboard.cpp
src/components/other/colors/Colors.cpp
src/components/other/text-to-speech/TextToSpeech.cpp
src/components/other/units/Units.cpp
src/components/presence/OwnPresenceModel.cpp
src/components/presence/Presence.cpp
src/components/settings/AccountSettingsModel.cpp
src/components/settings/SettingsModel.cpp
src/components/sip-addresses/SipAddressesModel.cpp
src/components/sip-addresses/SipAddressesProxyModel.cpp
src/components/sip-addresses/SipAddressObserver.cpp
src/components/sound-player/SoundPlayer.cpp
src/components/telephone-numbers/TelephoneNumbersModel.cpp
src/components/timeline/TimelineModel.cpp
src/components/url-handlers/UrlHandlers.cpp
src/utils/LinphoneUtils.cpp
src/utils/Utils.cpp
src/utils/QExifImageHeader.cpp
)
set(HEADERS
src/app/App.hpp
src/app/AppController.hpp
src/app/cli/Cli.hpp
src/app/logger/Logger.hpp
src/app/paths/Paths.hpp
src/app/providers/AvatarProvider.hpp
src/app/providers/ImageProvider.hpp
src/app/providers/ThumbnailProvider.hpp
src/app/single-application/SingleApplication.hpp
src/app/translator/DefaultTranslator.hpp
src/components/assistant/AssistantModel.hpp
src/components/authentication/AuthenticationNotifier.hpp
src/components/call/CallModel.hpp
src/components/calls/CallsListModel.hpp
src/components/calls/CallsListProxyModel.hpp
src/components/camera/Camera.hpp
src/components/camera/CameraPreview.hpp
src/components/camera/MSFunctions.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
src/components/codecs/AbstractCodecsModel.hpp
src/components/codecs/AudioCodecsModel.hpp
src/components/codecs/VideoCodecsModel.hpp
src/components/Components.hpp
src/components/conference/ConferenceAddModel.hpp
src/components/conference/ConferenceHelperModel.hpp
src/components/conference/ConferenceModel.hpp
src/components/contact/ContactModel.hpp
src/components/contact/VcardModel.hpp
src/components/contacts/ContactsListModel.hpp
src/components/contacts/ContactsListProxyModel.hpp
src/components/core/CoreHandlers.hpp
src/components/core/CoreManager.hpp
src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.hpp
src/components/notifier/Notifier.hpp
src/components/other/clipboard/Clipboard.hpp
src/components/other/colors/Colors.hpp
src/components/other/text-to-speech/TextToSpeech.hpp
src/components/other/units/Units.hpp
src/components/presence/OwnPresenceModel.hpp
src/components/presence/Presence.hpp
src/components/settings/AccountSettingsModel.hpp
src/components/settings/SettingsModel.hpp
src/components/sip-addresses/SipAddressesModel.hpp
src/components/sip-addresses/SipAddressesProxyModel.hpp
src/components/sip-addresses/SipAddressObserver.hpp
src/components/sound-player/SoundPlayer.hpp
src/components/telephone-numbers/TelephoneNumbersModel.hpp
src/components/timeline/TimelineModel.hpp
src/components/url-handlers/UrlHandlers.hpp
src/utils/LinphoneUtils.hpp
src/utils/Utils.hpp
src/utils/QExifImageHeader.h
)
set(TESTS
src/tests/assistant-view/AssistantViewTest.cpp
src/tests/assistant-view/AssistantViewTest.hpp
src/tests/main-view/MainViewTest.cpp
src/tests/main-view/MainViewTest.hpp
src/tests/self-test/SelfTest.cpp
src/tests/self-test/SelfTest.hpp
src/tests/TestUtils.cpp
src/tests/TestUtils.hpp
)
set(MAIN_FILE src/app/main.cpp)
set(TESTER_MAIN_FILE src/tests/main.cpp)
if (UNIX AND NOT APPLE)
list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp)
list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp)
endif ()
if (WIN32)
list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierWindows.cpp)
list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierWindows.hpp)
endif ()
if (APPLE)
list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.m)
list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp)
endif ()
if (ENABLE_DBUS)
list(APPEND SOURCES src/app/single-application/SingleApplicationDBus.cpp)
list(APPEND HEADERS src/app/single-application/SingleApplicationDBusPrivate.hpp)
else ()
list(APPEND SOURCES src/app/single-application/SingleApplication.cpp)
list(APPEND HEADERS src/app/single-application/SingleApplicationPrivate.hpp)
endif ()
set(QRC_RESOURCES resources.qrc)
set(LANGUAGES_DIRECTORY "${ASSETS_DIR}/languages")
set(I18N_FILENAME i18n.qrc)
set(LANGUAGES en fr_FR ru tr)
# ------------------------------------------------------------------------------
function (PREPEND list prefix)
set(new_list "")
foreach (elem ${${list}})
list(APPEND new_list "${prefix}${elem}")
endforeach ()
set(${list} ${new_list} PARENT_SCOPE)
endfunction ()
# Force absolute paths.
PREPEND(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/")
PREPEND(HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/")
PREPEND(QRC_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/")
# ------------------------------------------------------------------------------
# Compute QML files list.
# ------------------------------------------------------------------------------
set(QML_SOURCES)
file(STRINGS ${QRC_RESOURCES} QRC_RESOURCES_CONTENT)
foreach (line ${QRC_RESOURCES_CONTENT})
set(result)
string(REGEX REPLACE
"^[ \t]*<[ \t]*file[ \t]*>[ \t]*(.+\\.[a-z]+)[ \t]*<[ \t]*/[ \t]*file[ \t]*>[ \t]*$"
"\\1"
result
"${line}"
)
string(REGEX MATCH "\\.[a-z]+$" is_ui ${result})
if (NOT ${is_ui} STREQUAL "")
list(APPEND QML_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${result}")
endif ()
endforeach ()
# ------------------------------------------------------------------------------
# Init git hooks.
# ------------------------------------------------------------------------------
if (NOT WIN32)
add_custom_target(
check_qml DEPENDS ${QML_SOURCES}
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/tools/check_qml_syntax"
)
endif ()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/tools/private/pre-commit"
"${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit"
)
# ------------------------------------------------------------------------------
# Create config.h file
# ------------------------------------------------------------------------------
set(MSPLUGINS_DIR "${CMAKE_INSTALL_LIBDIR}/mediastreamer/plugins")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
# ------------------------------------------------------------------------------
# Build.
# ------------------------------------------------------------------------------
find_package(Qt5 COMPONENTS ${QT5_PACKAGES} REQUIRED)
find_package(Qt5 COMPONENTS ${QT5_PACKAGES_OPTIONAL} QUIET)
find_package(Qt5 COMPONENTS Test REQUIRED)
if (CMAKE_INSTALL_RPATH)
get_target_property(LUPDATE_PATH Qt5::lupdate LOCATION)
get_filename_component(LUPDATE_PATH "${LUPDATE_PATH}" DIRECTORY)
get_filename_component(QT_PATH "${LUPDATE_PATH}/../lib" ABSOLUTE)
list(APPEND CMAKE_INSTALL_RPATH "${QT_PATH}")
endif ()
# Add languages support.
add_subdirectory(${LANGUAGES_DIRECTORY})
list(APPEND QRC_RESOURCES "${CMAKE_CURRENT_BINARY_DIR}/${LANGUAGES_DIRECTORY}/${I18N_FILENAME}")
# Add qrc. (images, qml, translations...)
qt5_add_resources(RESOURCES ${QRC_RESOURCES})
# Build.
add_library(${APP_LIBRARY} OBJECT ${SOURCES} ${HEADERS} ${RESOURCES} ${QML_SOURCES})
set_property(TARGET ${APP_LIBRARY} PROPERTY POSITION_INDEPENDENT_CODE ON)
bc_git_version(${TARGET_NAME} ${PROJECT_VERSION})
add_dependencies(${APP_LIBRARY} ${TARGET_NAME}-git-version)
add_dependencies(${APP_LIBRARY} update_translations)
if (WIN32)
add_executable(${TARGET_NAME} WIN32 $<TARGET_OBJECTS:${APP_LIBRARY}> assets/linphone.rc ${MAIN_FILE})
add_executable(${TESTER_TARGET_NAME} WIN32 $<TARGET_OBJECTS:${APP_LIBRARY}> assets/linphone.rc ${TESTER_MAIN_FILE} ${TESTS})
else ()
add_executable(${TARGET_NAME} $<TARGET_OBJECTS:${APP_LIBRARY}> ${MAIN_FILE})
add_executable(${TESTER_TARGET_NAME} $<TARGET_OBJECTS:${APP_LIBRARY}> ${TESTER_MAIN_FILE} ${TESTS})
endif ()
if (NOT WIN32)
add_dependencies(update_translations check_qml)
endif ()
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}")
set_target_properties(${TESTER_TARGET_NAME} PROPERTIES OUTPUT_NAME "${TESTER_EXECUTABLE_NAME}")
set(INCLUDED_DIRECTORIES "${LINPHONECXX_INCLUDE_DIRS}" "${BELCARD_INCLUDE_DIRS}" "${BCTOOLBOX_INCLUDE_DIRS}" "${MEDIASTREAMER2_INCLUDE_DIRS}")
set(LIBRARIES ${BCTOOLBOX_CORE_LIBRARIES} ${BELCARD_LIBRARIES} ${LINPHONECXX_LIBRARIES})
foreach (package ${QT5_PACKAGES})
list(APPEND INCLUDED_DIRECTORIES "${Qt5${package}_INCLUDE_DIRS}")
# `qt5_create_translation` is provided from `LinguistTools` package.
# But the `Qt5::LinguistTools` lib does not exist. Remove it.
if (NOT (${package} STREQUAL LinguistTools))
list(APPEND LIBRARIES ${Qt5${package}_LIBRARIES})
endif ()
endforeach ()
foreach (package ${QT5_PACKAGES_OPTIONAL})
if ("${Qt5${package}_FOUND}")
message("Optional package ${package} found.")
list(APPEND INCLUDED_DIRECTORIES "${Qt5${package}_INCLUDE_DIRS}")
list(APPEND LIBRARIES ${Qt5${package}_LIBRARIES})
string(TOUPPER "${package}" INCLUDE_NAME)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${INCLUDE_NAME}_ENABLED")
else ()
message("Optional package ${package} not found.")
endif ()
endforeach ()
if (APPLE)
list(APPEND LIBRARIES "-framework Cocoa")
endif ()
target_include_directories(${APP_LIBRARY} SYSTEM PRIVATE ${INCLUDED_DIRECTORIES})
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${INCLUDED_DIRECTORIES})
target_include_directories(${TESTER_TARGET_NAME} SYSTEM PRIVATE ${INCLUDED_DIRECTORIES})
target_link_libraries(${TARGET_NAME} ${LIBRARIES})
target_link_libraries(${TESTER_TARGET_NAME} ${LIBRARIES} Qt5::Test)
foreach (target ${TARGET_NAME} ${TESTER_TARGET_NAME})
install(TARGETS ${target}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endforeach ()
install(FILES "assets/linphone.desktop"
DESTINATION "${CMAKE_INSTALL_DATADIR}/applications"
)
install(FILES "${ASSETS_DIR}/images/linphone_logo.svg"
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps/"
RENAME "linphone.svg"
)
# ------------------------------------------------------------------------------
# Install rc files.
# ------------------------------------------------------------------------------
install(FILES "${ASSETS_DIR}/linphonerc-factory"
DESTINATION "${CMAKE_INSTALL_DATADIR}/linphone"
)
set(ASSETS_ASSISTANT_DIR "${ASSETS_DIR}/assistant")
set(ASSISTANT_INSTALL_DATADIR "${CMAKE_INSTALL_DATADIR}/linphone/assistant")
install(FILES "${ASSETS_ASSISTANT_DIR}/use-other-sip-account.rc"
DESTINATION "${ASSISTANT_INSTALL_DATADIR}"
)
install(FILES "${ASSETS_ASSISTANT_DIR}/create-linphone-sip-account.rc"
DESTINATION "${ASSISTANT_INSTALL_DATADIR}"
)
install(FILES "${ASSETS_ASSISTANT_DIR}/use-linphone-sip-account.rc"
DESTINATION "${ASSISTANT_INSTALL_DATADIR}"
)
# ------------------------------------------------------------------------------
# CPack settings.
# ------------------------------------------------------------------------------
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES
"^${CMAKE_BINARY_DIR}"
"/\\\\..+"
"OUTPUT"
"WORK"
"cmake_builder"
"submodules"
)
include(CPack)
# ------------------------------------------------------------------------------
# To start better integration into IDE.
# ------------------------------------------------------------------------------
source_group(
"Qml" REGULAR_EXPRESSION ".+\.qml$"
)
source_group(
"Js" REGULAR_EXPRESSION ".+\.js)$"
)
source_group(
"Svg" REGULAR_EXPRESSION ".+\.svg$"
)