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

EAPI=8

inherit cmake-multilib xdg

if [[ ${PV} == *9999 ]] ; then
	EGIT_REPO_URI="https://github.com/strukturag/${PN}.git"
	inherit git-r3
else
	SRC_URI="https://github.com/strukturag/libde265/releases/download/v${PV}/${P}.tar.gz"
	KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86"
fi

DESCRIPTION="Open h.265 video codec implementation"
HOMEPAGE="https://github.com/strukturag/libde265"

LICENSE="GPL-3"
SLOT="0"
IUSE="enc265 dec265 sdl tools debug"
# IUSE+=" sherlock265" # Require libvideogfx or libswscale

RDEPEND="
	dec265? (
		sdl? ( media-libs/libsdl2 )
	)"

# Sherlock265 require libvideogfx or libswscale
#RDEPEND+="
#	sherlock265? (
#		media-libs/libsdl
#		dev-qt/qtcore:5
#		dev-qt/qtgui:5
#		dev-qt/qtwidgets:5
#		media-libs/libswscale
#	)
#"

DEPEND="${RDEPEND}"
BDEPEND="dec265? ( virtual/pkgconfig )"

# Sherlock265 require libvideogfx or libswscale
#BDEPEND+=" sherlock265? ( virtual/pkgconfig )"

multilib_src_configure() {
	local mycmakeargs=(
		-DENABLE_SDL=$(usex sdl)
		-DENABLE_DECODER=$(usex dec265)
		-DENABLE_ENCODER=$(usex enc265)
		-DENABLE_SHERLOCK265=$(usex tools)
		-DENABLE_INTERNAL_DEVELOPMENT_TOOLS=$(usex tools)
		-DWITH_FUZZERS=OFF
	)

	cmake_src_configure
}