# -*- 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           github 1.0

github.setup        polyfem polysolve 91f7e3a4a44df4ca541cb46923d5593a49254efd
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
version             2023.06.29
revision            0
categories          math
license             MIT
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
description         Easy-to-use wrapper for linear solver.
long_description    This library contains a cross-platform Eigen wrapper for many different external linear solvers.
homepage            https://polyfem.github.io
checksums           rmd160  e932aeaf28a95776f8db4130a1ac745094d75aae \
                    sha256  5b5b88d653a676a2a0307e1f70ba48641c36f4741fba97e7fe2057adb4275874 \
                    size    52538

depends_lib-append  path:share/pkgconfig/eigen3.pc:eigen3 \
                    port:hypre \
                    port:nlohmann-json

# Use Macports libs. Related issue: https://github.com/polyfem/polysolve/issues/37
patchfiles-append   patch-CMakeLists.diff

compiler.cxx_standard   2014
# Match settings in hypre port:
compiler.openmp_version 3.0

if {[string match *clang* ${configure.compiler}]} {
    configure.cxxflags-append \
                    -I${prefix}/include/libomp \
                    -Wno-c++11-narrowing
    configure.ldflags-append \
                    -L${prefix}/lib/libomp -lomp
}

# Accelerate support is broken at the moment: https://github.com/polyfem/polysolve/issues/38
configure.args-append \
                    -DEIGEN_WITH_MKL=OFF \
                    -DPOLYSOLVE_LARGE_INDEX=OFF \
                    -DPOLYSOLVE_WITH_ACCELERATE=OFF \
                    -DPOLYSOLVE_WITH_AMGCL=OFF \
                    -DPOLYSOLVE_WITH_CCACHE=OFF \
                    -DPOLYSOLVE_WITH_CHOLMOD=OFF \
                    -DPOLYSOLVE_WITH_CUSOLVER=OFF \
                    -DPOLYSOLVE_WITH_HYPRE=ON \
                    -DPOLYSOLVE_WITH_MKL=OFF \
                    -DPOLYSOLVE_WITH_PARDISO=OFF \
                    -DPOLYSOLVE_WITH_SANITIZERS=OFF \
                    -DPOLYSOLVE_WITH_SPECTRA=OFF \
                    -DPOLYSOLVE_WITH_SUPERLU=OFF \
                    -DPOLYSOLVE_WITH_TESTS=OFF \
                    -DPOLYSOLVE_WITH_UMFPACK=OFF

destroot {
    copy ${cmake.build_dir}/libpolysolve.a ${destroot}${prefix}/lib
}
