# -*- 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.5.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  76b559445ea24468c4d70bd8690afcec261ebd99 \
                    sha256  aa23f47c3164aa2cf848c2258b4b4bc372e7964d4a3ed47c2b4a4a915c5dfa37 \
                    size    667891

set port_libfmt     libfmt11
cmake.prefix_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

# Force build to C++ 2014; avoids use of newer features not available on older macOS releases
compiler.cxx_standard  2014
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
}
