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

# MAP_ANONYMOUS and clock_gettime
legacysupport.newest_darwin_requires_legacy 15

# Ports that depend on this port must be revbump after update.
github.setup        abseil abseil-cpp 20260107.0
github.tarball_from archive
name                abseil
revision            0
categories          devel
maintainers         {judaew @judaew} openmaintainer
license             Apache-2

description         Abseil - C++ Common Libraries
long_description    Abseil is an open-source collection of C++ library \
                    code designed to augment the C++ standard \
                    library. The Abseil library code is collected from \
                    Google's own C++ code base, has been extensively \
                    tested and used in production.

checksums           rmd160  199bc34335540a40205825bc2f841039f6f2a3ac \
                    sha256  4c124408da902be896a2f368042729655709db5e3004ec99f57e3e14439bc1b2 \
                    size    2301048

patchfiles          patch-remove-Xarch-from-pkg-config.diff

# Abseil broken for 10.4-10.5, it's the pthread issue.
# See https://github.com/macports/macports-ports/pull/19905#issuecomment-1679652939
patchfiles-append   patch-pthread.diff

platform darwin {
    if {${build_arch} in [list ppc ppc64]} {
        patchfiles-append patch-darwin-ppc.diff
    }
    if {[string match *gcc* ${configure.compiler}]} {
        configure.ldflags-append \
                    -latomic
    }
}

platform darwin {
    if {${os.major} >= 11 && ${os.major} <= 12} {
        # some functions in xlocale.h are hidden without this define
        # https://trac.macports.org/ticket/67988
        configure.cxxflags-append -D_DARWIN_C_SOURCE
    }
}

# ignore pre releases
github.livecheck.regex  {([0-9.]+)}

# Use C++17 standard for using std:meta, std:strings and std:types instead
# abseil implementation this types for C++14 standard
# See https://trac.macports.org/ticket/69578
compiler.cxx_standard   2017

# https://trac.macports.org/ticket/67553
# error: default initialization of an object of const type 'const absl::lts_20230125::Condition'
#   without a user-provided default constructo
compiler.blacklist-append \
                    {clang < 900}

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -DCMAKE_CXX_STANDARD=17 \
                    -DABSL_PROPAGATE_CXX_STD=ON

variant test description "Provide testing" {
    configure.args-append \
                    -DBUILD_SHARED_LIBS=OFF \
                    -DABSL_BUILD_TESTING=ON \
                    -DABSL_USE_EXTERNAL_GOOGLETEST=ON \
                    -DABSL_LOCAL_GOOGLETEST_DIR=${prefix}/src/googletest

    depends_test    port:gtest

    test.run        yes
    test.target     test
}
