# -*- 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       boost 1.0
PortGroup       cmake 1.1
PortGroup       qt5 1.0
PortGroup       github 1.0

github.setup    quassel quassel 0.14.0
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision        0

categories      irc
license         GPL-2 GPL-3
maintainers     nomaintainer
homepage        https://quassel-irc.org

checksums       rmd160  cd320484bcbcbce82ffe6dee8deec2948058aa8c \
                sha256  4cc54083be0d5c2c63851114482b899b72f9f0a73f0101c2668f25fabcaffdea \
                size    6163460

depends_lib-append \
                path:lib/libssl.dylib:openssl \
                port:zlib

qt5.depends_component qtmultimedia
qt5.depends_build_component qttools

compiler.cxx_standard \
                2011
compiler.thread_local_storage yes

patchfiles      patch-no-dmg.diff \
                patch-fix-cmake-osx-architectures.diff

configure.args  -DWANT_CORE=OFF \
                -DWANT_QTCLIENT=OFF \
                -DWANT_MONO=OFF \
                -DWITH_KDE=OFF \
                -DWITH_WEBENGINE=OFF \
                -DUSE_CCACHE=OFF \
                -DUSE_QT5=ON \
                -DBUNDLE=ON \
                -DENABLE_SHARED=OFF

variant urlpreview description "Support for showing URL thumbnails" {
    qt5.depends_component qtwebengine
    configure.args-replace -DWITH_WEBENGINE=OFF -DWITH_WEBENGINE=ON
}

default_variants +urlpreview

if {${name} eq ${subport}} {
    description \
        Qt5 IRC client
    long_description \
        Quassel IRC is a modern, cross-platform IRC client. This port installs \
        the monolithic variant, which does not require a separate Quassel core.

    qt5.depends_runtime_component sqlite-plugin
    qt5.depends_component qtscript

    # QCA is needed for chat encryption (/keyx and friends)
    depends_lib-append port:qca-qt5-ossl

    configure.args-replace -DWANT_MONO=OFF -DWANT_MONO=ON

    destroot {
        copy "${build.dir}/Quassel.app" "${destroot}${applications_dir}"
        xinstall -d \
            "${destroot}${applications_dir}/Quassel.app/Contents/Resources"
        copy "${build.dir}/pics/${name}.icns" \
            "${destroot}${applications_dir}/Quassel.app/Contents/Resources"
    }
}

subport ${name}-client {
    description \
        Qt5 IRC client - client component
    long_description \
        Quassel IRC is a modern, cross-platform, distributed IRC client, \
        meaning that one (or multiple) client(s) can attach to and detach from \
        a central core - much like the popular combination of screen and a \
        text-based IRC client such as WeeChat, but graphical.

    configure.args-replace -DWANT_QTCLIENT=OFF -DWANT_QTCLIENT=ON

    destroot {
        copy "${build.dir}/Quassel Client.app" "${destroot}${applications_dir}"
        xinstall -d \
            "${destroot}${applications_dir}/Quassel Client.app/Contents/Resources"
        copy "${build.dir}/pics/${name}.icns" \
            "${destroot}${applications_dir}/Quassel Client.app/Contents/Resources"
    }
}
