# Maintainer:

_realname=lib3mf
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}-devel")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}-devel")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-devel")
pkgver=2.1.1
pkgrel=1
pkgdesc='Lib3MF is the reference implementation of the 3D Manufacturing Format file standard http://3mf.io'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://github.com/3MFConsortium/lib3mf'
license=('BSD 2-Clause')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
options=(!staticlibs strip)
source=("${_realname}-${pkgver}.tar.gz"::"${url}/archive/v${pkgver}.tar.gz")
sha256sums=('314d2b3754de3c5519dcd57c8d7bcf450103ee91891a5a840343a03961accd89')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

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} \
    -DLIB3MF_TESTS=OFF \
    ../${_realname}-${pkgver}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
