diff options
3 files changed, 145 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/sirius/link-libraries-fortran.patch b/var/spack/repos/builtin/packages/sirius/link-libraries-fortran.patch new file mode 100644 index 0000000000..16de3a1710 --- /dev/null +++ b/var/spack/repos/builtin/packages/sirius/link-libraries-fortran.patch @@ -0,0 +1,25 @@ +From 76f238d0ebcfc186f5210b0807b6a83a5c17bd43 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tiziano=20M=C3=BCller?= <tiziano.mueller@chem.uzh.ch> +Date: Wed, 24 Apr 2019 15:30:50 +0200 +Subject: [PATCH 2/2] cmake: properly link Fortran lib against used libraries + +--- + src/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index b927adef..a0d4aeb3 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -13,7 +13,7 @@ if(USE_CUDA) + endif() + if(CREATE_FORTRAN_BINDINGS) + add_library(sirius_f "sirius_api.cpp;sirius.f90") +- add_dependencies(sirius_f generate_version_hpp runtime_options_json_hpp) ++ SIRIUS_SETUP_TARGET(sirius_f) + INSTALL (TARGETS sirius_f ARCHIVE DESTINATION + ${CMAKE_INSTALL_PREFIX}/lib/) + set_target_properties(sirius_f PROPERTIES POSITION_INDEPENDENT_CODE ON) +-- +2.16.4 + diff --git a/var/spack/repos/builtin/packages/sirius/package.py b/var/spack/repos/builtin/packages/sirius/package.py new file mode 100644 index 0000000000..3cbb3643df --- /dev/null +++ b/var/spack/repos/builtin/packages/sirius/package.py @@ -0,0 +1,95 @@ +# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +import os + +from spack import * + + +class Sirius(CMakePackage): + """Domain specific library for electronic structure calculations""" + + homepage = "https://github.com/electronic-structure/SIRIUS" + url = "https://github.com/electronic-structure/SIRIUS/archive/v6.1.5.tar.gz" + list_url = "https://github.com/electronic-structure/SIRIUS/releases" + + version('6.1.5', sha256='379f0a2e5208fd6d91c2bd4939c3a5c40002975fb97652946fa1bfe4a3ef97cb') + + variant('shared', default=False, description="Build shared libraries") + variant('openmp', default=True, description="Build with OpenMP support") + variant('fortran', default=False, description="Build Fortran bindings") + variant('elpa', default=False, description="Use ELPA") + variant('vdwxc', default=False, description="Enable libvdwxc support") + variant('scalapack', default=False, description="Enable scalapack support") + + depends_on('python') + depends_on('mpi') + depends_on('gsl') + depends_on('lapack') + depends_on('fftw') # SIRIUS does not care about MPI-support in FFTW + depends_on('libxc') + depends_on('spglib') + depends_on('hdf5+hl') + depends_on('pkgconfig', type='build') + + depends_on('elpa+openmp', when='+elpa+openmp') + depends_on('elpa~openmp', when='+elpa~openmp') + depends_on('libvdwxc+mpi', when='+vdwxc') + depends_on('scalapack', when='+scalapack') + + # TODO: + # add support for MKL, CUDA, MAGMA, CRAY_LIBSCI, Python bindings, testing + + patch("strip-spglib-include-subfolder.patch") + patch("link-libraries-fortran.patch") + + @property + def libs(self): + libraries = [] + + if self.spec.satisfies('+fortran'): + libraries += ['libsirius_f'] + + return find_libraries( + libraries, root=self.prefix, + shared=self.spec.satisfies('+shared'), recursive=True + ) + + def cmake_args(self): + def _def(variant, flag=None): + """Returns "-DUSE_VARIANT:BOOL={ON,OFF}" depending on whether + +variant is set. If the CMake flag differs from the variant + name, pass the flag name explicitly. + """ + + return "-D{0}:BOOL={1}".format( + flag if flag else "USE_{0}".format( + variant.strip('+~').upper() + ), + "ON" if self.spec.satisfies(variant) else "OFF" + ) + + args = [ + '-DBUILD_SHARED_LIBS=ON', + _def('+openmp'), + _def('+elpa'), + _def('+vdwxc'), + _def('+scalapack'), + _def('+fortran', 'CREATE_FORTRAN_BINDINGS'), + ] + + if self.spec.satisfies('+elpa'): + elpa = self.spec['elpa'] + elpa_suffix = '_openmp' if elpa.satisfies('+openmp') else '' + elpa_incdir = os.path.join( + elpa.prefix, + 'include', + 'elpa{suffix}-{version!s}'.format( + suffix=elpa_suffix, version=elpa.version), + 'elpa') + + args += ["-DELPA_INCLUDE_DIR={0}".format(elpa_incdir)] + + return args diff --git a/var/spack/repos/builtin/packages/sirius/strip-spglib-include-subfolder.patch b/var/spack/repos/builtin/packages/sirius/strip-spglib-include-subfolder.patch new file mode 100644 index 0000000000..0e775149a3 --- /dev/null +++ b/var/spack/repos/builtin/packages/sirius/strip-spglib-include-subfolder.patch @@ -0,0 +1,25 @@ +From 1a4ae29387790183b3de38acf8d38623429f3f62 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tiziano=20M=C3=BCller?= <tiziano.mueller@chem.uzh.ch> +Date: Wed, 24 Apr 2019 11:29:05 +0200 +Subject: [PATCH] spglib does not install to a subfolder by default + +--- + src/Unit_cell/unit_cell_symmetry.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Unit_cell/unit_cell_symmetry.hpp b/src/Unit_cell/unit_cell_symmetry.hpp +index 9852bd4a..2c5a1e04 100644 +--- a/src/Unit_cell/unit_cell_symmetry.hpp ++++ b/src/Unit_cell/unit_cell_symmetry.hpp +@@ -26,7 +26,7 @@ + #define __UNIT_CELL_SYMMETRY_HPP__ + + extern "C" { +-#include <spglib/spglib.h> ++#include <spglib.h> + } + + #include "geometry3d.hpp" +-- +2.16.4 + |