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

# _clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup        tidesdb tidesdb 9.3.14 v
revision            0
categories          databases
license             MPL-2
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         Fast and efficient key value storage engine library
long_description    {*}${description} written in C.
homepage            https://tiledb.com
checksums           rmd160  983e80a58f86b135075ec50498c1d5eeca907888 \
                    sha256  496305d133c81acf87ef79abc026bbe639636ce7498fc4823d7eefab59dc7709 \
                    size    1182487
github.tarball_from archive

depends_lib-append  port:lz4 \
                    port:snappy \
                    port:zstd

compiler.c_standard 2011

# Otherwise tests fail:
configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -DMACOS_DEPENDENCY_PREFIX=${prefix} \
                    -DTIDESDB_BUILD_TESTS=ON \
                    -DTIDESDB_WITH_JEMALLOC=OFF \
                    -DTIDESDB_WITH_MIMALLOC=OFF \
                    -DTIDESDB_WITH_S3=OFF \
                    -DTIDESDB_WITH_SANITIZER=OFF

variant jemalloc conflicts mimalloc description "Use jemalloc for memory allocation" {
    depends_lib-append  path:lib/pkgconfig/jemalloc.pc:jemalloc

    configure.args-replace \
                    -DTIDESDB_WITH_JEMALLOC=OFF -DTIDESDB_WITH_JEMALLOC=ON
}

variant mimalloc conflicts jemalloc description "Use mimalloc for memory allocation" {
    depends_lib-append  port:mimalloc

    configure.args-replace \
                    -DTIDESDB_WITH_MIMALLOC=OFF -DTIDESDB_WITH_MIMALLOC=ON
}

test.run            yes
