# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake

if [[ ${PV} == 9999 ]]; then
    KEYWORDS=""
    EGIT_REPO_URI="https://gitlab.com/ubports/development/core/${PN}.git"
    inherit git-r3
else
    KEYWORDS="~amd64"
    SRC_URI="https://gitlab.com/ubports/development/core/${PN}/-/archive/${PV}/${P}.tar.gz"
fi

DESCRIPTION="Provides a service for downloading files while an application is suspended"
HOMEPAGE="https://gitlab.com/ubports/development/core/${PN}"

LICENSE="GPL-3"
SLOT="0"

DEPEND="
    lomiri-base/lomiri-api
    lomiri-base/gsettings-qt
    dev-qt/qtsql:5
    sys-apps/dbus
    sys-apps/systemd
    sys-libs/libapparmor
"

RDEPEND="${DEPEND}"

BDEPEND="
    dev-build/cmake
    dev-build/cmake-extras
    dev-build/samurai
    dev-cpp/glog:0/2
    >=dev-libs/boost-1.88.0
    dev-qt/qtdeclarative:5
"

PATCHES=(
    "${FILESDIR}"/001-cmake_fix_quality.patch
)

src_prepare() {
    eapply_user

    # remove ctest from the build
    sed -i '/include(CTest)/d' CMakeLists.txt || die

    cmake_src_prepare
}

src_configure() {
    # disable QT6 support at the moment
    local mycmakeargs=(
        -DENABLE_QT6="OFF"
        -DENABLE_COVERAGE="OFF"
        -DENABLE_DOC="OFF"
        -DENABLE_WERROR="OFF"
    )

    cmake_src_configure
}