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

github.setup            ismrmrd ismrmrd 1.14.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
categories              science
maintainers             {eborisch @eborisch} openmaintainer
license                 permissive

# Keep; can need rebuild for HDF5 on version incompatibilities
revision                0

description             ISMRM Raw Data Format
long_description        ISMRM Raw Data format tools and libraries.

checksums \
    rmd160  15ebc7f5346ad3110350b9fa0ec163481656378d \
    sha256  54a7726fcaaf6e7ded51406a10f873ec748a8383376f44131be2645b86140a84 \
    size    175866

compiler.cxx_standard   2011

depends_lib-append      port:hdf5 \
                        port:fftw-3-single \
                        port:pugixml \
                        port:zlib

depends_build-append    path:bin/doxygen:doxygen \
                        path:bin/dot:graphviz

conflicts_build ${name}

configure.args-append   -DUSE_SYSTEM_PUGIXML=ON

build.target-append     doc

# fix testing
configure.pre_args-replace \
                        -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                        -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

test.run                yes
test.dir                ${cmake.build_dir}/tests
test.cmd                ./test_ismrmrd
test.target

patchfiles              patch-ismrmrd-no-werror.diff

post-patch {
    foreach pat {
        "/^(HAVE_DOT|DOT_MULTI_TARGETS)/s/NO/YES/"
        "/^GENERATE_XML/s/YES/NO/"
        "/^DOT_IMAGE_FORMAT/s/png/svg/"
    } { reinplace -E $pat doc/Doxyfile.in }
}

post-destroot {
    set DOCDIR ${destroot}${prefix}/share/doc/${name}
    set EXMPDIR ${destroot}${prefix}/share/examples
    xinstall -d ${DOCDIR} ${EXMPDIR}
    file copy ${cmake.build_dir}/doc/html/api ${DOCDIR}/html
    file copy ${worksrcpath}/examples ${EXMPDIR}/${name}
    xinstall -m 0644 -W ${worksrcpath} \
        LICENSE \
        README.md \
        ${DOCDIR}
}

notes "
    ISMRMRD documentation (HTML) installed at:
    file://${prefix}/share/doc/${name}/html/index.html
"
