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

github.setup        Chlumsky msdfgen 1.9 v
github.tarball_from archive
revision            0

categories          graphics textproc games devel print
license             MIT
maintainers         @jasonliu--

description         multi-channel signed distance field generator
long_description    MSDFgen is a utility for generating signed \
                    distance fields from vector shapes and font \
                    glyphs, which serve as a texture representation \
                    that can be used in real-time graphics to \
                    efficiently reproduce said shapes. This is often \
                    applicable to, for example, using texture maps to \
                    represent \"line-art\" images, such as text, \
                    signs, and UI elements, that need to be rendered \
                    in real-time in computer games.

checksums           rmd160  849ca3125c1122e9f03eed2debf1076648b0f059 \
                    sha256  909eb88c71268dc00cdda244a1fa40a0feefae45f68a779fbfddd5463559fa40 \
                    size    1807089

compiler.cxx_standard   2011

depends_lib-append      port:freetype \
                        port:libpng \
                        port:zlib

configure.args-append   -DFREETYPE_WITH_PNG=ON \
                        -DBUILD_SHARED_LIBS=ON

post-destroot {
    # Create a pkg-config file (needed by Godot)
    xinstall -d ${destroot}${prefix}/lib/pkgconfig
    set fp [open ${destroot}${prefix}/lib/pkgconfig/${name}.pc w]
    foreach line [list \
        "prefix=${prefix}" \
        "exec_prefix=\${prefix}" \
        "libdir=\${prefix}/lib" \
        "includedir=\${prefix}/include" \
        "" \
        "Name: ${name}" \
        "Description: ${description}" \
        "URL: ${homepage}" \
        "Version: ${version}" \
        "" \
        "Requires:" \
        "Requires.private: freetype2 libpng zlib" \
        "Libs: -L\${libdir} -l${name}" \
        "Cflags: -I\${includedir}/${name}" \
    ] {
        puts $fp $line
    }
    close $fp
}

variant openmp description {Enable OpenMP support} {
    compiler.openmp_version     3.1

    configure.args-append       -DMSDFGEN_USE_OPENMP=ON

    if {[string match *clang* ${configure.compiler}]} {
        configure.ldflags-append \
                                -L${prefix}/lib/libomp -lomp
    }
}

default_variants    +openmp