# Template file for 'qt6-multimedia'
pkgname=qt6-multimedia
version=6.8.2
revision=1
build_style=cmake
configure_args="-DQT_FEATURE_gstreamer=ON"
hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"
makedepends="qt6-base-private-devel qt6-declarative-private-devel
 qt6-quick3d-private-devel qt6-shadertools-devel
 pulseaudio-devel ffmpeg6-devel libva-devel
 libglib-devel gst-plugins-bad1-devel gst-plugins-base1-devel"
short_desc="Cross-platform application and UI framework - multimedia"
maintainer="John <me@johnnynator.dev>"
license="(LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only) AND GPL-3.0-only with Qt-GPL-exception-1.0"
homepage="https://qt.io/"
distfiles="http://download.qt.io/official_releases/qt/${version%.*}/${version}/submodules/qtmultimedia-everywhere-src-${version}.tar.xz"
checksum=34f561fdc07b158bcc4ad040b596fc6086c48908060e854b473b557e4feb1569

if [ "$XBPS_MACHINE" = "i686" ]; then
	CXXFLAGS="-DPFFFT_SIMD_DISABLE=1 -DDISABLE_SIMD=1"
	CFLAGS="-DPFFFT_SIMD_DISABLE=1 -DDISABLE_SIMD=1"
fi

subpackages="qt6-multimedia-private-devel qt6-multimedia-devel"

do_check() {
	cd build
	local broken="tst_qmediaformat|tst_qaudiodecoderbackend"
	broken+="|tst_qaudiodevice|tst_qaudiosource|tst_qaudiosink"
	broken+="|tst_qmediaplayerbackend|tst_qmediacapturesession"
	broken+="|tst_qcamerabackend|tst_qquickvideooutput"
	broken+="|tst_qquickvideooutput_window|tst_qwindowcapturebackend"
	ctest -E "($broken)"
}

post_install() {
	rm -rf ${DESTDIR}/usr/tests
}

qt6-multimedia-private-devel_package() {
	depends="qt6-multimedia-devel>=${version}_${revision}"
	short_desc+=" - private development files"
	pkg_install() {
		for dir in $(cd ${DESTDIR} && find usr/include -type d -name private); do
			vmove "$dir"
		done
		vmove "usr/lib/cmake/*Private"
		vmove "usr/lib/qt6/metatypes/*private_*_metatypes.json"
		vmove "usr/lib/qt6/mkspecs/modules/*_private.pri"
		vmove "usr/lib/qt6/modules/*Private.json"
	}
}

qt6-multimedia-devel_package() {
	depends="${sourcepkg}>=${version}_${revision} qt6-base-devel>=${version}_1"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove usr/lib/qt6/metatypes
		vmove usr/lib/pkgconfig
		vmove usr/lib/qt6/mkspecs
		vmove usr/lib/qt6/qml/QtMultimedia/plugins.qmltypes
		vmove "usr/lib/*.so"
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.prl"
	}
}
