# -*- 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.3.01
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from         tarball
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  f4e600d10da7f8dea9b6394984cefa42c022c9be \
                            sha256  eeffca89eb75584c4ac8bd55e8a3fcfb130400a696ba94fce7cfb5c77978131d \
                            size    2431476

subport kokkos-devel {
    github.setup            kokkos kokkos 7ff4042fd2dc1d1fe6ae280179fc693ad6dac6ac
    version                 2024.11.11
    conflicts               kokkos
    checksums               rmd160  9dbaa78dd8ce208793f74098df08c56935d6644c \
                            sha256  208b253350c7d658678e307313085facb31b27a9a872dd0a614bebb6478292de \
                            size    2447151
    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
}
