cmake_minimum_required(VERSION 3.16)

# Application and package version
set(PACKAGE_VERSION "2.6.4")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/pri/version.txt")
    include(${CMAKE_CURRENT_SOURCE_DIR}/pri/version.txt)
    set(PACKAGE_VERSION ${APP_VERSION})
endif()

project(mobile-datovka VERSION ${PACKAGE_VERSION} LANGUAGES C CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui Network PrintSupport Qml Quick QuickControls2 Sql Svg Widgets Xml)
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Core5Compat)
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
if (ANDROID)
    find_package(Qt6 REQUIRED COMPONENTS CorePrivate)
endif()

qt_standard_project_setup(REQUIRES 6.5)

qt_add_executable(mobile-datovka
    src/app_version_info.cpp
    src/auxiliaries/email_helper.cpp src/auxiliaries/email_helper.h
    src/auxiliaries/ios_helper.cpp src/auxiliaries/ios_helper.h
    src/backup_zip.cpp src/backup_zip.h
    src/crypto/crypto.c src/crypto/crypto.h
    src/datovka_shared/app_version_info.cpp src/datovka_shared/app_version_info.h
    src/datovka_shared/compat/compat_time.cpp src/datovka_shared/compat/compat_time.h
    src/datovka_shared/compat/compiler.h
    src/datovka_shared/compat_qt/misc.h
    src/datovka_shared/compat_qt/random.cpp src/datovka_shared/compat_qt/random.h
    src/datovka_shared/compat_qt/variant.h
    src/datovka_shared/crypto/crypto.c src/datovka_shared/crypto/crypto.h src/datovka_shared/crypto/crypto_funcs.h
    src/datovka_shared/crypto/crypto_pin.c src/datovka_shared/crypto/crypto_pin.h
    src/datovka_shared/crypto/crypto_pin_wrapped.cpp src/datovka_shared/crypto/crypto_pin_wrapped.h
    src/datovka_shared/crypto/crypto_pwd.c src/datovka_shared/crypto/crypto_pwd.h
    src/datovka_shared/crypto/crypto_threads.cpp src/datovka_shared/crypto/crypto_threads.h
    src/datovka_shared/crypto/crypto_trusted_certs.c src/datovka_shared/crypto/crypto_trusted_certs.h
    src/datovka_shared/crypto/crypto_version.cpp src/datovka_shared/crypto/crypto_version.h
    src/datovka_shared/crypto/crypto_wrapped.cpp src/datovka_shared/crypto/crypto_wrapped.h
    src/datovka_shared/gov_services/helper.cpp src/datovka_shared/gov_services/helper.h
    src/datovka_shared/gov_services/service/gov_mv_crr_vbh.cpp src/datovka_shared/gov_services/service/gov_mv_crr_vbh.h
    src/datovka_shared/gov_services/service/gov_mv_ir_vp.cpp src/datovka_shared/gov_services/service/gov_mv_ir_vp.h
    src/datovka_shared/gov_services/service/gov_mv_rt_vt.cpp src/datovka_shared/gov_services/service/gov_mv_rt_vt.h
    src/datovka_shared/gov_services/service/gov_mv_rtpo_vt.cpp src/datovka_shared/gov_services/service/gov_mv_rtpo_vt.h
    src/datovka_shared/gov_services/service/gov_mv_skd_vp.cpp src/datovka_shared/gov_services/service/gov_mv_skd_vp.h
    src/datovka_shared/gov_services/service/gov_mv_vr_vp.cpp src/datovka_shared/gov_services/service/gov_mv_vr_vp.h
    src/datovka_shared/gov_services/service/gov_mv_zr_vp.cpp src/datovka_shared/gov_services/service/gov_mv_zr_vp.h
    src/datovka_shared/gov_services/service/gov_service.cpp src/datovka_shared/gov_services/service/gov_service.h
    src/datovka_shared/gov_services/service/gov_service_form_field.cpp src/datovka_shared/gov_services/service/gov_service_form_field.h
    src/datovka_shared/gov_services/service/gov_services_all.cpp src/datovka_shared/gov_services/service/gov_services_all.h
    src/datovka_shared/gov_services/service/gov_szr_rob_vu.cpp src/datovka_shared/gov_services/service/gov_szr_rob_vu.h
    src/datovka_shared/gov_services/service/gov_szr_rob_vvu.cpp src/datovka_shared/gov_services/service/gov_szr_rob_vvu.h
    src/datovka_shared/gov_services/service/gov_szr_ros_vv.cpp src/datovka_shared/gov_services/service/gov_szr_ros_vv.h
    src/datovka_shared/graphics/colour.cpp src/datovka_shared/graphics/colour.h
    src/datovka_shared/graphics/graphics.cpp src/datovka_shared/graphics/graphics.h
    src/datovka_shared/html/html_export.cpp src/datovka_shared/html/html_export.h
    src/datovka_shared/identifiers/account_id.cpp src/datovka_shared/identifiers/account_id.h src/datovka_shared/identifiers/account_id_p.h
    src/datovka_shared/io/draft_db.cpp src/datovka_shared/io/draft_db.h
    src/datovka_shared/io/draft_db_tables.cpp src/datovka_shared/io/draft_db_tables.h
    src/datovka_shared/io/db_helper.cpp src/datovka_shared/io/db_helper.h
    src/datovka_shared/io/db_tables.h
    src/datovka_shared/io/db_time.cpp src/datovka_shared/io/db_time.h
    src/datovka_shared/io/filesystem.cpp src/datovka_shared/io/filesystem.h
    src/datovka_shared/io/message_db_tables.cpp src/datovka_shared/io/message_db_tables.h
    src/datovka_shared/io/prefs_db.cpp src/datovka_shared/io/prefs_db.h
    src/datovka_shared/io/prefs_db_tables.cpp src/datovka_shared/io/prefs_db_tables.h
    src/datovka_shared/io/records_management_db.cpp src/datovka_shared/io/records_management_db.h
    src/datovka_shared/io/records_management_db_tables.cpp src/datovka_shared/io/records_management_db_tables.h
    src/datovka_shared/io/sqlite/db.cpp src/datovka_shared/io/sqlite/db.h
    src/datovka_shared/io/sqlite/db_single.cpp src/datovka_shared/io/sqlite/db_single.h
    src/datovka_shared/io/sqlite/table.cpp src/datovka_shared/io/sqlite/table.h
    src/datovka_shared/isds/account_interface.cpp src/datovka_shared/isds/account_interface.h
    src/datovka_shared/isds/box_interface.cpp src/datovka_shared/isds/box_interface.h
    src/datovka_shared/isds/box_interface2.cpp src/datovka_shared/isds/box_interface2.h
    src/datovka_shared/isds/error.cpp src/datovka_shared/isds/error.h
    src/datovka_shared/isds/generic_interface.cpp src/datovka_shared/isds/generic_interface.h
    src/datovka_shared/isds/internal_conversion.cpp src/datovka_shared/isds/internal_conversion.h
    src/datovka_shared/isds/json_conversion.cpp src/datovka_shared/isds/json_conversion.h
    src/datovka_shared/isds/message_attachment.cpp src/datovka_shared/isds/message_attachment.h
    src/datovka_shared/isds/message_interface.cpp src/datovka_shared/isds/message_interface.h
    src/datovka_shared/isds/message_interface2.cpp src/datovka_shared/isds/message_interface2.h
    src/datovka_shared/isds/message_interface_vodz.cpp src/datovka_shared/isds/message_interface_vodz.h
    src/datovka_shared/isds/to_text_conversion.cpp src/datovka_shared/isds/to_text_conversion.h
    src/datovka_shared/isds/type_conversion.cpp src/datovka_shared/isds/type_conversion.h
    src/datovka_shared/isds/type_description.cpp src/datovka_shared/isds/type_description.h
    src/datovka_shared/isds/types.h
    src/datovka_shared/json/basic.cpp src/datovka_shared/json/basic.h
    src/datovka_shared/json/draft_interface.cpp src/datovka_shared/json/draft_interface.h
    src/datovka_shared/json/db_info.cpp src/datovka_shared/json/db_info.h
    src/datovka_shared/json/helper.cpp src/datovka_shared/json/helper.h
    src/datovka_shared/json/object.cpp src/datovka_shared/json/object.h
    src/datovka_shared/localisation/countries.cpp src/datovka_shared/localisation/countries.h
    src/datovka_shared/localisation/localisation.cpp src/datovka_shared/localisation/localisation.h
    src/datovka_shared/log/global.cpp src/datovka_shared/log/global.h
    src/datovka_shared/log/log.cpp src/datovka_shared/log/log.h
    src/datovka_shared/log/log_c.cpp src/datovka_shared/log/log_c.h
    src/datovka_shared/log/log_common.h
    src/datovka_shared/log/log_device.cpp src/datovka_shared/log/log_device.h
    src/datovka_shared/log/memory_log.cpp src/datovka_shared/log/memory_log.h
    src/datovka_shared/records_management/conversion.cpp src/datovka_shared/records_management/conversion.h
    src/datovka_shared/records_management/io/records_management_connection.cpp src/datovka_shared/records_management/io/records_management_connection.h
    src/datovka_shared/records_management/json/entry_error.cpp src/datovka_shared/records_management/json/entry_error.h
    src/datovka_shared/records_management/json/service_info.cpp src/datovka_shared/records_management/json/service_info.h
    src/datovka_shared/records_management/json/stored_files.cpp src/datovka_shared/records_management/json/stored_files.h
    src/datovka_shared/records_management/json/upload_account_status.cpp src/datovka_shared/records_management/json/upload_account_status.h
    src/datovka_shared/records_management/json/upload_file.cpp src/datovka_shared/records_management/json/upload_file.h
    src/datovka_shared/records_management/json/upload_hierarchy.cpp src/datovka_shared/records_management/json/upload_hierarchy.h
    src/datovka_shared/records_management/models/upload_hierarchy_proxy_model.cpp src/datovka_shared/records_management/models/upload_hierarchy_proxy_model.h
    src/datovka_shared/settings/account.cpp src/datovka_shared/settings/account.h src/datovka_shared/settings/account_p.h
    src/datovka_shared/settings/account_container.cpp src/datovka_shared/settings/account_container.h
    src/datovka_shared/settings/pin.cpp src/datovka_shared/settings/pin.h
    src/datovka_shared/settings/prefs.cpp src/datovka_shared/settings/prefs.h
    src/datovka_shared/settings/prefs_helper.cpp src/datovka_shared/settings/prefs_helper.h
    src/datovka_shared/settings/records_management.cpp src/datovka_shared/settings/records_management.h
    src/datovka_shared/utility/date_time.cpp src/datovka_shared/utility/date_time.h
    src/datovka_shared/utility/pdf_printer.cpp src/datovka_shared/utility/pdf_printer.h
    src/datovka_shared/utility/strings.cpp src/datovka_shared/utility/strings.h
    src/datovka_shared/worker/pool.cpp src/datovka_shared/worker/pool.h
    src/files.cpp src/files.h
    src/font/font.cpp src/font/font.h
    src/global.cpp src/global.h
    src/gov_services/models/gov_form_list_model.cpp src/gov_services/models/gov_form_list_model.h
    src/gov_services/models/gov_service_list_model.cpp src/gov_services/models/gov_service_list_model.h
    src/gov_wrapper.cpp src/gov_wrapper.h
    src/initialisation.cpp src/initialisation.h
    src/io/filesystem.cpp src/io/filesystem.h
    src/isds/conversion/isds_conversion.cpp src/isds/conversion/isds_conversion.h
    src/isds/conversion/isds_time_conversion.cpp src/isds/conversion/isds_time_conversion.h
    src/isds/conversion/isds_type_conversion.cpp src/isds/conversion/isds_type_conversion.h
    src/isds/interface/response_status.cpp src/isds/interface/response_status.h
    src/isds/io/connection.cpp src/isds/io/connection.h
    src/isds/io/downloader.cpp src/isds/io/downloader.h
    src/isds/isds_const.h
    src/isds/isds_login.cpp src/isds/isds_login.h
    src/isds/isds_tasks.cpp src/isds/isds_tasks.h
    src/isds/isds_wrapper.cpp src/isds/isds_wrapper.h
    src/isds/services/box_interface.cpp src/isds/services/box_interface.h
    src/isds/services/helper.cpp src/isds/services/helper.h
    src/isds/services/login_interface.cpp src/isds/services/login_interface.h
    src/isds/services/message_interface.cpp src/isds/services/message_interface.h
    src/isds/services/message_interface_offline.cpp src/isds/services/message_interface_offline.h
    src/isds/services/message_interface_vodz.cpp src/isds/services/message_interface_vodz.h
    src/isds/session/isds_context.cpp src/isds/session/isds_context.h
    src/isds/session/isds_session.cpp src/isds/session/isds_session.h
    src/isds/session/isds_sessions.cpp src/isds/session/isds_sessions.h
    src/isds/xml/box_interface.cpp src/isds/xml/box_interface.h
    src/isds/xml/cms.cpp src/isds/xml/cms.h
    src/isds/xml/helper.cpp src/isds/xml/helper.h
    src/isds/xml/login_interface.cpp src/isds/xml/login_interface.h
    src/isds/xml/message_interface.cpp src/isds/xml/message_interface.h
    src/isds/xml/message_interface_vodz.cpp src/isds/xml/message_interface_vodz.h
    src/isds/xml/response_status.cpp src/isds/xml/response_status.h
    src/isds/xml/xml_constants.cpp src/isds/xml/xml_constants.h
    src/json/backup.cpp src/json/backup.h
    src/locker.cpp src/locker.h
    src/log.cpp src/log.h
    src/main.cpp
    src/messages.cpp src/messages.h
    src/models/accountmodel.cpp src/models/accountmodel.h
    src/models/backup_selection_model.cpp src/models/backup_selection_model.h
    src/models/draftmodel.cpp src/models/draftmodel.h
    src/models/databoxmodel.cpp src/models/databoxmodel.h
    src/models/filemodel.cpp src/models/filemodel.h
    src/models/list_sort_filter_proxy_model.cpp src/models/list_sort_filter_proxy_model.h
    src/models/messagemodel.cpp src/models/messagemodel.h
    src/models/prefs_model.cpp src/models/prefs_model.h
    src/net/db_wrapper.cpp src/net/db_wrapper.h
    src/qml_identifiers/qml_account_id.cpp src/qml_identifiers/qml_account_id.h
    src/qml_interaction/image_provider.cpp src/qml_interaction/image_provider.h
    src/qml_interaction/interaction_filesystem.cpp src/qml_interaction/interaction_filesystem.h
    src/qml_interaction/interaction_zfo_file.cpp src/qml_interaction/interaction_zfo_file.h
    src/qml_interaction/message_info.cpp src/qml_interaction/message_info.h
    src/qml_interaction/string_manipulation.cpp src/qml_interaction/string_manipulation.h
    src/qml_isds/message_interface.cpp src/qml_isds/message_interface.h
    src/records_management/models/upload_hierarchy_list_model.cpp src/records_management/models/upload_hierarchy_list_model.h
    src/records_management/models/upload_hierarchy_qml_proxy_model.cpp src/records_management/models/upload_hierarchy_qml_proxy_model.h
    src/settings/account.cpp src/settings/account.h
    src/settings/account_logos.cpp src/settings/account_logos.h
    src/settings/accounts.cpp src/settings/accounts.h
    src/settings/convert_for_compatibility.cpp src/settings/convert_for_compatibility.h
    src/settings/convert_to_prefs.cpp src/settings/convert_to_prefs.h
    src/settings/ini_preferences.cpp src/settings/ini_preferences.h
    src/settings/ini_preferences_watcher.cpp src/settings/ini_preferences_watcher.h
    src/settings/prefs_defaults.cpp src/settings/prefs_defaults.h
    src/settings/prefs_specific.cpp src/settings/prefs_specific.h
    src/setwrapper.cpp src/setwrapper.h
    src/sqlite/account_db.cpp src/sqlite/account_db.h
    src/sqlite/account_db_tables.cpp src/sqlite/account_db_tables.h
    src/sqlite/db_tables.cpp
    src/sqlite/message_db.cpp src/sqlite/message_db.h
    src/sqlite/message_db_container.cpp src/sqlite/message_db_container.h
    src/sqlite/zfo_db.cpp src/sqlite/zfo_db.h
    src/sqlite/zfo_db_tables.cpp src/sqlite/zfo_db_tables.h
    src/worker/emitter.h
    src/worker/task.h
    src/worker/task_archive_document.cpp src/worker/task_archive_document.h
    src/worker/task_change_password.cpp src/worker/task_change_password.h
    src/worker/task_credit_info.cpp src/worker/task_credit_info.h
    src/worker/task_download_account_info.cpp src/worker/task_download_account_info.h
    src/worker/task_download_attachment.cpp src/worker/task_download_attachment.h
    src/worker/task_download_big_message.cpp src/worker/task_download_big_message.h
    src/worker/task_download_delivery_info.cpp src/worker/task_download_delivery_info.h
    src/worker/task_download_dt_info.cpp src/worker/task_download_dt_info.h
    src/worker/task_download_message.cpp src/worker/task_download_message.h
    src/worker/task_download_message_list.cpp src/worker/task_download_message_list.h
    src/worker/task_find_databox.cpp src/worker/task_find_databox.h
    src/worker/task_find_databox_fulltext.cpp src/worker/task_find_databox_fulltext.h
    src/worker/task_import_zfo.cpp src/worker/task_import_zfo.h
    src/worker/task_keep_alive.cpp src/worker/task_keep_alive.h
    src/worker/task_pdz_info.cpp src/worker/task_pdz_info.h
    src/worker/task_recipient_info.cpp src/worker/task_recipient_info.h
    src/worker/task_records_management_stored_messages.cpp src/worker/task_records_management_stored_messages.h
    src/worker/task_send_big_message.cpp src/worker/task_send_big_message.h
    src/worker/task_send_message.cpp src/worker/task_send_message.h
    src/worker/task_send_sms.cpp src/worker/task_send_sms.h
    src/worker/task_susp_message_report.cpp src/worker/task_susp_message_report.h
    src/worker/task_upload_attachment.cpp src/worker/task_upload_attachment.h
    src/wrap_accounts.cpp src/wrap_accounts.h
    src/wrap_records_management.cpp src/wrap_records_management.h
    src/zfo.cpp src/zfo.h
)

qt_add_qml_module(mobile-datovka
    URI mobile_datovka
    VERSION ${PACKAGE_VERSION}
    QML_FILES
        res/../qml/components/AccessibleButton.qml
        res/../qml/components/AccessibleComboBox.qml
        res/../qml/components/AccessibleImageButton.qml
        res/../qml/components/AccessibleLabel.qml
        res/../qml/components/AccessibleLabelDark.qml
        res/../qml/components/AccessibleRoundButton.qml
        res/../qml/components/AccessibleSpinBox.qml
        res/../qml/components/AccessibleSpinBoxZeroMax.qml
        res/../qml/components/AccessibleSwitch.qml
        res/../qml/components/AccessibleSwitchInfo.qml
        res/../qml/components/AccessibleText.qml
        res/../qml/components/AccessibleTextButton.qml
        res/../qml/components/AccessibleTextField.qml
        res/../qml/components/AccessibleTextHelp.qml
        res/../qml/components/AccessibleTextInfo.qml
        res/../qml/components/AccessibleTextInfoSmall.qml
        res/../qml/components/AccessibleToolButton.qml
        res/../qml/components/AccountList.qml
        res/../qml/components/ChangeLogBox.qml
        res/../qml/components/ControlGroupItem.qml
        res/../qml/components/DataboxList.qml
        res/../qml/components/FileDialogue.qml
        res/../qml/components/FilterBar.qml
        res/../qml/components/GovFormList.qml
        res/../qml/components/GovServiceList.qml
        res/../qml/components/MessageBox.qml
        res/../qml/components/MessageList.qml
        res/../qml/components/PageHeader.qml
        res/../qml/components/Pictogram.qml
        res/../qml/components/PopupItem.qml
        res/../qml/components/SeparatorLine.qml
        res/../qml/components/ScrollableListView.qml
        res/../qml/components/ShowPasswordOverlaidImage.qml
        res/../qml/components/SurveyDialogue.qml
        res/../qml/components/TextLineItem.qml
        res/../qml/components/TimedPasswordLine.qml
        res/../qml/dialogues/InputDialogue.qml
        res/../qml/dialogues/YesNoDialogue.qml
        res/../qml/pages/PageAboutApp.qml
        res/../qml/pages/PageAccountDetail.qml
        res/../qml/pages/PageAccountList.qml
        res/../qml/pages/PageAccountLogo.qml
        res/../qml/pages/PageArchiveDocument.qml
        res/../qml/pages/PageBackupData.qml
        res/../qml/pages/PageChangePassword.qml
        res/../qml/pages/PageDraftList.qml
        res/../qml/pages/PageContactList.qml
        res/../qml/pages/PageConvertDatabase.qml
        res/../qml/pages/PageDataboxDetail.qml
        res/../qml/pages/PageDataboxSearch.qml
        res/../qml/pages/PageGovService.qml
        res/../qml/pages/PageGovServiceList.qml
        res/../qml/pages/PageImportMessage.qml
        res/../qml/pages/PageLog.qml
        res/../qml/pages/PageMessageDetail.qml
        res/../qml/pages/PageMessageEnvelope.qml
        res/../qml/pages/PageMessageList.qml
        res/../qml/pages/PageMessageListSwipeView.qml
        res/../qml/pages/PageMessageSearch.qml
        res/../qml/pages/PageMessageSignature.qml
        res/../qml/pages/PagePrefsEditor.qml
        res/../qml/pages/PageRecordsManagementUpload.qml
        res/../qml/pages/PageRepairDatabase.qml
        res/../qml/pages/PageRestoreData.qml
        res/../qml/pages/PageSendMessage.qml
        res/../qml/pages/PageSettingsAccount.qml
        res/../qml/pages/PageSettingsGeneral.qml
        res/../qml/pages/PageSettingsPin.qml
        res/../qml/pages/PageSettingsRecordsManagement.qml
        res/../qml/pages/PageSettingsSync.qml
        res/../qml/pages/PageSpamReport.qml
        res/../qml/pages/PageTransferData.qml
        res/../qml/pages/PageWelcome.qml
        res/../qml/popups/DrawerMenuDatovka.qml
        res/../qml/popups/PopupMenuAccount.qml
        res/../qml/popups/PopupMenuMessage.qml
        res/../qml/popups/PopupMenuMessageDetail.qml
        res/../qml/popups/PopupMenuMessageList.qml
        res/../qml/popups/PopupMenuMessageSend.qml
        res/../qml/wizards/CreateAccountLoader.qml
        res/../qml/wizards/CreateAccountPage1.qml
        res/../qml/wizards/CreateAccountPage2.qml
        res/../qml/wizards/CreateAccountPage3.qml
        res/../qml/wizards/CreateAccountPage4.qml
        res/../qml/main.qml
    NO_RESOURCE_TARGET_PATH
)

target_compile_definitions(mobile-datovka PRIVATE
    APP_NAME="Datovka"
    VERSION="${PACKAGE_VERSION}"
    DEBUG=1
)

target_link_libraries(mobile-datovka PRIVATE
    Qt6::Core
    Qt6::Core5Compat
    Qt6::Gui
    Qt6::Network
    Qt6::PrintSupport
    Qt6::Qml
    Qt6::Quick
    Qt6::QuickControls2
    Qt6::Sql
    Qt6::Svg
    Qt6::Widgets
    Qt6::Xml
    Qt6::CorePrivate
)

# Resources:
set(img_resource_files
    "res/banners/mojeID_banner_landscape.svg"
    "res/banners/mojeID_banner_portrait.svg"
    "res/cznic.png"
    "res/cznicneg.png"
    "res/datovka-pdf.png"
    "res/datovka.png"
    "res/fileicons/fileicon_avi.png"
    "res/fileicons/fileicon_blank.png"
    "res/fileicons/fileicon_bmp.png"
    "res/fileicons/fileicon_doc.png"
    "res/fileicons/fileicon_docx.png"
    "res/fileicons/fileicon_dwg.png"
    "res/fileicons/fileicon_gif.png"
    "res/fileicons/fileicon_htm.png"
    "res/fileicons/fileicon_html.png"
    "res/fileicons/fileicon_jpeg.png"
    "res/fileicons/fileicon_jpg.png"
    "res/fileicons/fileicon_mp3.png"
    "res/fileicons/fileicon_mpeg.png"
    "res/fileicons/fileicon_mpg.png"
    "res/fileicons/fileicon_ods.png"
    "res/fileicons/fileicon_odt.png"
    "res/fileicons/fileicon_pdf.png"
    "res/fileicons/fileicon_png.png"
    "res/fileicons/fileicon_ppt.png"
    "res/fileicons/fileicon_pptx.png"
    "res/fileicons/fileicon_rtf.png"
    "res/fileicons/fileicon_tiff.png"
    "res/fileicons/fileicon_txt.png"
    "res/fileicons/fileicon_wav.png"
    "res/fileicons/fileicon_xls.png"
    "res/fileicons/fileicon_xlsx.png"
    "res/fileicons/fileicon_xml.png"
    "res/fileicons/fileicon_zfo.png"
    "res/font/NotoSerif-Regular.ttf"
    "res/font/Roboto-Regular.ttf"
    "res/font/SourceSansPro-Regular.ttf"
    "res/ui/account-box.svg"
    "res/ui/account-key.svg"
    "res/ui/account-plus.svg"
    "res/ui/account-remove.svg"
    "res/ui/account-search.svg"
    "res/ui/add.svg"
    "res/ui/alert-red.svg"
    "res/ui/alert.svg"
    "res/ui/android-arrow-back.svg"
    "res/ui/android-more-vertical.svg"
    "res/ui/app_preferences.svg"
    "res/ui/archive.svg"
    "res/ui/arrow-down-bold-circle.svg"
    "res/ui/arrow-left.svg"
    "res/ui/arrow-right.svg"
    "res/ui/attach-download.svg"
    "res/ui/briefcase.svg"
    "res/ui/calendar.svg"
    "res/ui/checkbox-marked-circle.svg"
    "res/ui/checkmark.svg"
    "res/ui/close-octagon.svg"
    "res/ui/drafts.svg"
    "res/ui/danger-cross-orange.svg"
    "res/ui/danger-cross-red.svg"
    "res/ui/danger-cross.svg"
    "res/ui/dark/briefcase.svg"
    "res/ui/dark/email-open-outline.svg"
    "res/ui/dark/email-outline.svg"
    "res/ui/dark/eye-pwd-hide.svg"
    "res/ui/dark/eye-pwd-show.svg"
    "res/ui/dark/next.svg"
    "res/ui/dark/paper-clip.svg"
    "res/ui/database.svg"
    "res/ui/databox-add.svg"
    "res/ui/databox-info.svg"
    "res/ui/databox-regular.png"
    "res/ui/databox-remove.svg"
    "res/ui/databox-settings.svg"
    "res/ui/databox-test.png"
    "res/ui/databox.svg"
    "res/ui/datovka-email-sample.svg"
    "res/ui/datovka-file-zfo.svg"
    "res/ui/datovka-msg-blank.png"
    "res/ui/delete.svg"
    "res/ui/document-text.svg"
    "res/ui/email-attachment.svg"
    "res/ui/email-open-outline.svg"
    "res/ui/email-outline.svg"
    "res/ui/email-zfo.svg"
    "res/ui/eye-pwd-hide.svg"
    "res/ui/eye-pwd-show.svg"
    "res/ui/eye.svg"
    "res/ui/file-import.svg"
    "res/ui/folder.svg"
    "res/ui/format-list-bulleted.svg"
    "res/ui/forward.svg"
    "res/ui/help-circle.svg"
    "res/ui/home.svg"
    "res/ui/information.svg"
    "res/ui/key-add.svg"
    "res/ui/key-change.svg"
    "res/ui/key-remove.svg"
    "res/ui/key-variant.svg"
    "res/ui/light/briefcase.svg"
    "res/ui/light/email-open-outline.svg"
    "res/ui/light/email-outline.svg"
    "res/ui/light/eye-pwd-hide.svg"
    "res/ui/light/eye-pwd-show.svg"
    "res/ui/light/next.svg"
    "res/ui/light/paper-clip.svg"
    "res/ui/magnify.svg"
    "res/ui/menu.svg"
    "res/ui/mobile.svg"
    "res/ui/next.svg"
    "res/ui/paper-clip-plus.svg"
    "res/ui/paper-clip.svg"
    "res/ui/pencil-box-outline.svg"
    "res/ui/received-msgs.svg"
    "res/ui/remove.svg"
    "res/ui/reply.svg"
    "res/ui/restamp-zfo.svg"
    "res/ui/save-to-disk-attachment.svg"
    "res/ui/save-to-disk-pdf.svg"
    "res/ui/save-to-disk-zfo.svg"
    "res/ui/send-gov-msg.svg"
    "res/ui/send-msg.svg"
    "res/ui/sent-msgs.svg"
    "res/ui/settings.svg"
    "res/ui/signature.svg"
    "res/ui/spam.svg"
    "res/ui/spam-red.svg"
    "res/ui/subtract.svg"
    "res/ui/sync-all.svg"
    "res/ui/sync.svg"
    "res/ui/upload.svg"
)

set(TS_FILES
    res/locale/datovka_en.ts
    res/locale/datovka_cs.ts
    res/locale/datovka_uk.ts
)
set_source_files_properties(${TS_FILES}
    PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/res/locale"
)
qt6_add_translation(qmFiles ${TS_FILES})

qt_add_resources(mobile-datovka "img"
    PREFIX
        "/"
    BASE
        "res"
    FILES
        ${img_resource_files}
)
set(translations_resource_files
    "res/locale/datovka_cs.qm"
    "res/locale/datovka_en.qm"
    "res/locale/datovka_uk.qm"
    "res/locale/qtbase_cs.qm"
    "res/locale/qtbase_en.qm"
    "res/locale/qtbase_uk.qm"
)

qt_add_resources(mobile-datovka "translations"
    PREFIX
        "/"
    BASE
        "res"
    FILES
        ${translations_resource_files}
)

target_sources(mobile-datovka PUBLIC
    src/datovka_shared/3rdparty/quazip-1.5/quazip/JlCompress.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/JlCompress.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/ioapi.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/minizip_crypt.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/qioapi.cpp
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quaadler32.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quaadler32.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quachecksum32.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quachecksum32.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quacrc32.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quacrc32.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quagzipfile.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quagzipfile.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quaziodevice.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quaziodevice.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quazip.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quazip.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quazip_global.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quazip_qt_compat.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipdir.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipdir.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipfile.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipfile.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipfileinfo.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipfileinfo.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipnewinfo.cpp src/datovka_shared/3rdparty/quazip-1.5/quazip/quazipnewinfo.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/unzip.c src/datovka_shared/3rdparty/quazip-1.5/quazip/unzip.h
    src/datovka_shared/3rdparty/quazip-1.5/quazip/zip.c src/datovka_shared/3rdparty/quazip-1.5/quazip/zip.h
)
target_include_directories(mobile-datovka PRIVATE
    src/datovka_shared/3rdparty/quazip-1.5
)
target_compile_definitions(mobile-datovka PRIVATE QUAZIP_STATIC)
target_link_libraries(mobile-datovka PRIVATE z)

if(lupdate_only)
    target_sources(mobile-datovka PUBLIC
        qml/*.qml
        qml/components/*.qml
        qml/dialogues/*.qml
        qml/pages/*.qml
        qml/popups/*.qml
        qml/wizards/*.qml
    )
endif()

if(IOS)

    target_sources(mobile-datovka PUBLIC
        ios/src/app_delegate.h ios/src/app_delegate.mm
        ios/src/doc_picker_controller.h ios/src/doc_picker_controller.mm
        ios/src/doc_view_controller.h ios/src/doc_view_controller.mm
        ios/src/icloud_io.h ios/src/icloud_io.mm
        ios/src/ios_file_opener.h ios/src/ios_file_opener.mm
        ios/src/qt_app_delegate.h
        ios/src/send_email_controller.h ios/src/send_email_controller.mm
        ios/src/url_opener.h ios/src/url_opener.mm
    )

    target_include_directories(mobile-datovka PRIVATE
        ios
        ios/openssl/include
        src
    )

    target_link_libraries(mobile-datovka PRIVATE
        "-framework MessageUI"
        "-framework MobileCoreServices"
        "-framework StoreKit"
        "-framework UIKit"
        ${CMAKE_CURRENT_SOURCE_DIR}/ios/openssl/lib/libcrypto.a
        ${CMAKE_CURRENT_SOURCE_DIR}/ios/openssl/lib/libssl.a
    )

    set(CF_BUNDLE_IDENTIFIER "cz.nic.mobile-datovka")
    set(CF_BUNDLE_NAME "Datovka")

    set(IOS_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ios")
    if(EXISTS "${IOS_PACKAGE_SOURCE_DIR}/codeversion.txt")
        message("---------------------------------------------------")
        message("Include external code version file: codeversion.txt")
        include(${IOS_PACKAGE_SOURCE_DIR}/codeversion.txt)
        message("PKG version: " ${PACKAGE_VERSION})
        message("PKG ID: " ${CF_BUNDLE_IDENTIFIER})
        message("APP name: " ${CF_BUNDLE_NAME})
        message("APP version: " ${PACKAGE_VERSION})
        message("---------------------------------------------------")
    endif()

    find_program (SED_TOOL NAMES sed)
    if (NOT SED_TOOL)
        message (FATAL_ERROR "Unable to find sed")
    endif (NOT SED_TOOL)
    message("Generate Info.plist")
    execute_process(
        COMMAND ${SED_TOOL} -e "s/@VERSION@/${PACKAGE_VERSION}/g" -e "s/@CF_BUNDLE_NAME@/${CF_BUNDLE_NAME}/g" -e "s/@CF_BUNDLE_IDENTIFIER@/${CF_BUNDLE_IDENTIFIER}/g" "${IOS_PACKAGE_SOURCE_DIR}/Info.tmp" OUTPUT_FILE "${IOS_PACKAGE_SOURCE_DIR}/Info.plist"
    )

    set_target_properties(mobile-datovka PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER "${CF_BUNDLE_IDENTIFIER}"
        MACOSX_BUNDLE_INFO_PLIST "${IOS_PACKAGE_SOURCE_DIR}/Info.plist"
    )

    set(asset_catalog_path "${IOS_PACKAGE_SOURCE_DIR}/Images.xcassets")
    target_sources(mobile-datovka PRIVATE "${asset_catalog_path}")
    set_source_files_properties(${asset_catalog_path} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

    set_target_properties(mobile-datovka PROPERTIES
        XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon)

    file(GLOB_RECURSE launch_images CONFIGURE_DEPENDS LaunchImage)
    if(IOS AND launch_images)
        target_sources(mobile-datovka PRIVATE ${launch_images})
        set_source_files_properties(
            ${launch_images}
            PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
    endif()

    set_target_properties(mobile-datovka PROPERTIES
        XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME LaunchImage)

endif()

if (ANDROID)

    # do not change these values
    set(GOOGLEPLAY_CODE_VERSION 1)
    set(GOOGLEPLAY_PACKAGE_NAME_ID "cz.nic.mobiledatovka")
    set(GOOGLEPLAY_APP_NAME "Datovka")
    set(GOOGLEPLAY_APP_ICON "icon")
    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
    set(ANDROID_PACKAGE_SOURCE_DIR2 "${CMAKE_CURRENT_SOURCE_DIR}/android_qt6")
    set_property(TARGET mobile-datovka APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR ${ANDROID_PACKAGE_SOURCE_DIR2})

    # include android wrapper code
    target_sources(mobile-datovka PRIVATE ${ANDROID_PACKAGE_SOURCE_DIR2}/src/android_io.cpp ${ANDROID_PACKAGE_SOURCE_DIR2}/src/android_io.h)

    # include openssl
    target_include_directories(mobile-datovka PRIVATE ${ANDROID_PACKAGE_SOURCE_DIR}/android_openssl/ssl_3/include)
    include(${ANDROID_PACKAGE_SOURCE_DIR}/android_openssl/android_openssl.cmake)
    target_link_libraries(mobile-datovka PRIVATE
        ${ANDROID_PACKAGE_SOURCE_DIR}/android_openssl/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libcrypto.a
        ${ANDROID_PACKAGE_SOURCE_DIR}/android_openssl/ssl_3/${CMAKE_ANDROID_ARCH_ABI}/libssl.a
    )
    add_android_openssl_libraries(mobile-datovka)

    # set package data and generate android manifest file
    set(GOOGLEPLAY_VERSION ${PACKAGE_VERSION})
    find_program (SED_TOOL NAMES sed)
    if (NOT SED_TOOL)
        message (FATAL_ERROR "Unable to find sed")
    endif (NOT SED_TOOL)
    if(EXISTS "${ANDROID_PACKAGE_SOURCE_DIR}/codeversion.txt")
        message("---------------------------------------------------")
        message("Include external code version file: codeversion.txt")
        include(${ANDROID_PACKAGE_SOURCE_DIR}/codeversion.txt)
        message("PKG version: " ${GOOGLEPLAY_CODE_VERSION})
        message("PKG ID: " ${GOOGLEPLAY_PACKAGE_NAME_ID})
        message("APP name: " ${GOOGLEPLAY_APP_NAME})
        message("APP version: " ${GOOGLEPLAY_VERSION})
        message("---------------------------------------------------")
    endif()
    message("Generate QFileProvider.java")
    execute_process(
        COMMAND ${SED_TOOL} -e "s/@GOOGLEPLAY_PACKAGE_NAME_ID@/${GOOGLEPLAY_PACKAGE_NAME_ID}/g" "${ANDROID_PACKAGE_SOURCE_DIR2}/src/cz/nic/mobiledatovka/java/QFileProvider.java.in" OUTPUT_FILE "${ANDROID_PACKAGE_SOURCE_DIR2}/src/cz/nic/mobiledatovka/java/QFileProvider.java"
    )
    message("Generate AndroidManifest.xml")
    execute_process(
        COMMAND ${SED_TOOL} -e "s/@VERSION@/${GOOGLEPLAY_VERSION}/g" -e "s/@GOOGLEPLAY_CODE_VERSION@/${GOOGLEPLAY_CODE_VERSION}/g" -e "s/@GOOGLEPLAY_PACKAGE_NAME_ID@/${GOOGLEPLAY_PACKAGE_NAME_ID}/g" -e "s/@GOOGLEPLAY_APP_NAME@/${GOOGLEPLAY_APP_NAME}/g" -e "s/@GOOGLEPLAY_APP_ICON@/${GOOGLEPLAY_APP_ICON}/g" "${ANDROID_PACKAGE_SOURCE_DIR2}/AndroidManifest.xml.in" OUTPUT_FILE "${ANDROID_PACKAGE_SOURCE_DIR2}/AndroidManifest.xml"
    )

endif()
