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

# NOTE: PaPILO is a header-based library, please bump all dependent ports on update
github.setup            scipopt papilo 2.1.4 v
revision                1
categories              math
license                 {LGPL-3 GPL-3}

maintainers             {@catap korins.ky:kirill} openmaintainer

description             Parallel Presolve for Integer and Linear Optimization
long_description        {*}${description}

checksums               rmd160  a59a3332c24dcc343a07826e8247fc4019f0c653 \
                        sha256  ac6e4fb2ca491c402cd3368ca5dca1639ea1fdecde71c1f75894915ed9621470 \
                        size    1086233

compilers.setup         require_fortran
compiler.cxx_standard   2014

compiler.blacklist-append {clang < 1000}

depends_lib-append      path:lib/libopenblas.dylib:OpenBLAS \
                        port:gmp \
                        port:onetbb

configure.args-append   -DBUILD_SHARED_LIBS=ON

subport libpapilo {
    # PaPILO as a library doesn't need any solver nor binaries
    configure.args-append \
                        -DSCIP=OFF \
                        -DSOPLEX=OFF \
                        -DHIGHS=OFF \
                        -DPAPILO_NO_BINARIES=ON
}

if {${name} eq ${subport}} {
    # and main port installs binaries, which is linked against soplex and scipt
    depends_lib-append  port:scip \
                        port:soplex

    # but it shouldn't install libraries and headers
    post-destroot {
        system "rm -rf ${destroot}${prefix}/lib"
        system "rm -rf ${destroot}${prefix}/include"
    }
}

# PAPILO may be linked against libquadmath, prevent that by using GMP.
configure.args-append   -DGMP=ON \
                        -DQUADMATH=OFF

test.run                yes
