CMakeLists.txt 4.32 KB
Newer Older
1 2 3 4
# ====================================================================
# CMakeLists.txt
# ====================================================================

Ronan Abhamon's avatar
Ronan Abhamon committed
5
cmake_minimum_required(VERSION 3.1)
6 7 8 9 10 11 12 13
project(linphone)

set(LINPHONE_EXEC linphone)

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

14 15 16 17
# --------------------------------------------------------------------
# Define packages, libs, sources, headers, resources and languages
# --------------------------------------------------------------------

18
set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2 LinguistTools)
19

20 21 22 23 24 25 26 27
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 ()
28

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

31
set(SOURCES
32
  src/app/App.cpp
Ronan Abhamon's avatar
Ronan Abhamon committed
33
  src/app/Database.cpp
34 35
  src/app/Logger.cpp
  src/components/chat/ChatModel.cpp
36 37 38
  src/components/contacts/ContactModel.cpp
  src/components/contacts/ContactsListModel.cpp
  src/components/contacts/ContactsListProxyModel.cpp
Ronan Abhamon's avatar
Ronan Abhamon committed
39
  src/components/core/CoreManager.cpp
40
  src/components/notifier/Notifier.cpp
41 42
  src/components/settings/AccountSettingsModel.cpp
  src/components/settings/SettingsModel.cpp
43
  src/components/timeline/TimelineModel.cpp
44 45 46 47
  src/main.cpp
)

set(HEADERS
48
  src/app/App.hpp
Ronan Abhamon's avatar
Ronan Abhamon committed
49
  src/app/Database.hpp
50 51
  src/app/Logger.hpp
  src/components/chat/ChatModel.hpp
52 53 54
  src/components/contacts/ContactModel.hpp
  src/components/contacts/ContactsListModel.hpp
  src/components/contacts/ContactsListProxyModel.hpp
Ronan Abhamon's avatar
Ronan Abhamon committed
55
  src/components/core/CoreManager.hpp
56
  src/components/notifier/Notifier.hpp
57 58 59
  src/components/presence/Presence.hpp
  src/components/settings/AccountSettingsModel.hpp
  src/components/settings/SettingsModel.hpp
60
  src/components/timeline/TimelineModel.hpp
Ronan Abhamon's avatar
Ronan Abhamon committed
61
  src/utils.hpp
62 63
)

64 65 66 67
set(QRC_RESOURCES
  resources.qrc
)

68
set(LANGUAGES_DIRECTORY assets/languages)
69
set(I18N_FILENAME i18n.qrc)
70 71 72 73
set(LANGUAGES en fr)

# --------------------------------------------------------------------

74 75
function (PREPEND list prefix)
  set(new_list "")
76

77 78 79
  foreach (elem ${${list}})
    list(APPEND new_list "${prefix}${elem}")
  endforeach ()
80

81 82 83 84 85 86
  set(${list} ${new_list} PARENT_SCOPE)
endfunction ()

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

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
# --------------------------------------------------------------------
# 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]*(.+\\.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}
110
  COMMAND "${CMAKE_SOURCE_DIR}/tools/check_qml_syntax"
111 112
)

113 114 115 116 117 118 119 120 121 122 123
# --------------------------------------------------------------------
# Init git hooks.
# --------------------------------------------------------------------

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

# --------------------------------------------------------------------
# Build.
124 125 126
# --------------------------------------------------------------------

find_package(Qt5 COMPONENTS ${QT5_PACKAGES})
127

128 129 130
# Add languages support.
add_subdirectory(${LANGUAGES_DIRECTORY})
list(APPEND QRC_RESOURCES "${CMAKE_BINARY_DIR}/${LANGUAGES_DIRECTORY}/${I18N_FILENAME}")
131 132

# Add qrc. (images, qml, translations...)
133
qt5_add_resources(RESOURCES ${QRC_RESOURCES})
134 135

# Build.
136
# Note: `update_translations` is provided by `languages/CMakeLists.txt`.
137
add_executable(${LINPHONE_EXEC} ${SOURCES} ${HEADERS} ${RESOURCES})
138
add_dependencies(${LINPHONE_EXEC} update_translations)
139
add_dependencies(update_translations check_qml)
Ronan Abhamon's avatar
Ronan Abhamon committed
140

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

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