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

name                    xdmf
version                 3.0.0
revision                12
categories              science devel
# cannot find license, assume same as ParaView
license                 BSD
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description             eXtensible Data Model and Format
long_description        The need for a standardized method to exchange scientific data between \
                        High Performance Computing codes and tools lead to the development of \
                        the eXtensible Data Model and Format (XDMF).

homepage                https://www.xdmf.org/index.php/Main_Page

fetch.type              git
git.url                 --depth 1 https://gitlab.kitware.com/xdmf/xdmf
git.branch              04a84bab0eb1568e0f1a27c8fb60c6931efda003

depends_lib-append      port:tiff \
                        port:hdf5  \
                        port:libxml2

# avoid self-conflict
# allow VTK and ParaView to find libraries
# see https://gitlab.kitware.com/xdmf/xdmf/-/issues/28
# fix tests
patchfiles-append       patch-isystem.diff \
                        patch-libraries.diff \
                        patch-hid_t.diff \
                        patch-fix_tests.diff

configure.args-append   -DBUILD_SHARED_LIBS=ON

post-destroot {
    # allow VTK and ParaView to find libraries
    set xdmf_major [lindex [split ${version} .] 0]
    xinstall -d -m 0755 ${destroot}${prefix}/lib/cmake/xdmf${xdmf_major}
    copy \
        ${destroot}${prefix}/lib/cmake/Xdmf/XdmfConfig.cmake \
        ${destroot}${prefix}/lib/cmake/xdmf${xdmf_major}/xdmf${xdmf_major}Config.cmake
    reinplace "s|set(XDMF_|set(XDMF${xdmf_major}_|g" ${destroot}${prefix}/lib/cmake/xdmf${xdmf_major}/xdmf${xdmf_major}Config.cmake
}

variant tests description {Enable tests} {
    test.run                yes
    configure.args-append   -DXDMF_BUILD_TESTING=ON
    test.args-append        DYLD_LIBRARY_PATH=${cmake.build_dir}/lib
}

livecheck.type          regexm
livecheck.version       ${git.branch}
livecheck.url           https://gitlab.kitware.com/xdmf/xdmf/-/commits/master
livecheck.regex         {/xdmf/xdmf/-/commit/([0-9a-z]*)}
