From 03cf03e581df145524c081f88ad99b2e5cc255f1 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 27 Feb 2018 13:00:07 +0100 Subject: [PATCH] spglib: add new package (#7321) --- .../packages/spglib/fix_cmake_install.patch | 25 ++++++++++++ .../builtin/packages/spglib/fix_cpp.patch | 34 ++++++++++++++++ .../repos/builtin/packages/spglib/package.py | 39 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 var/spack/repos/builtin/packages/spglib/fix_cmake_install.patch create mode 100644 var/spack/repos/builtin/packages/spglib/fix_cpp.patch create mode 100644 var/spack/repos/builtin/packages/spglib/package.py diff --git a/var/spack/repos/builtin/packages/spglib/fix_cmake_install.patch b/var/spack/repos/builtin/packages/spglib/fix_cmake_install.patch new file mode 100644 index 0000000000..d7451460db --- /dev/null +++ b/var/spack/repos/builtin/packages/spglib/fix_cmake_install.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3296d91..d18d26c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -47,17 +47,17 @@ set(SOURCES ${PROJECT_SOURCE_DIR}/src/arithmetic.c + add_library(symspg SHARED ${SOURCES}) + set_property(TARGET symspg PROPERTY VERSION ${serial}) + set_property(TARGET symspg PROPERTY SOVERSION ${soserial}) +-install(TARGETS symspg LIBRARY DESTINATION ${PROJECT_SOURCE_DIR}/lib) ++install(TARGETS symspg LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + + # Static link library + add_library(symspg_static STATIC ${SOURCES}) + set_property(TARGET symspg_static PROPERTY VERSION ${serial}) + set_property(TARGET symspg_static PROPERTY SOVERSION ${soserial}) + set_property(TARGET symspg_static PROPERTY OUTPUT_NAME symspg) +-install(TARGETS symspg_static ARCHIVE DESTINATION ${PROJECT_SOURCE_DIR}/lib) ++install(TARGETS symspg_static ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) + + # Header file +-install(FILES ${PROJECT_SOURCE_DIR}/src/spglib.h DESTINATION ${PROJECT_SOURCE_DIR}/include) ++install(FILES ${PROJECT_SOURCE_DIR}/src/spglib.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include) + + # make check + enable_testing() diff --git a/var/spack/repos/builtin/packages/spglib/fix_cpp.patch b/var/spack/repos/builtin/packages/spglib/fix_cpp.patch new file mode 100644 index 0000000000..9ab4c9bffe --- /dev/null +++ b/var/spack/repos/builtin/packages/spglib/fix_cpp.patch @@ -0,0 +1,34 @@ +From a91ea68d6771ed7d6b03bcbffd891489dc77e574 Mon Sep 17 00:00:00 2001 +From: Krishnendu Ghosh +Date: Thu, 22 Feb 2018 14:24:14 -0500 +Subject: [PATCH] added extern "C" + +--- + src/spglib.h | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/spglib.h b/src/spglib.h +index e1746b1..530dfa4 100644 +--- a/src/spglib.h ++++ b/src/spglib.h +@@ -35,6 +35,9 @@ + #ifndef __spglib_H__ + #define __spglib_H__ + ++#ifdef __cplusplus ++extern "C" { ++#endif + /* SPGCONST is used instead of 'const' so to avoid gcc warning. */ + /* However there should be better way than this way.... */ + #ifndef SPGCONST +@@ -481,4 +484,7 @@ void spg_get_neighboring_grid_points(int relative_grid_points[], + /* Return 0 if failed */ + int spg_niggli_reduce(double lattice[3][3], const double symprec); + ++#ifdef __cplusplus ++} ++#endif + #endif +-- +2.7.4.1.g5468f9e + diff --git a/var/spack/repos/builtin/packages/spglib/package.py b/var/spack/repos/builtin/packages/spglib/package.py new file mode 100644 index 0000000000..45f35a0cdc --- /dev/null +++ b/var/spack/repos/builtin/packages/spglib/package.py @@ -0,0 +1,39 @@ +############################################################################## +# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/spack/spack +# Please also see the NOTICE and LICENSE files for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +from spack import * + + +class Spglib(CMakePackage): + """C library for finding and handling crystal symmetries.""" + + homepage = "https://atztogo.github.io/spglib/" + url = "https://github.com/atztogo/spglib/archive/v1.10.3.tar.gz" + + patch('fix_cmake_install.patch', when='@:1.10.3') + # patch by Krishnendu Ghosh + patch('fix_cpp.patch', when='@:1.10.3') + + version('1.10.3', 'f6ef0554fa528ffa49d8eaee18a2b7b9') + version('1.10.0', '0ad9330ae8a511d25e2e26cb9bf02808')