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

_variant=-${KF5_VARIANT:-shared}
source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks5
_realname=umbrello
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=25.08.3
pkgrel=1
pkgdesc="UML modeller (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://apps.kde.org/umbrello/"
msys2_repository_url="https://invent.kde.org/sdk/umbrello/"
msys2_references=(
  'archlinux: umbrello'
)
license=('spdx:GPL-2.0-or-later AND LGPL-2.0-or-later AND GFDL-1.3-no-invariants-only')
groups=("${MINGW_PACKAGE_PREFIX}-kdesdk")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-clang-tools-extra"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-graphviz"
             "${MINGW_PACKAGE_PREFIX}-extra-cmake-modules"
             "${MINGW_PACKAGE_PREFIX}-kdoctools-qt5${_namesuff}"
             "${MINGW_PACKAGE_PREFIX}-icoutils")
depends=("${MINGW_PACKAGE_PREFIX}-ki18n-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-ktextwidgets-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-ktexteditor-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kio-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kxmlgui-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-knotifications-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kconfig-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kcoreaddons-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kdbusaddons-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-kcrash-qt5${_namesuff}"
         "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme")
source=("https://download.kde.org/stable/release-service/${pkgver}/src/${_realname}-${pkgver}.tar.xz"{,.sig})
sha256sums=('9048a6159c8486248a95b956ed08c1954ac21708b89a81fe6a3b0aa7a5207a2c'
            'SKIP')
validpgpkeys=(CA262C6C83DE4D2FB28A332A3A6A4DB839EAA6D7  # Albert Astals Cid <aacid@kde.org>
              F23275E4BF10AFC1DF6914A6DBD2CE893E2D1C87  # Christoph Feck <cfeck@kde.org>
              D81C0CB38EB725EF6691C385BB463350D6EF31EF) # Heiko Becker <heiko.becker@kde.org>

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

  declare -a _extra_config
  if check_option "debug" "n"; then
    _extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    _extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

  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 \
    -DBUILD_PHP_IMPORT=OFF \
    -DECM_DIR=${MINGW_PREFIX}/share/ECM \
    "${_extra_config[@]}" \
    ../${_realname}-${pkgver}

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

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

  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install .
}
