# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=kcolorpicker
pkgver=0.3.1
pkgrel=0
pkgdesc="Qt based Color Picker with popup menu"
url="https://github.com/ksnip/kColorPicker"
arch="all"
license="LGPL-3.0-or-later"
depends_dev="qt6-qtbase-dev"
makedepends="$depends_dev
	cmake
	samurai
	"
checkdepends="xvfb-run"
subpackages="$pkgname-dev"
source="https://github.com/ksnip/kColorPicker/archive/v$pkgver/kcolorpicker-$pkgver.tar.gz"
builddir="$srcdir/kColorPicker-$pkgver"

build() {
	cmake -B build -G Ninja \
		-DBUILD_WITH_QT6=ON \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=TRUE \
		-DBUILD_TESTS=ON \
		-DBUILD_EXAMPLE=OFF
	cmake --build build
}

check() {
	xvfb-run -a ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mkdir -p "$pkgdir"/usr/lib/cmake/kColorPicker
	ln -s /usr/lib/cmake/kColorPicker-Qt5/kColorPicker-Qt5Config.cmake \
		"$pkgdir"/usr/lib/cmake/kColorPicker/kColorPickerConfig.cmake
	ln -s /usr/lib/cmake/kColorPicker-Qt5/kColorPicker-Qt5Config-version.cmake \
		"$pkgdir"/usr/lib/cmake/kColorPicker/kColorPickerConfig-version.cmake
	ln -s /usr/lib/cmake/kColorPicker-Qt5/kColorPicker-Qt5-targets-minsizerel.cmake \
		"$pkgdir"/usr/lib/cmake/kColorPicker/kColorPicker-Qt5-targets-minsizerel.cmake
	ln -s /usr/lib/cmake/kColorPicker-Qt5/kColorPicker-Qt5-targets.cmake \
		"$pkgdir"/usr/lib/cmake/kColorPicker/kColorPicker-Qt5-targets.cmake
}

sha512sums="
bb91d8dfa555e60206665453cde8f4f7536154fe7660aeab276c0a509bdb19caf04276eb0935537b390657881db020ecb943de3e5b8d286f3cd7d89bf7010674  kcolorpicker-0.3.1.tar.gz
"
