# -*- 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        llnl zfp 1.0.1.post0
github.tarball_from archive
revision            0
epoch               1

categories          science devel
license             BSD
maintainers         {mps @Schamschula} openmaintainer
description         ${name} is a compressed format for representing \
                    multi-dimensional floating-point and integer arrays
long_description    {*}${description}
homepage            https://zfp.llnl.gov

checksums           rmd160  f8ac39ee88eb3a40fff00614e7f6e96f46a3b7f1 \
                    sha256  2c2d2ab18d78f8152159171f272177629ddff9b41e748ad88bee2d298d7292a5 \
                    size    508095

# index.hpp: error: integer constant is too large for ‘unsigned long’ type
compiler.blacklist-append \
                    {clang < 400} *gcc-4.*
compiler.c_standard 1999

configure.args-append \
                    -DBUILD_EXAMPLES=OFF \
                    -DBUILD_TESTING=ON \
                    -DBUILD_UTILITIES=ON \
                    -DZFP_WITH_ALIGNED_ALLOC=OFF \
                    -DZFP_WITH_OPENMP=OFF

variant openmp description {use OpenMP} {
    compiler.openmp_version 3.0

    configure.args-replace \
                    -DZFP_WITH_OPENMP=OFF \
                    -DZFP_WITH_OPENMP=ON

    if {[string match *clang* ${configure.compiler}]} {
        configure.ldflags-append \
                    -L${prefix}/lib/libomp \
                    -lomp
    }
}

# See: https://github.com/LLNL/zfp/issues/205
if {${configure.build_arch} in [list i386 ppc]} {
    configure.args-append \
                    -DZFP_INT64='long long' \
                    -DZFP_INT64_SUFFIX=ll \
                    -DZFP_UINT64='unsigned long long' \
                    -DZFP_UINT64_SUFFIX=ull
}

test.run            yes
# Drop once someone finally removes this from cmake PG:
configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF
