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

github.setup        nullptrlabs pgmodeler 2.0.0 v
github.tarball_from archive
revision            0

categories          databases
license             GPL-3
maintainers         {l2dy @l2dy} \
                    {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

description         PostgreSQL Database Modeler

long_description    pgModeler - {*}${description} - is an open source data \
                    modeling tool designed for PostgreSQL.

checksums           rmd160  ef2d636ba906f4871bdc8f42126340660c21e003 \
                    sha256  074a9a508d5c8415464ab5c37bb8d1a9d511e23daa2ba15a4a05feb84463754a \
                    size    9230375

# 2.0 builds with CMake, as C++17 against Qt 6.6 or later
compiler.cxx_standard \
                    2017

set pg_version      15

# On macOS, upstream hard-codes EnterpriseDB's PostgreSQL and the SDK's
# libxml2; point them at MacPorts'
patchfiles          patch-DefaultPaths.cmake.diff

post-patch {
    set f ${worksrcpath}/DefaultPaths.cmake
    reinplace "s|@@PGSQL_INC@@|${prefix}/include/postgresql${pg_version}|" ${f}
    reinplace "s|@@PGSQL_LIB@@|${prefix}/lib/postgresql${pg_version}/libpq.dylib|" ${f}
    reinplace "s|@@PREFIX@@|${prefix}|g" ${f}
}

depends_lib-append  port:libxml2 \
                    port:postgresql${pg_version}

qt6.depends_lib     qtsvg

cmake.build_type    Release
configure.args-append \
                    -DPGM_PREFIX=${applications_dir}/${name}.app/Contents

github.livecheck.regex \
                    {([0-9.]+)}
