# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=qt6-quick3d
_pkgver=6.11.0
pkgver=${_pkgver/-/}
pkgrel=1
arch=(x86_64 aarch64)
url='https://www.qt.io'
license=(GPL-3.0-only
         LGPL-3.0-only
         LicenseRef-Qt-Commercial
         Qt-GPL-exception-1.0)
pkgdesc='Qt module and API for defining 3D content in Qt Quick'
depends=(gcc-libs
         glibc
         openxr
         qt6-base
         qt6-declarative
         qt6-quicktimeline
         qt6-shadertools
         zlib)
makedepends=(assimp
             cmake
             git
             ninja
             vulkan-headers)
optdepends=('assimp: assimp import plugin')
groups=(qt6)
_pkgfn=${pkgname/6-/}
source=(git+https://github.com/qt/$_pkgfn#tag=v$_pkgver
        assimp-6.patch)
sha256sums=('50c9b1fd8575d1c65d8626bf0ef8b5ee3d9aee408f8d66d5d0275d98e6ff47a9'
            '394b5f26877477c4ceba252c06a6a2101f5e99e3dddc01cc8831e7fa7d70f797')

prepare() {
  patch -d $_pkgfn -p1 < assimp-6.patch
}

build() {
  cmake -B build -S $_pkgfn -G Ninja \
    -DCMAKE_MESSAGE_LOG_LEVEL=STATUS
  cmake --build build
}

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

  install -d "$pkgdir"/usr/share/licenses
  ln -s /usr/share/licenses/qt6-base "$pkgdir"/usr/share/licenses/$pkgname
}
