# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgbase=qcoro
pkgname=(qcoro-qt5
         qcoro-qt6)
pkgver=%version%
pkgrel=%release%
pkgdesc='C++ Coroutines for Qt'
arch=(x86_64)
url='https://github.com/danvratil/qcoro'
license=(MIT)
depends=(gcc-libs
         glibc)
makedepends=(cmake
             qt5-declarative
             qt5-websockets
             qt6-declarative
             qt6-websockets)
source=(https://github.com/danvratil/qcoro/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('b7c8f00273ad27d85814bf4ec93eb6922c75656800a61d11854d36355a4a1aec')

build() {
  cmake -B build5 -S $pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_QT_VERSION=5 \
    -DBUILD_SHARED_LIBS=ON
  cmake --build build5

  cmake -B build6 -S $pkgbase-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_QT_VERSION=6 \
    -DBUILD_SHARED_LIBS=ON
  cmake --build build6
}

package_qcoro-qt5() {
  depends+=(qt5-base
            qt5-declarative
            qt5-websockets)
  DESTDIR="$pkgdir" cmake --install build5
  install -Dm644 $pkgbase-$pkgver/LICENSES/MIT.txt -t "$pkgdir"/usr/share/licenses/$pkgname
}

package_qcoro-qt6() {
  depends+=(qt6-base
            qt6-declarative
            qt6-websockets)
  DESTDIR="$pkgdir" cmake --install build6
  install -Dm644 $pkgbase-$pkgver/LICENSES/MIT.txt -t "$pkgdir"/usr/share/licenses/$pkgname
}
