# Template file for 'fcitx5-qt'
pkgname=fcitx5-qt
version=5.0.11
revision=1
build_style=cmake
configure_args="-DENABLE_QT4=OFF -DENABLE_QT5=ON -DENABLE_QT6=ON
 -DQT_HOST_PATH=/usr"
hostmakedepends="cldr-emoji-annotation pkg-config gettext doxygen
 extra-cmake-modules qt5-qmake qt5-host-tools qt6-base-devel"
makedepends="libfcitx5-devel fmt-devel qt5-devel libxkbcommon-devel
 qt6-base-devel"
short_desc="Flexible Context-aware Input Tool with eXtension v5 - Qt"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="LGPL-2.1-or-later, BSD-3-Clause"
homepage="https://fcitx-im.org/wiki/Fcitx"
distfiles="https://download.fcitx-im.org/fcitx5/fcitx5-qt/fcitx5-qt-${version}.tar.xz"
checksum=7196798d4c6f9305c028dab30a31eb64566b9b47b1cb916518d33f3a0f053d62
lib32disabled=yes

if [ "$XBPS_TARGET_NOATOMIC8" ]; then
	configure_args+=" -DCMAKE_CXX_STANDARD_LIBRARIES=-latomic"
	makedepends+=" libatomic-devel"
fi

post_install() {
	local _file
	for _file in $(grep -rl 'SPDX-License-Identifier: BSD-3-Clause' qt5 qt6)
	do
		sed -n '/SPDX-FileCopyrightText/s/.*:/Copyright/p' "$_file"
	done | sort -u >LICENSE
	cat LICENSES/BSD-3-Clause.txt >>LICENSE
	vlicense LICENSE
}

fcitx5-qt5_package() {
	depends="fcitx5-qt-${version}_${revision}"
	short_desc+="5"
	pkg_install() {
		vmove usr/lib/fcitx5/qt5
		vmove usr/lib/qt5
		vmove "usr/libexec/*qt5-*"
		vmove "usr/lib/*Qt5*.so.*"
	}
}

fcitx5-qt5-devel_package() {
	depends="fcitx5-qt5>=${version}_${revision} qt5-devel"
	short_desc+="5 - development files"
	pkg_install() {
		vmove usr/include/Fcitx5Qt5
		vmove "usr/lib/cmake/Fcitx5Qt5*"
		vmove "usr/lib/*Qt5*.so"
	}
}

fcitx5-qt6_package() {
	depends="fcitx5-qt-${version}_${revision}"
	short_desc+="6"
	pkg_install() {
		vmove usr/lib/qt6
		vmove "usr/lib/*Qt6*.so.*"
	}
}

fcitx5-qt6-devel_package() {
	depends="fcitx5-qt6>=${version}_${revision} qt6-base-devel"
	short_desc+="6 - development files"
	pkg_install() {
		vmove usr/include/Fcitx5Qt6
		vmove "usr/lib/cmake/Fcitx5Qt6*"
		vmove "usr/lib/*Qt6*.so"
	}
}
