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

github.setup                tpaviot oce 0.18.3 OCE-
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from         tarball
set branch                  [join [lrange [split ${version} .] 0 1] .]
revision                    1
categories                  graphics
maintainers                 {gmail.com:mark.brethen @mbrethen} openmaintainer
license                     LGPL-2.1

description                 Open CASCADE Community Edition

long_description            {*}${description}

checksums                   rmd160  3bfe060893dca29baefd70d88b05098f9457ee20 \
                            sha256  792ec7d735f1e8ffb9db4bf20fc724c6ec2d2a435aa78e5df795c36fb0f360a1 \
                            size    24636499

patchfiles-append           patch-use-isfinite-on-arm64.diff

depends_lib-append          port:freetype

# install it into libexec to avoid conflict with opencascade port
cmake.install_prefix        ${prefix}/libexec/${name}

configure.args-append       -DOCE_INSTALL_PREFIX:PATH=${cmake.install_prefix} \
                            -DOCE_INSTALL_CMAKE_DATA_DIR:PATH=${cmake.install_prefix}/lib/cmake/${subport}

variant test description {Build and run unit testing framework} {
    configure.args-append   -DOCE_TESTING:BOOL=ON
    test.run                yes
}

variant draw description {Build DRAW test harness} {
    depends_lib-append      port:tcl port:tk
    configure.args-append   -DTCL_INCLUDE_PATH=${prefix}/include
    configure.args-append   -DOCE_DRAW:BOOL=ON
    configure.args-append   -DOCE_INSTALL_PACKAGE_LIB_DIR=lib
}

variant tbb description {Use TBB for memory allocation} {
    depends_lib-append      port:tbb
    configure.args-append   -DOCE_MULTITHREAD_LIBRARY:STRING=TBB \
                            -DTBB_INCLUDE_DIR:FILEPATH=${prefix}/libexec/tbb/include \
                            -DTBB_LIB_DIR:FILEPATH=${prefix}/libexec/tbb/lib
}

variant freeimage description {Build with FreeImage support} {
    depends_lib-append      port:freeimage
    configure.args-append   -DOCE_WITH_FREEIMAGE:BOOL=ON
}

variant gl2ps description {Build with gl2ps support} {
    depends_lib-append      port:gl2ps
    configure.args-append   -DOCE_WITH_GL2PS:BOOL=ON
}

# keep this port at perfix's cmake's lib
post-destroot {
    xinstall -d -m 0755 ${destroot}${prefix}/lib/cmake
    foreach cmakedir [glob -type d -nocomplain -tails -directory ${destroot}${cmake.install_prefix}/lib/cmake *] {
        xinstall -d -m 0755 ${destroot}${prefix}/lib/cmake/${cmakedir}
        foreach cmakefile [glob -tails -directory ${destroot}${cmake.install_prefix}/lib/cmake/${cmakedir} *.cmake] {
            ln -s ${cmake.install_prefix}/lib/cmake/${cmakedir}/${cmakefile} \
                ${destroot}${prefix}/lib/cmake/${cmakedir}/
            reinplace -q "s|\\\${CMAKE_CURRENT_LIST_DIR}|${cmake.install_prefix}/lib/cmake/${cmakedir}|g" \
                 ${destroot}${cmake.install_prefix}/lib/cmake/${cmakedir}/${cmakefile}
            reinplace -q "s|\\\${CMAKE_CURRENT_LIST_FILE}|${cmake.install_prefix}/lib/cmake/${cmakedir}/${cmakefile}|g" \
                 ${destroot}${cmake.install_prefix}/lib/cmake/${cmakedir}/${cmakefile}
        }
    }
}

livecheck.type              none

notes "
This is unmaintained version of occt tools. Consider to use opencascade port instead.
See: https://github.com/tpaviot/oce/issues/745
"
