# -*- 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                   github 1.0
PortGroup                   cmake 1.1

github.setup                kokkos kokkos 4.7.01
github.tarball_from         archive
conflicts                   kokkos-devel
revision                    0
categories                  devel
license                     BSD
maintainers                 {mcalhoun @MarcusCalhoun-Lopez} openmaintainer
description                 implements a programming model in C++ for writing performance portable applications targeting all major HPC platforms
long_description            Kokkos Core {*}${description}.

checksums                   rmd160  f06c419cc860398638613c0ebad46f82038da29b \
                            sha256  cebf6daeb99c95e3d4116ea0d97c94b6a521c0cff1f5e613f127f6beea960ac7 \
                            size    2521574

subport kokkos-devel {
    github.setup            kokkos kokkos 7c08b2e91865d579efe3fb0a881a1912fc248d8f
    version                 2025.10.19
    conflicts               kokkos
    checksums               rmd160  cd01859b4fb01cde492c57393174fbd27736695a \
                            sha256  1535e8ac0248b435071b1d2ba61a8086c522434e59c2ac2d828953bbdb7e15c2 \
                            size    1782131
    github.tarball_from     archive
    github.livecheck.branch develop
    # Kokkos_HostSpace.cpp:79:11: error: aligned allocation function
    # of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &)
    # noexcept' is only available on macOS 10.13 or newer
    if {${os.platform} eq "darwin" && ${os.major} < 17} {
        if {${configure.cxx_stdlib} eq "libc++"} {
            configure.cxxflags-append -fno-aligned-allocation
        }
    }
}

compiler.cxx_standard       2017
compiler.openmp_version     4.0

depends_lib-append          port:hwloc

configure.args-append       -DBUILD_SHARED_LIBS=ON \
                            -DKokkos_ENABLE_OPENMP=ON \
                            -DKokkos_ENABLE_SERIAL=ON \
                            -DKokkos_ENABLE_HWLOC=ON

# see https://github.com/macports/macports-base/commit/7c91604891fa0d071b8d598490c4dc2edb8e0031
# see https://github.com/macports/macports-ports/pull/17877#discussion_r1183486766
compiler.log_verbose_output no

variant tests description {Enable tests} {
    configure.args-append   -DKokkos_ENABLE_TESTS=ON
    configure.pre_args-replace \
                            -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                            -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF
    test.run                yes
}
