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

github.setup        davisking dlib 20.0.1 v
revision            0
categories          math
maintainers         nomaintainer
license             MIT

description         Modern C++ toolkit for machine learning, image \
                    processing, and more.

long_description    Dlib is a modern C++ toolkit containing machine \
                    learning algorithms and tools for creating \
                    complex software in C++ to solve real world \
                    problems. It is used in both industry and \
                    academia in a wide range of domains including \
                    robotics, embedded devices, mobile phones, \
                    and large high performance computing \
                    environments. Dlib's open source licensing allows \
                    you to use it in any application, free of charge.

homepage            https://dlib.net

github.tarball_from archive

checksums           rmd160  f6d8fa394512ff4d12b59c2765b62d960226de85 \
                    sha256  dab5b4ec4b68bd7dc128a1fb7900723f89d2da107e44cd5def7d38fc57252a9d \
                    size    19011784

depends_lib-append  path:lib/libavcodec.dylib:ffmpeg \
                    port:giflib \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libjxl \
                    port:libpng \
                    path:lib/libopenblas.dylib:OpenBLAS \
                    port:sqlite3 \
                    port:webp \
                    port:xorg-libice \
                    port:xorg-libsm \
                    port:xorg-libX11 \
                    port:xorg-libXext \
                    port:zlib

require_active_variants \
                    path:lib/libopenblas.dylib:OpenBLAS lapack

compiler.cxx_standard   2014
compiler.thread_local_storage yes

configure.args      -DBUILD_SHARED_LIBS=ON

# create Python subports
set python_versions {310 311 312 313 314}
foreach v ${python_versions} {
    subport py${v}-${github.project} {
        PortGroup   python 1.0

        categories-prepend  math
        python.default_version  ${v}

        master_sites ${github.master_sites}
    }
}

# Python bindings for supported Python versions
if {[string match "py*" ${subport}]} {
    categories-append   math
    description     Python ${python.branch} bindings for {*}${description}
    long_description\
                    This package provides Python ${python.branch}\
                    bindings, modules, and scripts.

    depends_build-append \
                    port:py${python.version}-packaging \
                    port:py${python.version}-setuptools

    depends_test-append \
                    port:py${python.version}-pytest

    build.dir       ${worksrcpath}
    build.post_args

    python.pep517   no
    destroot.target install

    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} README.md \
            ${destroot}${docdir}
    }

    # FIXME: 4 tests fail on ppc, likely due to precision:
    # https://github.com/davisking/dlib/issues/2933
    test.run        yes
    test.env        PYTHONPATH=[glob -nocomplain ${worksrcpath}/build/lib*]

    livecheck.type  none
}
