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

name                ompl
version             2.0.0
revision            0
checksums           rmd160  79bfd15fa08793fb994a192a6d7b758cd220da44 \
                    sha256  7b6032ca69d0c69280ce3872737c1c6ff6105cfa38769befb57dd15610c90f75 \
                    size    153418954

categories          science
maintainers         {mmoll @mamoll}
description         The Open Motion Planning Library (OMPL)
long_description    The Open Motion Planning Library (OMPL) consists of a set \
                    of sampling-based motion planning algorithms.
master_sites        https://github.com/ompl/ompl/releases/download/${version}
distname            ompl-${version}-Source
homepage            http://ompl.kavrakilab.org
platforms           darwin
license             BSD
depends_build-append port:pkgconfig
depends_lib-append   port:flann port:triangle port:eigen3

boost.version 1.88
compiler.cxx_standard   2017
configure.args-append   -DOMPL_BUILD_DEMOS=OFF \
                        -DOMPL_BUILD_TESTS=OFF \
                        -DCMAKE_DISABLE_FIND_PACKAGE_spot=ON \
                        -DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=ON

variant spot description {Include support for automaton generation from LTL specifications using Spot} {
    configure.args-delete -DCMAKE_DISABLE_FIND_PACKAGE_spot=ON
    depends_lib-append    port:spot
}

set pythons_versions {3.10 3.11 3.12 3.13 3.14}

set pythons_ports {}
foreach v ${pythons_versions} {
    lappend pythons_ports python[string map {. {}} ${v}]
}

proc python_dir {} {
    global pythons_versions
    foreach p ${pythons_versions} {
        set s [string map {. {}} ${p}]
        if {[variant_isset python${s}]} {
            return [file normalize [exec python${p} -c "import sys; print(sys.prefix)"]/lib/${p}/site-packages]
        }
    }
    error "Python support not enabled."
}

foreach v ${pythons_versions} {
    set s [string map {. {}} ${v}]
    set p python${s}
    set vnodots [string index ${s} 0][string index ${s} 1]
    set i [lsearch -exact ${pythons_ports} ${p}]
    set c [lreplace ${pythons_ports} ${i} ${i}]
    variant ${p} description "Use Python ${v} for python bindings" "
        depends_lib-append      port:${p}
        configure.args-append   -DPYTHON_EXECUTABLE=${prefix}/bin/python${v}
        post-destroot {
            delete -force ${destroot}${prefix}/lib/cmake/nigh \
            delete -force ${destroot}${prefix}/lib/cmake/pdqsort
        }
    "
}

# enable one python variant so that the python bindings can be compiled
set selected_python python314
foreach v ${pythons_versions} {
    set s [string map {. {}} ${v}]
    if {[variant_isset python${s}]} {
        set selected_python python${s}
    }
}
default_variants +${selected_python}

livecheck.type  regex
livecheck.url   http://ompl.kavrakilab.org/download.html
livecheck.regex (\[0-9.\]+), released
