# -*- 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           conflicts_build 1.0
PortGroup           R 1.0

R.setup             cran roigrp highs 0.1-10
revision            3
categories-append   math
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             GPL-2+
description         HiGHS optimization solver
long_description    R interface to HiGHS, an optimization solver for solving mixed integer optimization \
                    problems with quadratic or linear objective and linear constraints.
homepage            https://gitlab.com/roigrp/solver/highs
checksums           rmd160  2fc440d27e217824ecbaf4e355dcc04b82c76194 \
                    sha256  4ce0034f9eea27e5ba3562c57b09d6c656d898e37cd6a01c19a4d2e6ddfa55ee \
                    size    1128369

depends_build-append \
                    path:bin/cmake:cmake \
                    port:bash \
                    port:pkgconfig
depends_lib-append  port:R-checkmate \
                    port:R-Rcpp

# Switching to bundled HiGHS due to incompatibility with v. 1.7.0,
# until upstream addresses it: https://gitlab.com/roigrp/solver/highs/-/issues/5
# depends_lib-append  port:HiGHS
# patchfiles          patch-use-Macports-highs.diff
# post-patch {
#     reinplace "s,@PREFIX@,${prefix}," ${worksrcpath}/configure
# }
conflicts_build     HiGHS

if {[string match *gcc* ${configure.compiler}]} {
    # To avoid multiplying patches, just apply this for gcc cases:
    patchfiles-append \
                    patch-gcc-builds.diff
} else {
    # Clang gets upset about non-existing path here, drop it:
    patchfiles-append \
                    patch-fix-paths.diff
}

# There are no specific tests atm.
depends_test-append port:R-tinytest

test.run            yes
