# -*- 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.0
PortGroup       github 1.0

name            SDL3_image
github.setup    libsdl-org SDL_image 3.4.4 release-
categories      devel graphics
platforms       {darwin >= 20}
license         zlib
maintainers     {jmr @jmroot} openmaintainer
description     Add on library for libSDL handling several image formats

long_description \
    This is a simple library to load images of various formats as SDL surfaces. \
    This library supports BMP, PPM, PCX, GIF, JPEG, PNG, TGA, and TIFF formats.

github.tarball_from releases
distname        ${name}-${version}

checksums       rmd160 ffece0e157ebde9d98abd5078bab041936104b5c \
                sha256 29751304a13d25ac513f24305fa25b06a6edd9607718c90129b8350d35fc5573

depends_build-append   path:bin/pkg-config:pkgconfig
depends_lib     port:SDL3 \
                port:tiff \
                port:webp

cmake.out_of_source yes

configure.args-append  -DSDLIMAGE_INSTALL_MAN=ON \
                -DSDLIMAGE_DEPS_SHARED=OFF \
                -DSDLIMAGE_STRICT=ON \
                -DSDLIMAGE_SAMPLES=OFF \
                -DSDLIMAGE_BACKEND_IMAGEIO=OFF \
                -DSDLIMAGE_AVIF=OFF \
                -DSDLIMAGE_JXL=OFF

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} CHANGES.txt README.md \
        ${destroot}${docdir}
}

variant jxl description {Enable JPEG XL support (experimental)} {
    depends_lib-append  port:libjxl
    configure.args-replace  -DSDLIMAGE_JXL=OFF \
                            -DSDLIMAGE_JXL=ON
}
