# -*- 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        RoaringBitmap CRoaring 5.2.0 v
github.tarball_from archive
name                croaring
revision            0

categories          devel
license             {Apache-2 MIT}
maintainers         {@jrjsmrtn gmail.com:jrjsmrtn} openmaintainer

description         Roaring compressed bitmaps in C and C++

long_description    CRoaring implements Roaring bitmaps, compressed bitsets \
                    that are usually faster and smaller than conventional \
                    compressed bitmaps such as WAH, EWAH or Concise. It \
                    provides a C library with a header-only C++ wrapper, and \
                    uses SIMD instructions where the processor supports them.

checksums           rmd160  aece55210a9ee74b62ce13dc34064702da7bf918 \
                    sha256  5f6ce15f23cb70fca04839d186a15ceb540e31d650496e0a2c8284a882465b13 \
                    size    100817734

compiler.c_standard 2011
compiler.cxx_standard 2011
# CMakeLists.txt refuses Apple clang older than 11, for runtime dispatch.
compiler.blacklist-append \
                    {clang < 1100}

# cmocka is only linked by the test executables, which are always configured.
depends_build-append \
                    port:cmocka

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -DROARING_USE_CPM=OFF

test.run            yes

# The test executables get the install rpath, which does not reach the
# libraries in the build tree, and SIP strips DYLD_LIBRARY_PATH.
pre-test {
    foreach exe [glob -nocomplain -types {f x} ${cmake.build_dir}/* ${cmake.build_dir}/tests/*] {
        if {[string match *.dylib ${exe}] || [catch {exec otool -l ${exe}} load]} {
            continue
        }
        if {[string match {*@rpath/*} ${load}] && ![string match *LC_RPATH* ${load}]} {
            system "install_name_tool -add_rpath ${cmake.build_dir} [shellescape ${exe}]"
        }
    }
}
