# Description: Nextcloud desktop client
# URL: https://nextcloud.com/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: libevent librsvg pciutils qtkeychain
# Optional: doxygen karchive qtwebengine

name=nextcloud-client
version=3.9.2
release=1
source=(https://github.com/nextcloud/desktop/archive/v$version/$name-$version-$release.tar.gz
  4875.patch)

build() {
  # do not hard depend on qtwebengine
  patch -Rp1 -d desktop-$version -i $SRC/4875.patch

  # you need both librsvg and qtwebengine to build the gui client
  prt-get isinst karchive librsvg qtwebengine && \
    PKGMK_NCC+=' -D SVG_CONVERTER=/usr/bin/rsvg-convert' || \
    PKGMK_NCC+=' -D BUILD_GUI=OFF'

  cmake -S desktop-$version -B build -G Ninja $PKGMK_NCC \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_INSTALL_LIBDIR=lib \
    -D CMAKE_INSTALL_SYSCONFDIR=/usr/etc/nextcloud \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
    -D CMAKE_C_FLAGS_RELEASE="$CFLAGS" \
    -D APPLICATION_HELP_URL="https://crux.nu/bugs/" \
    -D BUILD_SHELL_INTEGRATION_DOLPHIN=OFF \
    -D BUILD_SHELL_INTEGRATION_NAUTILUS=OFF \
    -D BUILD_TESTING=OFF \
    -D BUILD_UPDATER=OFF \
    -Wno-dev
  cmake --build build
  DESTDIR=$PKG cmake --install build

  rm -rf $PKG/usr/share/nextcloud
}
