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

EAPI=8

inherit cmake qmake-utils

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="Mediates and multiplexes access to biometric devices"
HOMEPAGE="https://gitlab.com/ubports/development/core/${PN}"

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

DEPEND="
    dev-libs/glib
    dev-libs/dbus-cpp
    dev-libs/process-cpp
    sys-apps/systemd
    sys-libs/libapparmor
"

RDEPEND="${DEPEND}"

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

PATCHES=(
    "${FILESDIR}"/001-cmake_fix_quality.patch
    "${FILESDIR}"/002-boost_1.88-asio.patch
)

src_prepare() {
    eapply_user

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

    cmake_src_prepare
}

src_configure() {
    # add 'qmlplugindump' to PATH
    export PATH="$(qt5_get_bindir):${PATH}"

    local mycmakeargs=(
        -DUSE_SYSTEMD="ON"
    )

    cmake_src_configure
}