# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           active_variants 1.1
PortGroup           boost 1.0
PortGroup           cmake 1.1
PortGroup           github 1.0
PortGroup           legacysupport 1.1

boost.version       1.81

github.setup        google libphonenumber 9.0.34 v
revision            0
name                libphonenumber-cpp
categories          devel
license             Apache-2
description         Google's C++ library for parsing, formatting, storing \
                    and validating international phone numbers.
long_description    {*}${description}
maintainers         {devans @dbevans} openmaintainer

checksums           rmd160  aeab8c465c176484cc4cf1e20cfc0cdc4cf9e522 \
                    sha256  5d2a61572110f0538fdb1afbc1f8381426fbfbbf544b45e8ae905297f2f5befa \
                    size    13041844
github.tarball_from archive

worksrcdir          ${worksrcpath}/cpp

set gtest_srcdir    ${prefix}/src/googletest

depends_build-append \
                    port:gtest \
                    path:bin/pkg-config:pkgconfig

depends_lib-append  port:abseil \
                    path:lib/pkgconfig/icu-uc.pc:icu \
                    port:protobuf

configure.args-append \
                    -DABSL_PROPAGATE_CXX_STD=ON \
                    -DBUILD_GEOCODER=OFF \
                    -DBUILD_TESTING=OFF \
                    -DGTEST_SOURCE_DIR=${gtest_srcdir} \
                    -DGTEST_INCLUDE_DIR=${gtest_srcdir}/include \
                    -DREGENERATE_METADATA=OFF \
                    -DUSE_BOOST=ON \
                    -DUSE_ICU_REGEXP=ON \
                    -DUSE_POSIX_THREAD=OFF \
                    -DUSE_RE2=OFF \
                    -DUSE_STD_MAP=ON \
                    -DUSE_STDMUTEX=OFF

compiler.cxx_standard       2017
compiler.thread_local_storage \
                            yes

# phonenumber_offline_geocoder.cc:80:25: error: 'absl::lts_20260107::MutexLock::MutexLock(absl::lts_20260107::Mutex*)'
# is deprecated: Use the constructor that takes a reference instead [-Werror=deprecated-declarations]
configure.cxxflags-append   -Wno-error=deprecated-declarations

variant cxx17 conflicts cxx20 description "Use C++17" {
    require_active_variants abseil cxx17
    require_active_variants protobuf cxx17
    configure.cxxflags-append   -std=c++17
}

variant cxx20 conflicts cxx17 description "Use C++20" {
    require_active_variants abseil cxx20
    require_active_variants protobuf cxx20
    compiler.cxx_standard       2020
    configure.cxxflags-append   -std=c++20
}

if ![variant_isset cxx17] {
    default_variants +cxx20
}

test.run            yes
test.cmd            ./libphonenumber_test
test.target
