# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem              1.0
PortGroup               cmake 1.1
PortGroup               qt5 1.0
PortGroup               compiler_blacklist_versions 1.0
PortGroup               github 1.0

epoch                   1
github.setup            nextcloud desktop 3.5.2 v
checksums               rmd160  8175c77b5ad78618740ada31b7531ef57f87a5fb \
                        sha256  161d82a4db5faabf3c69266b7b3aea1073ad98d14db6e3381fa1ae2a8fdef829 \
                        size    15432939
revision                0

name                    nextcloud-client
categories              www aqua
platforms               darwin
maintainers             nomaintainer
license                 GPL-2+
description             Desktop Syncing Client for Nextcloud
long_description \
    The Nextcloud Desktop Client is a tool to synchronize files from Nextcloud \
    server with your computer.
homepage                https://nextcloud.com/

use_xcode               yes
compiler.cxx_standard   2014

depends_lib-append      port:sqlite3 port:zlib port:qtkeychain-qt5

depends_build-append    path:lib/pkgconfig/librsvg-2.0.pc:librsvg

qt5.min_version         5.12
qt5.depends_component   qtmacextras qtquickcontrols2 qtwebsockets
qt5.depends_build_component \
                        qttools

patchfiles              patch-use-system-sqlite.diff \
                        patch-add-xcodeflags.diff \
                        patch-no-deployqt.diff \
                        patch-remove-inkscape.diff

# Fix builds pre macOS 11 - may be removed in future release
# Note that upstream patch doesn't work as-is; required updating to use preprocessor block, rather than runtime
# https://github.com/nextcloud/desktop/pull/4563/commits/4bdfe5927051741584b86ba6c45054f0679357d4
patchfiles-append       patch-fix-build-pre-macos-11.diff

cmake.install_prefix    ${applications_dir}

configure.args-append   -DCMAKE_INSTALL_NAME_DIR=${applications_dir}/Nextcloud.app/Contents/MacOS \
                        -DXCODEFLAGS="-IDECustomDerivedDataLocation=${workpath}/DerivedData" \
                        -DBUILD_UPDATER=OFF \
                        -DWITH_CRASHREPORTER=OFF \
                        -DBUILD_OWNCLOUD_OSX_BUNDLE=ON \
                        -DSVG_CONVERTER_DIR=${prefix}/bin

if {${os.major} < 13} {
    # Finder extension does not compile on 10.8
    configure.pre_args-append   -DBUILD_SHELL_INTEGRATION=OFF
}

post-destroot {
    ln -s ${applications_dir}/Nextcloud.app/Contents/MacOS/nextcloudcmd \
        ${destroot}${prefix}/bin/nextcloudcmd
}
