# -*- 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
PortGroup           wxWidgets 1.0

github.setup        openbabel openbabel 3-1-1 openbabel-
github.tarball_from releases
conflicts           openbabel2
version             [string map {- .} ${github.version}]
revision            1

categories          science devel chemistry
license             GPL-2
maintainers         {reneeotten @reneeotten} openmaintainer

description         Open Babel is a chemical toolbox designed to speak the many languages \
                    of chemical data
long_description    ${description}. It's an open, collaborative project allowing anyone to \
                    search, convert, analyze, or store data from molecular modeling, chemistry, \
                    solid-state materials, biochemistry, or related areas.

homepage            https://openbabel.org

use_bzip2           yes
distname            ${name}-${version}-source
worksrcdir          ${name}-${version}

checksums           rmd160  4e0e07ed8ed4361de1dfff021d540c2e46c06fe2 \
                    sha256  a6ec8381d59ea32a4b241c8b1fbd799acb52be94ab64cdbd72506fb4e2270e68 \
                    size    27743669

compiler.cxx_standard \
                    2011
compiler.thread_local_storage yes

patchfiles          version.patch
patchfiles-append   patch-cmake-coordgen.diff
patch.pre_args-replace  -p0 -p1

configure.args-append \
                    -DBUILD_GUI=OFF \
                    -DBUILD_TESTING=OFF \
                    -DENABLE_OPENMP=OFF \
                    -DOPTIMIZE_NATIVE=OFF

depends_build-append \
                    path:share/pkgconfig/eigen3.pc:eigen3 \
                    port:pkgconfig

depends_lib-append  port:boost \
                    port:coordgen \
                    path:lib/pkgconfig/cairo.pc:cairo \
                    port:libxml2 \
                    port:maeparser \
                    path:lib/pkgconfig/RapidJSON.pc:rapidjson \
                    port:zlib

variant native description {Enable CPU-specific optimizations} {
    configure.args-replace \
                    -DOPTIMIZE_NATIVE=OFF \
                    -DOPTIMIZE_NATIVE=ON
}

variant gui description {Build the OpenBabelGUI} {
    wxWidgets.use   wxWidgets-3.2

    depends_lib-append \
                    port:${wxWidgets.port}

    configure.args-replace \
                    -DBUILD_GUI=OFF \
                    -DBUILD_GUI=ON

    configure.args-append \
                    -DwxWidgets_CONFIG_EXECUTABLE=${wxWidgets.wxconfig}
}
