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

github.setup        google draco 1.5.7
revision            5
github.tarball_from archive

categories          archivers graphics gis
license             Apache-2
maintainers         {yahoo.com:n_larsson @nilason} openmaintainer
description         3D data compression
long_description    Draco is an open-source library for compressing and        \
                    decompressing 3D geometric meshes and point clouds.        \
                    Is is intended to improve the storage and transmission     \
                    of 3D graphics.
homepage            https://google.github.io/draco/

checksums           rmd160  8570f7264777ac166dfec8db1d09c07cd997f4ee \
                    sha256  bf6b105b79223eab2b86795363dfe5e5356050006a96521477973aba8f036fe1 \
                    size    60465968

patchfiles          patch-gltf-decoder-cc.diff \
                    patch-draco-targets-cmake.diff

# https://github.com/google/draco/pull/1089
patchfiles-append   patch-gltf_utils.h.diff

compiler.cxx_standard   2017
cmake.set_cxx_standard  yes

depends_build-append \
                    port:ghc-filesystem \
                    port:gtest

depends_lib-append  path:share/pkgconfig/eigen3.pc:eigen3 \
                    port:nlohmann-json \
                    port:stb \
                    port:tinygltf

# ghc-filesystem uses utimensat in its headers
legacysupport.newest_darwin_requires_legacy 16

configure.args-append \
                    -DBUILD_SHARED_LIBS=ON \
                    -DDRACO_EIGEN_PATH=${prefix}/include/eigen3 \
                    -DDRACO_FILESYSTEM_PATH=${prefix}/include/ghc \
                    -DDRACO_GOOGLETEST_PATH=${prefix}/src \
                    -DDRACO_TESTS=ON \
                    -DDRACO_TINYGLTF_PATH=${prefix}/include \
                    -DDRACO_TRANSCODER_SUPPORTED=ON \
                    -DDRACO_VERBOSE=3 \

# https://trac.macports.org/ticket/71430
if {[string match *gcc* ${configure.compiler}]} {
    configure.cxxflags-append \
                    -fpermissive
}

test.run            yes
test.cmd            "./draco_tests"
