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

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

set(LINPHONE_EXEC linphone)
9
set(CMAKE_CXX_STANDARD 11)
10 11 12 13 14

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

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

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

38
set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2 LinguistTools)
39

40 41 42 43 44 45 46 47
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 ()
48

Ronan Abhamon's avatar
Ronan Abhamon committed
49
list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/liblinphone.so")
Ronan Abhamon's avatar
Ronan Abhamon committed
50
list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/liblinphone++.so")
51
list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/libbelcard.so")
Ronan Abhamon's avatar
Ronan Abhamon committed
52
list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/libbellesip.so")
Ronan Abhamon's avatar
Ronan Abhamon committed
53
list(APPEND LIBS "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/lib64/libbctoolbox.so")
Ronan Abhamon's avatar
Ronan Abhamon committed
54

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

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

106 107 108 109
set(QRC_RESOURCES
  resources.qrc
)

110
set(LANGUAGES_DIRECTORY assets/languages)
111
set(I18N_FILENAME i18n.qrc)
112 113
set(LANGUAGES en fr)

Ronan Abhamon's avatar
Ronan Abhamon committed
114
# ------------------------------------------------------------------------------
115

116 117
function (PREPEND list prefix)
  set(new_list "")
118

119 120 121
  foreach (elem ${${list}})
    list(APPEND new_list "${prefix}${elem}")
  endforeach ()
122

123 124 125 126 127 128
  set(${list} ${new_list} PARENT_SCOPE)
endfunction ()

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

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

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}
152
  COMMAND "${CMAKE_SOURCE_DIR}/tools/check_qml_syntax"
153 154
)

Ronan Abhamon's avatar
Ronan Abhamon committed
155
# ------------------------------------------------------------------------------
156
# Init git hooks.
Ronan Abhamon's avatar
Ronan Abhamon committed
157
# ------------------------------------------------------------------------------
158 159 160 161 162 163

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

Ronan Abhamon's avatar
Ronan Abhamon committed
164
# ------------------------------------------------------------------------------
165
# Build.
Ronan Abhamon's avatar
Ronan Abhamon committed
166
# ------------------------------------------------------------------------------
167 168

find_package(Qt5 COMPONENTS ${QT5_PACKAGES})
169

170 171 172
# Add languages support.
add_subdirectory(${LANGUAGES_DIRECTORY})
list(APPEND QRC_RESOURCES "${CMAKE_BINARY_DIR}/${LANGUAGES_DIRECTORY}/${I18N_FILENAME}")
173 174

# Add qrc. (images, qml, translations...)
175
qt5_add_resources(RESOURCES ${QRC_RESOURCES})
176 177

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

183
target_include_directories(${LINPHONE_EXEC} SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/../OUTPUT/desktop/include/")
Ronan Abhamon's avatar
Ronan Abhamon committed
184

185
target_link_libraries(${LINPHONE_EXEC} ${LIBS})