# Copyright 2024-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake

DESCRIPTION="Package for generating maximally-localized Wannier functions"
HOMEPAGE="https://wannier.org"

SRC_URI="https://github.com/wannier-developers/wannier90/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64"

LICENSE="LGPL-2.1+"
IUSE="mpi test"
SLOT="0"

DEPEND="
	sci-libs/flexiblas[system-blas]
        mpi? ( virtual/mpi[fortran] >=sys-devel/gcc-12 )
	!mpi? ( >=sys-devel/gcc-12[fortran] )
"

BDEPEND="
	test? ( >=dev-python/pytest-xdist-3.0 >=dev-python/pytest-xdist-2.0 >=dev-python/pyyaml-5.4 )
"

src_configure() {
        local mycmakeargs=(
		-DWANNIER90_WITH_C=ON
		-DWANNIER90_SHARED_LIBS=ON
		-DWANNIER90_MPI="$(usex mpi ON OFF)"
		-DWANNIER90_TEST="$(usex test ON OFF)"
        )
        cmake_src_configure
}