CMakeLists.txt 5.84 KB
Newer Older
Ronan's avatar
Ronan committed
1
# ==============================================================================
2
# CMakeLists.txt
Ronan's avatar
Ronan committed
3
# ==============================================================================
4

Ronan's avatar
Ronan committed
5
cmake_minimum_required(VERSION 3.1)
Ronan's avatar
Ronan committed
6 7
project(linphone)

8
set(LINPHONE_EXEC linphone-qt)
9
set(CMAKE_CXX_STANDARD 11)
Ronan's avatar
Ronan committed
10 11 12 13 14

# Use automatically moc from Qt5.
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

Ronan's avatar
Ronan committed
15
set(CUSTOM_FLAGS "\
Ronan's avatar
Ronan committed
16
-Wall \
Ronan's avatar
Ronan committed
17 18
-Wcast-align \
-Wconversion \
Ronan's avatar
Ronan committed
19
-Werror=suggest-override \
Ronan's avatar
Ronan committed
20 21 22 23 24
-Wextra \
-Wfloat-equal \
-Winit-self \
-Winline \
-Wlogical-op \
Ronan's avatar
Ronan committed
25
-Wold-style-cast \
Ronan's avatar
Ronan committed
26 27
-Woverloaded-virtual \
-Wpointer-arith \
Ronan's avatar
Ronan committed
28
-Wsuggest-override \
Ronan's avatar
Ronan committed
29 30 31 32
-Wuninitialized \
-Wunused \
")
set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${CUSTOM_FLAGS}")
33
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG")
Ronan's avatar
Ronan committed
34

Ronan's avatar
Ronan committed
35 36 37
# ------------------------------------------------------------------------------
# Define packages, libs, sources, headers, resources and languages.
# ------------------------------------------------------------------------------
38

39
set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2 LinguistTools)
Ronan's avatar
Ronan committed
40

41 42 43 44 45 46 47 48
set(LIBS)
foreach (package ${QT5_PACKAGES})
  # `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 LIBS "Qt5::${package}")
  endif ()
endforeach ()
Ronan's avatar
Ronan committed
49

50 51
find_package(Linphone REQUIRED)

Ronan's avatar
Ronan committed
52 53
list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/liblinphone++.so")

Ronan's avatar
Ronan committed
54
set(SOURCES
55
  src/app/App.cpp
56
  src/app/AvatarProvider.cpp
Ronan's avatar
Ronan committed
57
  src/app/DefaultTranslator.cpp
58
  src/app/Logger.cpp
Ronan's avatar
Ronan committed
59
  src/app/Paths.cpp
60
  src/app/ThumbnailProvider.cpp
61
  src/components/camera/Camera.cpp
Ronan's avatar
Ronan committed
62 63
  src/components/call/CallModel.cpp
  src/components/calls/CallsListModel.cpp
64
  src/components/chat/ChatModel.cpp
Ronan's avatar
Ronan committed
65
  src/components/chat/ChatProxyModel.cpp
66
  src/components/contact/ContactObserver.cpp
Ronan's avatar
Ronan committed
67 68
  src/components/contact/ContactModel.cpp
  src/components/contact/VcardModel.cpp
Ronan's avatar
Ronan committed
69 70
  src/components/contacts/ContactsListModel.cpp
  src/components/contacts/ContactsListProxyModel.cpp
Ronan's avatar
Ronan committed
71
  src/components/core/CoreHandlers.cpp
Ronan's avatar
Ronan committed
72
  src/components/core/CoreManager.cpp
Ronan's avatar
Ronan committed
73
  src/components/notifier/Notifier.cpp
Ronan's avatar
Ronan committed
74 75
  src/components/settings/AccountSettingsModel.cpp
  src/components/settings/SettingsModel.cpp
76
  src/components/sip-addresses/SipAddressesModel.cpp
77
  src/components/smart-search-bar/SmartSearchBarModel.cpp
Ronan's avatar
Ronan committed
78
  src/components/timeline/TimelineModel.cpp
Ronan's avatar
Ronan committed
79 80 81 82
  src/main.cpp
)

set(HEADERS
83
  src/app/App.hpp
84
  src/app/AvatarProvider.hpp
Ronan's avatar
Ronan committed
85
  src/app/DefaultTranslator.hpp
86
  src/app/Logger.hpp
Ronan's avatar
Ronan committed
87
  src/app/Paths.hpp
88
  src/app/ThumbnailProvider.hpp
89
  src/components/camera/Camera.hpp
Ronan's avatar
Ronan committed
90 91
  src/components/call/CallModel.hpp
  src/components/calls/CallsListModel.hpp
92
  src/components/chat/ChatModel.hpp
Ronan's avatar
Ronan committed
93
  src/components/chat/ChatProxyModel.hpp
94
  src/components/contact/ContactObserver.hpp
Ronan's avatar
Ronan committed
95 96
  src/components/contact/ContactModel.hpp
  src/components/contact/VcardModel.hpp
Ronan's avatar
Ronan committed
97 98
  src/components/contacts/ContactsListModel.hpp
  src/components/contacts/ContactsListProxyModel.hpp
Ronan's avatar
Ronan committed
99
  src/components/core/CoreHandlers.hpp
Ronan's avatar
Ronan committed
100
  src/components/core/CoreManager.hpp
Ronan's avatar
Ronan committed
101
  src/components/notifier/Notifier.hpp
Ronan's avatar
Ronan committed
102 103 104
  src/components/presence/Presence.hpp
  src/components/settings/AccountSettingsModel.hpp
  src/components/settings/SettingsModel.hpp
105
  src/components/sip-addresses/SipAddressesModel.hpp
106
  src/components/smart-search-bar/SmartSearchBarModel.hpp
Ronan's avatar
Ronan committed
107
  src/components/timeline/TimelineModel.hpp
Ronan's avatar
Ronan committed
108
  src/utils.hpp
Ronan's avatar
Ronan committed
109 110
)

Ronan's avatar
Ronan committed
111
set(QRC_RESOURCES resources.qrc)
112

Ronan's avatar
Ronan committed
113
set(LANGUAGES_DIRECTORY assets/languages)
114
set(I18N_FILENAME i18n.qrc)
115 116
set(LANGUAGES en fr)

Ronan's avatar
Ronan committed
117
# ------------------------------------------------------------------------------
118

119 120
function (PREPEND list prefix)
  set(new_list "")
121

122 123 124
  foreach (elem ${${list}})
    list(APPEND new_list "${prefix}${elem}")
  endforeach ()
125

126 127 128 129 130 131
  set(${list} ${new_list} PARENT_SCOPE)
endfunction ()

# Force absolute paths.
PREPEND(SOURCES "${CMAKE_SOURCE_DIR}/")
PREPEND(HEADERS "${CMAKE_SOURCE_DIR}/")
132
PREPEND(QRC_RESOURCES "${CMAKE_SOURCE_DIR}/")
133

Ronan's avatar
Ronan committed
134
# ------------------------------------------------------------------------------
135
# Compute QML files list.
Ronan's avatar
Ronan committed
136
# ------------------------------------------------------------------------------
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154

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]*(.+\\.qml)[ \t]*<[ \t]*/[ \t]*file[ \t]*>[ \t]*$"
    "\\1"
    result
    ${line})
  string(REGEX MATCH "qml$" isQml ${result})
  if (NOT ${isQml} STREQUAL "")
    list(APPEND QML_SOURCES "${CMAKE_SOURCE_DIR}/${result}")
  endif ()
endforeach ()

add_custom_target(
  check_qml DEPENDS ${QML_SOURCES}
155
  COMMAND "${CMAKE_SOURCE_DIR}/tools/check_qml_syntax"
156 157
)

Ronan's avatar
Ronan committed
158
# ------------------------------------------------------------------------------
159
# Init git hooks.
Ronan's avatar
Ronan committed
160
# ------------------------------------------------------------------------------
161 162 163 164 165 166

execute_process(COMMAND ${CMAKE_COMMAND} -E copy
  "${CMAKE_SOURCE_DIR}/tools/private/pre-commit"
  "${CMAKE_SOURCE_DIR}/../.git/hooks/pre-commit"
)

Ronan's avatar
Ronan committed
167
# ------------------------------------------------------------------------------
168
# Build.
Ronan's avatar
Ronan committed
169
# ------------------------------------------------------------------------------
170 171

find_package(Qt5 COMPONENTS ${QT5_PACKAGES})
172

173 174 175
# Add languages support.
add_subdirectory(${LANGUAGES_DIRECTORY})
list(APPEND QRC_RESOURCES "${CMAKE_BINARY_DIR}/${LANGUAGES_DIRECTORY}/${I18N_FILENAME}")
176 177

# Add qrc. (images, qml, translations...)
178
qt5_add_resources(RESOURCES ${QRC_RESOURCES})
Ronan's avatar
Ronan committed
179 180

# Build.
181
# Note: `update_translations` is provided by `languages/CMakeLists.txt`.
Ronan's avatar
Ronan committed
182
add_executable(${LINPHONE_EXEC} ${SOURCES} ${HEADERS} ${RESOURCES})
183
add_dependencies(${LINPHONE_EXEC} update_translations)
184
add_dependencies(update_translations check_qml)
Ronan's avatar
Ronan committed
185

186
target_include_directories(${LINPHONE_EXEC} SYSTEM PRIVATE "${LINPHONE_INCLUDE_DIRS}")
Ronan's avatar
Ronan committed
187

188
target_link_libraries(${LINPHONE_EXEC} ${LIBS} ${LINPHONE_LIBRARIES})