pkgname=unisic
# Plain literal on purpose: OBS parses the PKGBUILD server-side (no bash
# ${var:-default} expansion) and its set_version service rewrites this line
# at build time; the CI release job seds in the CMakeLists version likewise.
pkgver=0.6.4
pkgrel=1
pkgdesc='Capture, annotate, record and share your screen on Linux Wayland'
arch=('x86_64')
url='https://github.com/unisic/unisic'
license=('GPL-3.0-or-later')
# tesseract/leptonica/layer-shell-qt are hard deps: the CI build links them
# (HAVE_TESSERACT / HAVE_LAYERSHELL), so the binary needs the libs at runtime.
# libinput (keystroke/click overlays link libinput.so.10) and
# hicolor-icon-theme (the icons land in its hierarchy) were missing up to
# 0.7.5 - namcap on the AUR recipes caught them. Both are present on any real
# Wayland desktop, so nobody hit it, but an unstated dependency is a bug.
depends=('qt6-base' 'qt6-declarative' 'qt6-svg' 'qt6-wayland' 'pipewire' 'ffmpeg' 'wl-clipboard' 'xdg-desktop-portal'
         'tesseract' 'leptonica' 'layer-shell-qt' 'zxing-cpp' 'kguiaddons' 'libinput' 'hicolor-icon-theme'
         'libx11' 'libxext' 'libxfixes' 'libxcb')
# plasma-wayland-protocols carries zkde-screencast-unstable-v1.xml, which
# HAVE_KWIN_SCREENCAST (KWin-native recording, no portal share dialog) is
# generated from. Build-time only: the generated client code is linked in.
makedepends=('cmake' 'ninja' 'pkgconf' 'qt6-tools' 'plasma-wayland-protocols' 'tesseract' 'leptonica' 'layer-shell-qt' 'wayland' 'zxing-cpp' 'kguiaddons' 'libx11' 'libxext' 'libxfixes' 'libxcb' 'libinput')
optdepends=('curl: FTP/SFTP upload destinations'
            'xdg-desktop-portal-kde: KDE portal backend for screenshots and screen recording'
            'xdg-desktop-portal-gtk: generic portal backend on non-KDE desktops'
            'tesseract-data-pol: Polish OCR language data'
            'tesseract-data-eng: English OCR language data')
install=unisic.install
source=("${pkgname}-${pkgver}.tar.gz")
sha256sums=('SKIP')

build() {
    # Without an explicit build number CMake defaults UNISIC_BUILD to "dev",
    # which also flips UNISIC_DEV_BUILD to ON — a packaged build must be a
    # release build with a real number in the sidebar footer.
    export UNISIC_BUILD_NUMBER="${UNISIC_BUILD_NUMBER:-${pkgver}-${pkgrel}}"
    cmake -S "${srcdir}/${pkgname}-${pkgver}" -B build -G Ninja \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DUNISIC_DEV_BUILD=OFF
    cmake --build build
}

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