# Maintainer: Antonio Rojas <arojas@archlinux,org>

pkgname=krita
pkgver=6.0.2
_pkgver=${pkgver/beta/-beta}
pkgrel=1
pkgdesc='Edit and paint images'
arch=(x86_64)
url='https://krita.org'
license=(GPL3)
depends=(exiv2
         ffmpeg
         fftw
         fontconfig
         freetype2
         fribidi
         giflib
         glibc
         gsl
         harfbuzz
         imath
         kcolorscheme
         kcompletion
         kconfig
         kcoreaddons
         kcrash
         kguiaddons
         ki18n
         kitemviews
         kwidgetsaddons
         lcms2
         libgcc
         libjpeg-turbo
         libkdcraw
         libpng
         libstdc++
         libtiff
         libunibreak
         libwebp
         libx11
         libxkbcommon
         mlt
         opencolorio
         openexr
         openjpeg2
         qt6-5compat
         qt6-base
         qt6-declarative
         qt6-svg
         quazip-qt6
         wayland
         zlib)
makedepends=(boost
             eigen
             extra-cmake-modules
             immer
             kseexpr
             lager
             libheif
             libjxl
             libmypaint
             poppler-qt6
             python-pyqt6
             qt6-tools
             sip
             xsimd
             zug)
optdepends=('kimageformats: PSD support'
            'krita-plugin-gmic: GMic plugin'
            'kseexpr: SeExpr generator layer'
            'libheif: HEIF filter'
            'libjxl: JPEG-XL filter'
            'libmypaint: support for MyPaint brushes'
            'poppler-qt6: PDF filter'
            'python-pyqt6: for the Python plugins')
source=(https://download.kde.org/stable/krita/$_pkgver/$pkgname-$_pkgver.tar.xz{,.sig})
sha256sums=('1910d68a52b812314f2ebcea1d4ef494882dad6b02225fdec40d4b81fa691766'
            'SKIP')
validpgpkeys=('05D00A8B73A686789E0A156858B9596C722EA3BD'  # Boudewijn Rempt <foundation@krita.org>
              'E9FB29E74ADEACC5E3035B8AB69EB4CF7468332F'  # Dmitry Kazakov (main key) <dimula73@gmail.com>
              '064182440C674D9F8D0F6F8B4DA79EDA231C852B') # Stichting Krita Foundation <foundation@krita.org>

prepare() {
  sed -e 's|13.0|13.8|' -i $pkgname-$_pkgver/cmake/modules/SIPMacros.cmake # Update SIP ABI version
}

build() {
  cmake -B build -S $pkgname-$_pkgver \
    -DBUILD_KRITA_QT_DESIGNER_PLUGINS=ON \
    -DBUILD_TESTING=OFF \
    -DBUILD_WITH_QT6=ON \
    -DALLOW_UNSTABLE=QT6
  cmake --build build
}

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