# -*- 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 19.24.6 v
revision            1
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            http://dlib.net

checksums           rmd160  cd4272ba15e8fac095fd9a5fd5da8c3dce39d44a \
                    sha256  22513c353ec9c153300c394050c96ca9d088e02966ac0f639e989e50318c82d6 \
                    size    18927196
github.tarball_from archive

compiler.cxx_standard   2014
compiler.thread_local_storage yes

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:webp \
                    port:xorg-libice \
                    port:xorg-libsm \
                    port:xorg-libXext

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

configure.cxxflags-append \
                    -fvisibility=hidden \
                    -fvisibility-inlines-hidden

cmake.build_type    Release

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

        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_lib-append \
                    port:sqlite3

    depends_build-append \
                    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
}
