# let's put most of the "meat" in a static library this way, we can also unit
# test parts of it
add_library(gpgpass_internal STATIC)

target_sources(gpgpass_internal PRIVATE
    ../resources.qrc

    clipboardhelper.cpp
    clipboardhelper.h
    gpgmehelpers.h
    gpgmehelpers.h
    passentry.cpp
    passentry.h
    passphrasegenerator.cpp
    passphrasegenerator.h
    passwordhealth.cpp
    passwordhealth.h
    passwordgenerator.cpp
    passwordgenerator.h
    rootfoldersmanager.cpp
    rootfoldersmanager.h
    userinfo.cpp
    userinfo.h
    util.cpp
    util.h

    job/directoryreencryptjob.cpp
    job/directoryreencryptjob.h
    job/fileencryptjob.cpp
    job/fileencryptjob.h
    job/filedecryptjob.cpp
    job/filedecryptjob.h
    job/filereencryptjob.cpp
    job/filereencryptjob.h

    conf/configuredialog.cpp
    conf/configuredialog.h
    conf/generalconfigurationpage.cpp
    conf/generalconfigurationpage.h
    conf/gpgpassconfigmodule.cpp
    conf/gpgpassconfigmodule.h
    conf/gpgpasspageconfigdialog.cpp
    conf/gpgpasspageconfigdialog.h
    conf/rootfoldersconfigurationpage.cpp
    conf/rootfoldersconfigurationpage.h
    conf/templateconfigurationpage.cpp
    conf/templateconfigurationpage.h

    models/addfileinfoproxy.cpp
    models/addfileinfoproxy.h
    models/storemodel.cpp
    models/storemodel.h
    models/userslistmodel.cpp
    models/userslistmodel.h
    models/rootfoldersmodel.cpp
    models/rootfoldersmodel.h

    widgets/adjustingscrollarea.cpp
    widgets/adjustingscrollarea.h
    widgets/deselectabletreeview.h
    widgets/formtextinput.cpp
    widgets/formtextinput.h
    widgets/mainwindow.cpp
    widgets/mainwindow.h
    widgets/passwordeditorwidget.cpp
    widgets/passwordeditorwidget.h
    widgets/passwordgeneratorwidget.cpp
    widgets/passwordgeneratorwidget.h
    widgets/passwordviewerwidget.cpp
    widgets/passwordviewerwidget.h
    widgets/qpushbuttonfactory.h
    widgets/qrcodepopup.cpp
    widgets/qrcodepopup.h
    widgets/setupwidget.cpp
    widgets/setupwidget.h
    widgets/usersdialog.cpp
    widgets/usersdialog.h
    widgets/welcomewidget.cpp
    widgets/welcomewidget.h

    zxcvbn/zxcvbn.c
    zxcvbn/zxcvbn.h
)

kconfig_add_kcfg_files(gpgpass_internal GENERATE_MOC
    config.kcfgc
    rootfolderconfig.kcfgc
)

ki18n_wrap_ui(gpgpass_internal
    conf/generalconfigurationpage.ui
    conf/rootfoldersconfigurationpage.ui
    conf/templateconfigurationpage.ui
    widgets/passwordeditorwidget.ui
    widgets/passwordgeneratorwidget.ui
    widgets/welcomewidget.ui
    widgets/mainwindow.ui
    widgets/usersdialog.ui
    widgets/userswidget.ui
)

target_link_libraries(gpgpass_internal
    Qt::Widgets
    KF${QT_MAJOR_VERSION}::CoreAddons
    KF${QT_MAJOR_VERSION}::ConfigCore
    KF${QT_MAJOR_VERSION}::ConfigGui
    KF${QT_MAJOR_VERSION}::Prison
    KF${QT_MAJOR_VERSION}::IconThemes
    KF${QT_MAJOR_VERSION}::I18n
    KF${QT_MAJOR_VERSION}::WidgetsAddons
    KF${QT_MAJOR_VERSION}::ItemModels
    KF${QT_MAJOR_VERSION}::ItemViews
    KF${QT_MAJOR_VERSION}::KIOWidgets
    KPim${QT_MAJOR_VERSION}::Libkleo
)

if (QT_MAJOR_VERSION STREQUAL "6")
    target_link_libraries(gpgpass_internal QGpgmeQt6 LibGpgError::LibGpgError KF6::ColorScheme)
    target_sources(gpgpass_internal PRIVATE
        job/openpgpcertificatecreationjob.cpp
        job/openpgpcertificatecreationjob.h
    )
else()
    target_link_libraries(gpgpass_internal QGpgme KF5::ConfigWidgets)
endif()
