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

EAPI=8

EGIT_REPO_URI="https://gitlab.com/luciocarreras/sayonara-player.git"

inherit cmake git-r3 xdg

DESCRIPTION="Small, clear and fast Qt-based audio player"
HOMEPAGE="https://sayonara-player.com"
SRC_URI=""

LICENSE="GPL-3+"
SLOT="0"
KEYWORDS=""
IUSE="doc test"
RESTRICT="!test? ( test )"

RDEPEND="dev-qt/qtcore:5
	dev-qt/qtgui:5
	dev-qt/qtdbus:5
	dev-qt/qtnetwork:5
	dev-qt/qtsql:5
	dev-qt/qtsvg:5
	dev-qt/qtwidgets:5
	dev-qt/qtxml:5
	dev-libs/glib:2
	media-libs/taglib
	media-libs/gstreamer:1.0
	media-libs/gst-plugins-bad:1.0
	media-libs/gst-plugins-base:1.0
	media-libs/gst-plugins-good:1.0
	media-plugins/gst-plugins-soundtouch:1.0
	media-libs/libmtp:0=
	sys-libs/zlib:0="
DEPEND="${RDEPEND}
	dev-qt/qtsvg:5
	test? ( dev-qt/qttest:5 )"
BDEPEND="dev-qt/linguist-tools:5
	virtual/pkgconfig
	doc? ( app-text/doxygen )"

src_prepare() {
	# wrt 709450
	sed -i  -e '/execute_process(COMMAND gzip/d' \
		-e '/install(FILES/s/sayonara.1.gz/sayonara.1/' \
		-e '/install(FILES/s/sayonara-ctl.1.gz/sayonara-ctl.1/' \
		-e '/install(FILES/s/sayonara-query.1.gz/sayonara-query.1/' \
		resources/CMakeLists.txt || die "sed failed for resources/CMakeLists.txt"

	# Remove failed tests
	sed -i  -e '/new_test(Covers\/CoverLocationTest.cpp)/d' \
		-e '/new_test(Tagging\/CoverTest.cpp  Tagging\/AbstractTaggingTest.cpp)/d' \
		-e '/new_test(Tagging\/EditorTest.cpp)/d' \
		-e '/new_test(Util\/StandardPathTest.cpp)/d' \
		test/CMakeLists.txt || die "sed failed for test/CMakeLists.txt"

	cmake_src_prepare
}

src_configure() {
	local mycmakeargs=(
		-DWITH_COTIRE="OFF"
		-DWITH_DOC="$(usex doc)"
		-DWITH_TESTS="$(usex test)"
	)
	cmake_src_configure
}