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

name                log4cxx
version             1.4.0
revision            0
github.setup        apache logging-log4cxx ${version} rel/v

categories          devel
license             Apache-2
maintainers         {mascguy @mascguy} openmaintainer

description         log4cxx is a port to C++ of the log4j project
long_description    Apache log4cxx is a logging framework for C++ patterned \
                    after Apache log4j. Apache log4cxx uses Apache Portable \
                    Runtime for most platform-specific code and should be \
                    usable on any platform supported by APR.
homepage            https://logging.apache.org/log4cxx/

distname            apache-log4cxx-${version}
master_sites        apache:logging/log4cxx/${version}

checksums           rmd160  dc3b4917a396ad575c6fad5193b7674b268b49be \
                    sha256  3d2d1f356a546c14562763aaf15fcc3fd59d4ffeb5a2f68fcb0bbd7571ed6f96 \
                    size    667835

set port_libfmt     libfmt11
cmake.module_path-append \
                    ${prefix}/lib/${port_libfmt}/cmake

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

depends_lib-append \
                    port:apr-util \
                    port:expat \
                    port:${port_libfmt} \
                    port:libiconv

compiler.cxx_standard  2017
# While project defaults to 2020, build will gracefully fallback if set to 2017
cmake.set_cxx_standard yes

# gcc-4.2 fails to build this on darwin 10
# https://trac.macports.org/ticket/40090
# This is redundant now, but can be retained for those who may wish to use fallback option of Boost instead of C++17.
# https://github.com/apache/logging-log4cxx/blob/master/src/site/markdown/development/dependencies.md
platform darwin 10 {
    compiler.blacklist-append *gcc-4.2
}

configure.args-append \
                    -DPREFER_BOOST:BOOL=OFF

patch.pre_args-replace  -p0 -p1
patchfiles-append   gcc43.patch
# See: https://github.com/fmtlib/fmt/issues/2759
patchfiles-append   patch-fmt.diff

# This reverts a commit that does not build on PPC:
# https://github.com/apache/logging-log4cxx/commit/23a85d7a711f1cd5bf7170ff2a4106d00995c079#commitcomment-80358572
platform darwin powerpc {
    patchfiles-append patch-logstream.diff
}
