# -*- 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

name                oofcanvas
version             1.2.0
revision            0

license             public-domain
categories          graphics
maintainers         {@snarkhunter nist.gov:stephen.langer} \
                    nist.gov:oof_manager openmaintainer

description         C++ library that does some of what libgnomecanvas used to do
long_description    OOFCanvas is a replacement for libgnomecanvas, designed \
                    for use in OOF2, but hopefully useful elsewhere. OOFCanvas \
                    is based on Cairo and, unlike libgnomecanvas, is compatible\
                    with gtk3. The canvas is a drawing area that can display a \
                    variety of shapes, including text. It can be scrolled, \
                    zoomed, and printed.  Items drawn on the canvas can be \
                    selected with the mouse. Note that OOFCanvas is not a \
                    drop-in replacement for libgnomecanvas.  It's also not a \
                    full-fledged gtk widget.  It's a set of classes that does \
                    some of what libgnomecanvas did and uses gtk.

homepage            https://www.ctcms.nist.gov/oof/oofcanvas
master_sites        ${homepage}/source

checksums           rmd160 35a4efc8aedfe00d9a1b479f2e7ceebee9d97293 \
                    sha256 765052341960736ca7a4fe1630725f54a32c3f68933ff219b356a5d01938c40d \
                    size 103322

compiler.cxx_standard 2017
cmake.build_type    Release

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     "source/oofcanvas-(\\d+(?:\\.\\d+)*).tar.gz"

# clang 503.0.40 provided by Xcode 5.1.1 supports C++11 but apparently not <type_traits>
# fatal error: 'type_traits' file not found
# #include <type_traits>
compiler.blacklist-append {clang < 600.0.57}

depends_build       path:bin/cmake:cmake port:pkgconfig port:swig-python

depends_lib-append  path:lib/pkgconfig/gtk+-3.0.pc:gtk3 port:cairomm

set python_versions {310 311 312 313 314}

foreach v ${python_versions} {
    set minor [string range ${v} 1 end]
    # This variant conflicts with all other python variants
    set conflictversions [lsearch -all -inline -not ${python_versions} $v]
    set conflictswith {}
    foreach cv ${conflictversions} {
        lappend conflictswith python$cv
    }
    variant python${v} description "Build the API for Python 3.${minor}" \
        conflicts {*}$conflictswith \
        [ subst {
            depends_lib-append   port:python${v} port:py${v}-gobject3
            configure.args-append \
              -DOOFCANVAS_PYTHON_VERSION=3.$minor \
              -DOOFCANVAS_SYSTEM_INSTALL=ON
        }]
}

variant magick description {Add support for ImageMagick images} {
    configure.args-append -DOOFCANVAS_USE_IMAGEMAGICK=ON
    depends_lib-append     port:ImageMagick
}

variant numpy description {Add support for NumPy images} {
    depends_lib-append    port:py${v}-scikit-image
    configure.args-append -DOOFCANVAS_USE_NUMPY=ON
}

# python314 is the default variant if no other python variant is set
set vactive 0
foreach v ${python_versions} {
    if [variant_isset python$v] {
        set vactive 1
    }
}
if { !$vactive } {
    default_variants +numpy +python314
} else {
    default_variants +numpy
}

