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

# strnlen
legacysupport.newest_darwin_requires_legacy 10

github.setup            malaterre GDCM 3.2.5 v
revision                0

name                    gdcm
categories              science graphics
license                 BSD
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description             a C++ library for DICOM medical files
long_description        Grassroots DiCoM is a C++ library for DICOM medical files.

# Home page on Sourceforge, but new releases found only on Github mirror.
homepage                https://sourceforge.net/projects/gdcm/

github.tarball_from     archive

checksums               rmd160  5b84f55a53af869cb29e6a7ae863f44f1140d038 \
                        sha256  1763d94228ef31babe68a2b5f3b0d4fc66bc0afae641d9a4c38ea5269e06ba5d \
                        size    4092525

compiler.cxx_standard   2014

# Fix 10.10, 10.11
# error: default initialization of an object of const type 'const vtkOStreamWrapper::EndlType' without a user-provided default constructor
compiler.blacklist-append \
                        {clang < 801}

# fix error with newer Poppler
patchfiles-append       patch-poppler.diff

depends_build-append    path:bin/pkg-config:pkgconfig

depends_lib-append      port:charls \
                        port:expat \
                        port:json-c \
                        port:jsoncpp \
                        port:openjpeg \
                        path:lib/libssl.dylib:openssl \
                        port:socketxx \
                        port:vtk \
                        port:zlib

configure.args-append   -DCMAKE_CXX_STANDARD=14 \
                        -DGDCM_BUILD_DOCBOOK_MANPAGES=OFF \
                        -DGDCM_BUILD_EXAMPLES=OFF \
                        -DGDCM_BUILD_TESTING=OFF \
                        -DGDCM_BUILD_SHARED_LIBS=ON \
                        -DGDCM_DOCUMENTATION=OFF \
                        -DGDCM_USE_SYSTEM_ZLIB=ON \
                        -DGDCM_USE_SYSTEM_OPENSSL=ON \
                        -DGDCM_USE_SYSTEM_UUID=ON \
                        -DGDCM_USE_SYSTEM_EXPAT=ON \
                        -DGDCM_USE_SYSTEM_JSON=ON \
                        -DGDCM_USE_SYSTEM_PAPYRUS3=OFF \
                        -DGDCM_USE_SYSTEM_SOCKETXX=ON \
                        -DGDCM_USE_SYSTEM_LJPEG=OFF \
                        -DGDCM_USE_SYSTEM_OPENJPEG=ON \
                        -DGDCM_USE_SYSTEM_CHARLS=ON \
                        -DGDCM_USE_VTK=ON \
                        -DGDCM_WRAP_CSHARP=OFF \
                        -DGDCM_WRAP_JAVA=OFF \
                        -DGDCM_WRAP_PYTHON=OFF

#  PROJ version should be in sync with VTK
set proj_version        proj9
configure.args-append   -DLibPROJ_INCLUDE_DIR=${prefix}/lib/${proj_version}/include
configure.env-append    CMAKE_LIBRARY_PATH=${prefix}/lib/${proj_version}/lib

variant applications description {build Application} {
    PortGroup               qt5 1.0

    compiler.cxx_standard   2017

    depends_lib-append      path:lib/pkgconfig/poppler.pc:poppler \
                            port:libxml2
    configure.args-append   -DGDCM_BUILD_APPLICATIONS=ON \
                            -DGDCM_USE_SYSTEM_POPPLER=ON \
                            -DGDCM_USE_SYSTEM_LIBXML2=ON
    configure.args-replace  -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD=17
}

# installation seems to hang
#variant docs description {Build source documentation} {
#    depends_build-append    path:bin/doxygen:doxygen \
#                            port:libxslt
#    configure.args-append   -DGDCM_DOCUMENTATION=ON
#}
