Commit 3fbc24fd authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): use now cmake to build project

- remove useless scripts
- move `build_resources_file` to root and rename it to `update_resources`
- update/create languages directly with cmake
parent a5056465
......@@ -7,13 +7,16 @@ set(LINPHONE_EXEC linphone)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2)
set(QT5_PACKAGES Core Gui Quick Widgets QuickControls2 LinguistTools)
set(LIBS "")
foreach(package ${QT5_PACKAGES})
list(APPEND LIBS "Qt::${package}")
find_package(Qt5 COMPONENTS ${QT5_PACKAGES})
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 ()
set(SOURCES
src/app.cpp
......@@ -39,8 +42,37 @@ set(HEADERS
src/components/settings/SettingsModel.hpp
)
# Include `qrc` files.
qt5_add_resources(RESOURCES resources.qrc)
set(QRC_RESOURCES
resources.qrc
)
set(LANGUAGES_DIRECTORY languages)
set(LANGUAGES en fr)
# --------------------------------------------------------------------
find_package(Qt5 COMPONENTS ${QT5_PACKAGES})
# Build languages resource file.
set(TS_FILES)
set(I18N_CONTENT "<!DOCTYPE RCC>\n<RCC version=\"1.0\">\n <qresource prefix=\"/\">\n")
foreach (lang ${LANGUAGES})
list(APPEND TS_FILES "${LANGUAGES_DIRECTORY}/${lang}.ts")
# Note: the below `languages/` path is not the same as the `${LANGUAGES_DIRECTORY}` value.
# It's the symbolic path used by the linphone binary in the qrc model.
set(I18N_CONTENT "${I18N_CONTENT} <file alias=\"languages/${lang}\">${lang}.qm</file>\n")
endforeach ()
set(I18N_CONTENT "${I18N_CONTENT} </qresource>\n</RCC>\n")
set(I18N_RESOURCE i18n.qrc)
file(WRITE "${CMAKE_BINARY_DIR}/${I18N_RESOURCE}" "${I18N_CONTENT}")
# Create `qm` files from `ts` files.
qt5_create_translation(QM_FILES ${TS_FILES} src ui)
# Add qrc. (images, qml, translations...)
qt5_add_resources(RESOURCES ${QRC_RESOURCES} "${CMAKE_BINARY_DIR}/${I18N_RESOURCE}")
# Build.
add_executable(${LINPHONE_EXEC} ${SOURCES} ${HEADERS} ${RESOURCES})
......
QT = core gui quick widgets quickcontrols2
TARGET = linphone
TEMPLATE = app
CONFIG += c++11
RESOURCES = resources.qrc
SOURCES = \
src/app.cpp \
src/components/contacts/ContactModel.cpp \
src/components/contacts/ContactsListModel.cpp \
src/components/contacts/ContactsListProxyModel.cpp \
src/components/notification/Notification.cpp \
src/components/settings/AccountSettingsListModel.cpp \
src/components/settings/AccountSettingsModel.cpp \
src/components/settings/SettingsModel.cpp \
src/main.cpp \
HEADERS = \
src/app.hpp \
src/components/contacts/ContactModel.hpp \
src/components/contacts/ContactsListModel.hpp \
src/components/contacts/ContactsListProxyModel.hpp \
src/components/notification/Notification.hpp \
src/components/presence/Presence.hpp \
src/components/settings/AccountSettingsListModel.hpp \
src/components/settings/AccountSettingsModel.hpp \
src/components/settings/SettingsModel.hpp \
TRANSLATIONS = \
languages/en.ts \
languages/fr.ts \
lupdate_only{
SOURCES = \
ui/modules/Common/*.qml \
ui/modules/Common/Dialog/*.qml \
ui/modules/Common/Form/*.qml \
ui/modules/Common/Image/*.qml \
ui/modules/Common/Popup/*.qml \
ui/modules/Common/Styles/*.qml \
ui/modules/Common/Styles/Form/*.qml \
ui/modules/Common/View/*.qml \
ui/modules/Linphone/*.qml \
ui/modules/Linphone/Chat/*.qml \
ui/modules/Linphone/Contact/*.qml \
ui/modules/Linphone/Select/*.qml \
ui/modules/Linphone/Styles/*.qml \
ui/modules/Linphone/Styles/Contact/*.qml \
ui/views/*.qml \
ui/views/Calls/*.qml \
ui/views/MainWindow/*.qml \
}
......@@ -26,8 +26,6 @@
<file>imgs/right_arrow.svg</file>
<file>imgs/speaker.svg</file>
<file>imgs/valid.svg</file>
<file>languages/en.qm</file>
<file>languages/fr.qm</file>
<file>ui/modules/Common/Borders.qml</file>
<file>ui/modules/Common/Collapse.qml</file>
<file>ui/modules/Common/Colors.qml</file>
......
#!/usr/bin/bash
lupdate-qt5 -verbose $1/linphone.pro
lrelease-qt5 $1/linphone.pro
#!/usr/bin/bash
PRO_FILE="linphone.pro"
cd $1
echo "QT = core gui quick widgets quickcontrols2
TARGET = linphone
TEMPLATE = app
CONFIG += c++11
RESOURCES = resources.qrc" > $PRO_FILE
echo "
SOURCES = \\" >> $PRO_FILE
for filename in $(find src/ -name \*.cpp -type f | sort)
do
echo " $filename \\" >> $PRO_FILE
done
echo "
HEADERS = \\" >> $PRO_FILE
for filename in $(find src/ -name \*.hpp -type f | sort)
do
echo " $filename \\" >> $PRO_FILE
done
echo "
TRANSLATIONS = \\" >> $PRO_FILE
for filename in $(find languages/ -name \*.ts -type f | sort)
do
echo " $filename \\" >> $PRO_FILE
done
echo "
lupdate_only{
SOURCES = \\" >> $PRO_FILE
for filename in $(find ui/ -type f -name \*.qml -printf '%h\n' | sort -u)
do
echo " $filename/*.qml \\" >> $PRO_FILE
done
echo "
}" >> $PRO_FILE
#!/usr/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
$SCRIPT_DIR/scripts/update_linphone $SCRIPT_DIR
$SCRIPT_DIR/scripts/build_resources_file $SCRIPT_DIR
$SCRIPT_DIR/scripts/update_languages $SCRIPT_DIR
#!/usr/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RESOURCE_FILE="resources.qrc"
cd $1
cd $SCRIPT_DIR
echo "<!DOCTYPE RCC><RCC version=\"1.0\">
<qresource prefix=\"/\">" > $RESOURCE_FILE
for filename in $(find languages/ ui/ imgs/ -type f | sort)
for filename in $(find ui/ imgs/ -type f | sort)
do
basename="${filename##*/}"
extension="${filename##*.}"
if [[ "${extension}" == @(qml|svg|png|jpg|qm|js) ||
if [[ "${extension}" == @(qml|svg|png|jpg|js) ||
"${basename}" == "qmldir" ]]; then
echo " <file>$filename</file>" >> $RESOURCE_FILE
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment