# -*- 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        contour-terminal libunicode 0.9.2 v
revision            0
categories          devel textproc
license             Apache-2
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         Modern C++20 Unicode Library
long_description    {*}${description}
checksums           rmd160  b419f0a3b0492143225512457825090c5b51da66 \
                    sha256  df2c7b1a80e7aeb52f0ac3e23e460d4b2ada3996307dd886aca8e058d3ddb653 \
                    size    145154
github.tarball_from archive

# https://github.com/contour-terminal/libunicode/issues/138
patchfiles          patch-fix-std-simd.diff

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]

# Only needed if building with tests enabled:
depends_build-append \
                    port:python${py_ver_nodot}

compiler.cxx_standard   2020

# C++20 is the default here, but control it explicitly.
configure.args-append \
                    -DCMAKE_CXX_STANDARD=20 \
                    -DLIBUNICODE_BENCHMARK=OFF \
                    -DLIBUNICODE_BUILD_STATIC=OFF \
                    -DLIBUNICODE_EXAMPLES=OFF \
                    -DLIBUNICODE_SIMD_IMPLEMENTATION="std" \
                    -DLIBUNICODE_TESTING=OFF \
                    -DLIBUNICODE_TOOLS=ON \
                    -DPython3_EXECUTABLE=${prefix}/bin/python${py_ver}

# This is needed regardless of testing:
# dyld: Library not loaded: @rpath/libunicode_loader.0.6.dylib
configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

# On 10.6.8 powerpc:
# 100% tests passed, 0 tests failed out of 1
variant tests description "Build tests" {
    depends_build-append \
                    port:catch2
    configure.args-replace \
                    -DLIBUNICODE_TESTING=OFF -DLIBUNICODE_TESTING=ON
    test.run        yes
}
