# -*- 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
PortGroup                       legacysupport   1.1

github.setup                    AcademySoftwareFoundation openexr 3.5.3 v
github.tarball_from             releases
revision                        0

checksums                       rmd160  b2d6db38b9ef6cc630bbbac9961ee68f6c103bbe \
                                sha256  aa84c2979d614a1bb5870da64d9fb4969deda8bf4f8166e7393bfd81e40af305 \
                                size    26460839

categories                      graphics
license                         BSD
maintainers                     {mascguy @mascguy} openmaintainer
description                     OpenEXR Graphics Library
long_description                OpenEXR is the professional-grade high dynamic range image \
                                storage format of the motion picture industry.
homepage                        https://www.openexr.com

# Python only used for tests
set py_ver                      3.14
set py_ver_nodot                [string map {. {}} ${py_ver}]

# std::filesystem
legacysupport.newest_darwin_requires_legacy 18
legacysupport.use_mp_libcxx     yes

if { (!(${universal_possible} && [variant_isset universal]) && ${configure.build_arch} eq "ppc")
     ||
     ((${universal_possible} && [variant_isset universal]) && "ppc" in ${configure.universal_archs}) } {
    # see description in patch file; bug in GCC, fixed in current branches, but not backported yet:
    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110044
    patchfiles-append           patch-ensure_pack.diff
}

# https://trac.macports.org/ticket/74524
# aligned_alloc is missing on macOS <= 10.14
if {${os.platform} eq "darwin" && ${os.major} <= 18} {
    patchfiles-append           patch-src-lib-OpenEXRCore-internal_zstd.c.diff
}

depends_build-append \
                                path:bin/pkg-config:pkgconfig

depends_lib-append \
                                port:imath \
                                port:libdeflate \
                                port:OpenJPH \
                                port:zstd

compiler.cxx_standard           2017

configure.args-append \
                                -DBUILD_TESTING=OFF \
                                -DOPENEXR_BUILD_PYTHON=OFF

variant tests description {Enable test support} {
    depends_build-append        port:python${py_ver_nodot}

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

    test.run                    yes
    test.target                 test
}

# only allow numbers, to avoid pre-release versions
github.livecheck.regex          {([0-9.]+)}
