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.
depends=('qt6-base' 'qt6-declarative' 'qt6-svg' 'qt6-wayland' 'pipewire' 'ffmpeg' 'wl-clipboard' 'xdg-desktop-portal'
         'tesseract' 'leptonica' 'layer-shell-qt' 'zxing-cpp' 'kguiaddons')
makedepends=('cmake' 'ninja' 'pkgconf' 'qt6-tools' 'tesseract' 'leptonica' 'layer-shell-qt' 'wayland' 'zxing-cpp' 'kguiaddons')
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
}
