# -*- 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           github 1.0
PortGroup           cmake 1.1

github.setup        gperftools gperftools 2.15 gperftools-
revision            0

categories          devel
license             BSD
maintainers         nomaintainer
description         high-performance multi-threaded malloc() and nifty performance analysis tools
long_description    gperftools is a collection of a high-performance multi-threaded malloc() \
                    implementation, plus some pretty nifty performance analysis tools.

github.tarball_from releases

checksums           rmd160  3ed3b444c010ce1b13cec85dc3efc142c0a61074 \
                    sha256  c69fef855628c81ef56f12e3c58f2b7ce1f326c0a1fe783e5cae0b88cbbe9a80 \
                    size    1511014

patchfiles-append   patch-check_address_test.cc-missed-MAP_ANON-fix.diff

compiler.cxx_standard  2017
cmake.set_cxx_standard yes

if { [string match *clang* ${configure.compiler}] } {
    # Quiet deprecation warnings
    configure.cxxflags-append \
                    -Wno-deprecated-declarations \
                    -Wno-error=unknown-warning-option \
                    -Wno-unknown-warning-option
}

configure.args-append \
                    -DBUILD_TESTING:BOOL=OFF \
                    -Dgperftools_build_benchmark:BOOL=OFF \
                    -Dgperftools_enable_libunwind:BOOL=OFF

variant benchmark description {Enable benchmark support} {
    configure.args-replace \
                    -Dgperftools_build_benchmark:BOOL=OFF \
                    -Dgperftools_build_benchmark:BOOL=ON
}

# A number of tests fail, similarly for all archs (arm64, x86_64, ppc):
# https://github.com/gperftools/gperftools/issues/1477
variant tests description {Enable test support} {
    configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF
    configure.args-replace \
                    -DBUILD_TESTING:BOOL=OFF \
                    -DBUILD_TESTING:BOOL=ON

    test.run        yes
    test.target     test
}
