set(KASTENCORE_VERSION ${KASTEN_LIB_VERSION})
set(KASTENCORE_SO_VERSION ${KASTEN_LIB_SOVERSION})

okteta_add_library(Core NAMESPACE Kasten
    PUBLIC
        KF6::KIOCore
        Qt6::Core
        Qt6::Gui
    PRIVATE
        KF6::I18n
        KF6::JobWidgets
        KF6::WidgetsAddons
        Qt6::Network
    VERSION     ${KASTENCORE_VERSION}
    SOVERSION   ${KASTENCORE_SO_VERSION}
    ABIVERSION  ${KASTEN_ABI_VERSION}
    NO_TARGET_NAMESPACE
    NO_VERSIONED_INCLUDEDIR
)

target_compile_definitions(KastenCore PRIVATE -DTRANSLATION_DOMAIN=\"libkasten\")

ecm_qt_declare_logging_category(KastenCore
    HEADER "logging.hpp"
    IDENTIFIER "LOG_KASTEN_CORE"
    CATEGORY_NAME "kasten.core"
    DESCRIPTION "Kasten Core library"
    EXPORT OKTETA
)

macro(KASTENCORE_ADD_SUBLIBRARY _subdir)
    okteta_add_sublibrary(Core  NAMESPACE Kasten
        SUBDIR ${_subdir}
        ${ARGN}
    )
endmacro()

# kastencore_add_sublibrary(entity
#     BUILD_INCLUDEDIR
#     PUBLIC
#         AbstractEntity
#         Group
#         Person
# )

kastencore_add_sublibrary(document
    BUILD_INCLUDEDIR
    PUBLIC
        Versionable
#         UserListable

        AbstractModel
        AbstractModelSelection
        AbstractDocument
        AbstractDocumentFactory
        AbstractTool
        AbstractToolFactory

        DocumentVersionId
        DocumentVersionData
)

kastencore_add_sublibrary(io
    BUILD_INCLUDEDIR
    PUBLIC
        AbstractSyncToRemoteJob
        AbstractModelSynchronizer
        AbstractSyncWithRemoteJob
        AbstractSyncFromRemoteJob
        AbstractConnectJob
        AbstractModelStreamEncoder
        AbstractModelDataGenerator
        AbstractExportJob
        AbstractModelExporter
        ModelStreamEncodeThread
        ModelDataGenerateThread
        AbstractLoadJob
        AbstractModelSynchronizerFactory
)

kastencore_add_sublibrary(io/filesystem
    BUILD_INCLUDEDIR
    PUBLIC
        AbstractFileSystemSyncWithRemoteJob
        AbstractFileSystemSyncFromRemoteJob
        AbstractFileSystemSyncToRemoteJob
        AbstractModelFileSystemSynchronizer
        AbstractFileSystemConnectJob
        AbstractFileSystemLoadJob
        AbstractFileSystemExportJob
        ModelEncoderFileSystemExporter
        ModelEncoderFileSystemExportJob
)

kastencore_add_sublibrary(system
    BUILD_INCLUDEDIR
    PUBLIC
        AbstractOverwriteDialog
        AbstractSaveDiscardDialog

        JobManager
        DocumentManager
        DocumentCreateManager
        DocumentSyncManager
        ModelCodecManager
)

okteta_add_sublibrary(Core  NAMESPACE Kasten
    PUBLIC
        KastenCore
)

okteta_add_cmakeconfig(Core NAMESPACE Kasten
    DEPS
        Qt6Gui ${Qt6_VERSION}
        KF6KIO ${KF6_VERSION}
)

if(BUILD_TESTING)
    add_subdirectory(tests)
endif()
