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

EAPI=8

inherit lomiri 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="Service that provides call log and conversation history"
HOMEPAGE="https://gitlab.com/ubports/development/core/${PN}"
LICENSE="GPL-3"

DEPEND="
    dev-libs/glib
    dev-libs/libphonenumber
    net-libs/telepathy-qt
    dev-qt/qtpim:5
"

RDEPEND="${DEPEND}"

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

PATCHES=(
    "${FILESDIR}"/001_cmake_fix_add_command.patch
    "${FILESDIR}"/002_fix_dump_schema.patch
)

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

    local mycmakeargs=(
        -DENABLE_WERROR=ON
    )

    # remove hard coded enabling of tests
    sed -i "/include(CTest)/d" CMakeLists.txt  || die
    cmake_comment_add_subdirectory tests

    # remove hard coded code coverage
    sed -i "/find_package(CoverageReport)/d" CMakeLists.txt  || die

    lomiri_src_configure
}