# -*- mode: tcl; indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4 -*-

PortSystem          1.0
PortGroup           boost 1.0
PortGroup           cmake 1.1
PortGroup           github 1.0

github.setup        OGRECave ogre 14.0.1 v
github.tarball_from archive
revision            1

license             MIT
categories          graphics
maintainers         nomaintainer

description         Object-Oriented Graphics Rendering Engine
long_description    OGRE (Object-Oriented Graphics Rendering Engine) \
                    is a scene-oriented, flexible 3D engine written in \
                    C++ designed to make it easier and more intuitive \
                    for developers to produce applications utilising \
                    hardware-accelerated 3D graphics. The class \
                    library abstracts all the details of using the \
                    underlying system libraries like Direct3D and \
                    OpenGL and provides an interface based on world \
                    objects and other intuitive classes.

homepage            https://www.ogre3d.org/

# ogre uses NSOpenGLContext.pixelFormat which was added at 10.10
platforms           {darwin >= 14}

checksums           rmd160  a57631ed493db10dfa5909c221faf5520ba9dc24 \
                    sha256  5a25357a8d8423f9fd8a06e0f46abeba932e6093f402d08cc5d3249c1ce40109 \
                    size    94900032

use_xcode           yes

cmake.build_type    Release
compiler.cxx_standard \
                    2011
# Extend blacklist to cover macOS10.11
compiler.blacklist-append \
                    {clang < 900}

depends_build-append \
                    path:bin/dot:graphviz \
                    path:bin/doxygen:doxygen \
                    port:pkgconfig

depends_lib-append  port:assimp \
                    port:freeimage \
                    port:freetype \
                    port:glslang \
                    port:libsdl2 \
                    port:pugixml \
                    port:swig \
                    port:zlib

post-patch {
    reinplace "s|@rpath|${prefix}/lib|" ${worksrcpath}/CMake/Utils/OgreConfigTargets.cmake
    reinplace "s|/Release\"|\"|" ${worksrcpath}/CMake/Utils/OgreConfigTargets.cmake
    reinplace "s|\"/\${PLATFORM_NAME}\"|\"\"|" ${worksrcpath}/CMake/Utils/OgreConfigTargets.cmake
}

configure.args-append \
                    -DOGRE_BUILD_COMPONENT_CSHARP=FALSE \
                    -DOGRE_BUILD_COMPONENT_JAVA=FALSE \
                    -DOGRE_BUILD_COMPONENT_PYTHON=FALSE \
                    -DOGRE_BUILD_DEPENDENCIES=FALSE \
                    -DOGRE_BUILD_SAMPLES=FALSE \
                    -DOGRE_CFG_INSTALL_PATH=share/${name}/config \
                    -DOGRE_CMAKE_DIR=share/${name}/Cmake \
                    -DOGRE_DOCS_PATH=share/doc/${name} \
                    -DOGRE_ENABLE_PRECOMPILED_HEADERS=FALSE \
                    -DOGRE_MEDIA_PATH=share/${name}/Media \
                    -DOGRE_PLUGINS_PATH=share/${name}/plugins

post-destroot {
    set ogre_share   ${destroot}${prefix}/share/${name}
    set ogre_config  ${ogre_share}/config
    set ogre_plugins ${ogre_share}/plugins

    xinstall -d ${ogre_config}
    move {*}[glob ${destroot}${prefix}/bin/*.cfg] ${ogre_config}

    xinstall -d ${ogre_plugins}
    destroot.keepdirs ${ogre_plugins}
}
