# Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
#
# This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
#
# Privacy Browser PC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Privacy Browser PC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.

# Create the executable and add the resources.
add_executable(privacybrowser resources.qrc)

# List the sources to include in the executable.
target_sources(privacybrowser PRIVATE
    main.cpp
)

# Add the Qt logging category.  This will create the `debug.h` header file.
ecm_qt_declare_logging_category(privacybrowser
    HEADER debug.h
    IDENTIFIER PRIVACYBROWSER
    CATEGORY_NAME "privacybrowser"
)

# Include the KConfig controller file.
kconfig_add_kcfg_files(privacybrowser settings/Settings.kcfgc)

# Use KDE Frameworks to handle internationalization of the following UI files.
ki18n_wrap_ui(privacybrowser
    uis/AddBookmarkDialog.ui
    uis/AddFolderDialog.ui
    uis/AddOrEditCookieDialog.ui
    uis/AddTabWidget.ui
    uis/BookmarksDialog.ui
    uis/CookiesDialog.ui
    uis/DomainSettingsDialog.ui
    uis/DurableCookiesDialog.ui
    uis/EditBookmarkDialog.ui
    uis/EditFolderDialog.ui
    uis/SaveDialog.ui
    uis/SettingsGeneral.ui
    uis/SettingsPrivacy.ui
    uis/SettingsSpellCheck.ui
    uis/TabWidget.ui
)

# Link the following libraries.
target_link_libraries(privacybrowser
    Qt5::Core
    Qt5::Gui
    Qt5::Sql
    Qt5::PrintSupport
    Qt5::Widgets
    Qt5::WebEngineCore
    Qt5::WebEngineWidgets
    KF5::Completion
    KF5::ConfigWidgets
    KF5::CoreAddons
    KF5::Crash
    KF5::DBusAddons
    KF5::DocTools
    KF5::I18n
    KF5::Notifications
    KF5::KIOCore
    KF5::KIOWidgets
    KF5::XmlGui
)

# Add the subdirectories.
add_subdirectory(databases)
add_subdirectory(delegates)
add_subdirectory(dialogs)
add_subdirectory(filters)
add_subdirectory(helpers)
add_subdirectory(interceptors)
add_subdirectory(ui.rcs)
add_subdirectory(widgets)
add_subdirectory(windows)

# Install Privacy Browser using the default KDE arguments.
install(TARGETS privacybrowser ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})

# Install Privacy Browser according to the instructions in the desktop file, specifying the permissions.
install(PROGRAMS com.stoutner.privacybrowser.desktop DESTINATION ${KDE_INSTALL_APPDIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

# Install the metadata file.
install(FILES com.stoutner.privacybrowser.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})

# Install the notifyrc file.
install(FILES privacybrowser.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR})

# Install the standard icons.
ecm_install_icons(ICONS icons/sc-apps-privacybrowser.svg DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/16-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/22-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/24-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/32-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/48-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/64-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/128-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/256-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/512-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})
ecm_install_icons(ICONS icons/1024-apps-privacybrowser.png DESTINATION ${KDE_INSTALL_ICONDIR})

# Install the symbolic icon (used by Gnome).
install(FILES icons/privacybrowser-symbolic.svg DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/symbolic/apps/)
