# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=quarter
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.1.0
pkgrel=1
pkgdesc="Coin GUI binding for Qt (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/coin3d/quarter"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-graphviz"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-coin"
         "${MINGW_PACKAGE_PREFIX}-qt5")
options=('!strip' 'staticlibs' '!buildflags')
source=("quarter-Quarter-${pkgver}.tar.gz::https://github.com/coin3d/quarter/archive/Quarter-${pkgver}.tar.gz"
        'quarter-1.1.0-use-cpack-off.patch'
        'quarter-1.1.0-pc-use-qt5.patch')
sha256sums=('392f0c13eea34b4044f4fdcba8757245365dec2c4055e73cf88b287154b81514'
            '52d203a5eabd4d2e21f1cd7b99958633335f7cc547b96e99f2fae42e22315c81'
            '92c3f6074c7c25d5d0cd0cef62443527b74390883a8d61c5610e67c0cf85e36a')

prepare() {
  cd "${srcdir}/quarter-Quarter-${pkgver}"
  patch -p1 -i "${srcdir}/quarter-1.1.0-use-cpack-off.patch"
  patch -p1 -i "${srcdir}/quarter-1.1.0-pc-use-qt5.patch"
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DQUARTER_BUILD_PLUGIN=OFF \
    -DQUARTER_BUILD_EXAMPLES=OFF \
    -DQUARTER_BUILD_DOCUMENTATION=ON \
    -DQUARTER_USE_CPPFLAGS=-DQUARTER_DLL \
    ../quarter-Quarter-${pkgver}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/quarter-Quarter-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}

# vim:set ts=2 sw=2 et:
