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

EAPI=8

inherit cmake xdg

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

DESCRIPTION="A terminal app for desktop and mobile devices"
HOMEPAGE="https://gitlab.com/ubports/development/apps/${PN}"

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

DEPEND="
    dev-qt/qtgui:5
    gui-libs/qmltermwidget

"

RDEPEND="${DEPEND}"

BDEPEND="
    dev-build/cmake
    dev-build/cmake-extras
    dev-build/samurai
    dev-qt/qtdeclarative:5
"

S="${WORKDIR}/${PN}-v${PV}"

#PATCHES=(
#    "${FILESDIR}"/
#)

src_prepare() {
    eapply_user

    # remove ctest from the build
    sed -i '/enable_testing()/d' CMakeLists.txt || die
    sed -i '/add_subdirectory(tests)/d' CMakeLists.txt || die

    cmake_src_prepare
}

src_configure() {
    local mycmakeargs=(
        -DINSTALL_TESTS="OFF"
        -DCLICK_MODE="OFF"
    )

    cmake_src_configure
}

pkg_postinst() {
    xdg_pkg_postinst
}

pkg_postrm() {
    xdg_pkg_postrm
}