# Maintainer (MSYS2): Gary Wang <wzc782970009@gmail.com>
# Contributor: Zach Bacon <zachbacon@vba-m.com>

_variant=-${KF5_VARIANT:-shared}
source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks5
_kde_f5_init_package "${_variant}" "kirigami-addons"
pkgver=0.11.0
pkgrel=1
pkgdesc="Add-ons for the Kirigami framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://invent.kde.org/libraries/kirigami-addons'
msys2_references=(
  'archlinux: kirigami-addons5'
)
license=('GPL' 'LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-extra-cmake-modules"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-ki18n-qt5")
depends=("${MINGW_PACKAGE_PREFIX}-kirigami2-qt5")
if [ "${_variant}" = "-static" ]; then
  _kde_f5_add_depends "${_variant}" "${MINGW_PACKAGE_PREFIX}-qt5${_namesuff}"
else
  makedepends+=("${MINGW_PACKAGE_PREFIX}-qt5-tools")
  depends+=("${MINGW_PACKAGE_PREFIX}-qt5-base"
            "${MINGW_PACKAGE_PREFIX}-qt5-declarative"
            "${MINGW_PACKAGE_PREFIX}-qt5-quickcontrols2"
            "${MINGW_PACKAGE_PREFIX}-qt5-svg")
fi
groups=("${MINGW_PACKAGE_PREFIX}-kf5")
source=("https://download.kde.org/stable/${_basename}/${_basename}-${pkgver}.tar.xz"{,.sig})
sha256sums=('05296c5afbe6804308bf9c0d2751f3b748b40d00fa784946d1dcdf3af4bffbad'
            'SKIP')
validpgpkeys=('39FFA93CAE9C6AFC212AD00202325448204E452A') # Carl Schwan <carl@carlschwan.eu>

build() {
  mkdir -p build-${MSYSTEM}${_variant} && cd build-${MSYSTEM}${_variant}

  local -a extra_config
  if [ "${_variant}" = "-static" ]; then
    extra_config+=( -DBUILD_SHARED_LIBS=NO )
  fi

  _kde_f5_build_env
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G "Ninja" \
    -DCMAKE_BUILD_TYPE=$(_kde_f5_CMAKE_BUILD_TYPE) \
    "${_kde_f5_KDE_INSTALL_DIRS[@]}" \
    -DBUILD_QCH=OFF \
    -DBUILD_TESTING=OFF \
    -DECM_DIR=${MINGW_PREFIX}/share/ECM \
    "${extra_config[@]}" \
    ../${_basename}-${pkgver}

  ${MINGW_PREFIX}/bin/cmake.exe --build ./
}

package() {
  cd build-${MSYSTEM}${_variant}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install ./
}
