# -*- 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       gitlab 1.0
PortGroup       cmake 1.1
PortGroup       boost 1.0
PortGroup       compiler_blacklist_versions 1.0

name            lib2geom-devel
conflicts       lib2geom
set my_name     lib2geom
gitlab.setup    inkscape ${my_name} 1.4
revision        0

categories      graphics
license         {LGPL-2.1 MPL-1.1}
maintainers     {devans @dbevans} {mascguy @mascguy} openmaintainer

description     2Geom is a computational geometry library intended for use with \
                2D vector graphics.
long_description \
                ${description} It concentrates on high-level algorithms, such as \
                computing the length of a curve or Boolean operations on paths.

checksums       rmd160  8e33a9a406058cb8ba95f3efa3cd39959970dd22 \
                sha256  717a87ce7f2192271a789c1273ae7b432856c522647b9fe33bb4dd662942b3ea \
                size    1287532

dist_subdir     ${my_name}

# this port only uses boost headers during build
# and does not link with any boost libraries
# no need to rebuild due to boost library ABI changes
boost.depends_type build
boost.version      1.81

# Patch to expose formal options for: Cython, GTK3
# Otherwise, those will be opportunistically pulled in, which we don't want.
patchfiles-append \
                patch-cmake-options.diff

depends_build-append \
                port:gettext \
                port:pkgconfig

depends_lib-append \
                path:lib/pkgconfig/cairo.pc:cairo \
                port:double-conversion \
                port:gettext-runtime \
                path:lib/pkgconfig/glib-2.0.pc:glib2 \
                port:gsl \
                port:ragel

# C++17 is required
compiler.cxx_standard 2017

#--------------------------------------------------------------------------------------------------
# Xcode Clang 10.x is based on LLVM 6.x. And it does not include an upstream fix, for the
# following (valid) scenario involving templates:
#
#   MyTemplate(some_arg);
#
# It can be sidestepped, by explicitly declaring a variable of that template type:
#
#   MyTemplate myVar(some_arg);
#
# But since this is an LLVM 6.x bug - and one that was ultimately fixed, after Xcode 10.x was
# released - it arguably shouldn't be necessary.
#
# The specific compilation error for this scenario is:
#   error: cannot use parentheses when declaring variable with deduced class template specialization type
#
# See: https://trac.macports.org/ticket/68036
#--------------------------------------------------------------------------------------------------
compiler.blacklist-append \
                {clang >= 1000 < 1100}

# Need no-invalid-constexpr for v1.3. Remove if/when fixed in future.
if { [string match *clang* ${configure.compiler}] } {
    configure.cxxflags-append \
                -Wno-invalid-constexpr \
                -Wno-error=unknown-warning-option \
                -Wno-unknown-warning-option
}

configure.args-append \
                -D2GEOM_BUILD_SHARED:BOOL=ON \
                -D2GEOM_TESTING:BOOL=OFF \
                -D2GEOM_USE_GPL_CODE:BOOL=OFF \
                -DWITH_CYTHON:BOOL=OFF \
                -DWITH_GTK3:BOOL=OFF

variant apidocs description {Generate and install HTML API documentation} {
    depends_build-append \
                path:bin/doxygen:doxygen \
                path:bin/dot:graphviz

    post-build {
        system -W ${worksrcpath} "${prefix}/bin/doxygen"
    }

    post-destroot {
        set docdir ${prefix}/share/doc/${name}/html

        xinstall -d ${destroot}${docdir}
        xinstall -m 644 \
            {*}[glob ${worksrcpath}/doc/html/*] \
            ${destroot}${docdir}
    }
}
