Adding dune-functions and dune-typetree

This commit is contained in:
Gauthier Folzan 2020-04-02 13:07:33 +02:00
parent 540f0a02e4
commit 4bfe34f2fc
5 changed files with 241 additions and 45 deletions

View File

@ -0,0 +1,31 @@
--- a/cmake/modules/AddQuadMathFlags.cmake 2020-03-24 07:54:22.548925006 +0100
+++ b/cmake/modules/AddQuadMathFlags.cmake.patched 2020-03-24 22:53:43.127262894 +0100
@@ -0,0 +1,28 @@
+# Defines the functions to use QuadMath
+#
+# .. cmake_function:: add_dune_quadmath_flags
+#
+# .. cmake_param:: targets
+# :positional:
+# :single:
+# :required:
+#
+# A list of targets to use QuadMath with.
+#
+
+
+function(add_dune_quadmath_flags _targets)
+ if(QUADMATH_FOUND)
+ foreach(_target ${_targets})
+ target_link_libraries(${_target} "quadmath")
+ set_property(TARGET ${_target}
+ APPEND_STRING
+ PROPERTY COMPILE_FLAGS "-DENABLE_QUADMATH=1 -D_GLIBCXX_USE_FLOAT128=1 ")
+ if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
+ set_property(TARGET ${_target}
+ APPEND_STRING
+ PROPERTY COMPILE_FLAGS "-fext-numeric-literals ")
+ endif()
+ endforeach(_target ${_targets})
+ endif(QUADMATH_FOUND)
+endfunction(add_dune_quadmath_flags)

View File

@ -0,0 +1,62 @@
--- a/cmake/modules/FindQuadMath.cmake 2020-03-24 07:54:22.548925006 +0100
+++ b/cmake/modules/FindQuadMath.cmake.patched 2020-03-24 22:53:43.127262894 +0100
@@ -0,0 +1,59 @@
+# .. cmake_module::
+#
+# Find the GCC Quad-Precision library
+#
+# Sets the following variables:
+#
+# :code:`QUADMATH_FOUND`
+# True if the Quad-Precision library was found.
+#
+#
+
+
+# search for the header quadmath.h
+include(CheckIncludeFile)
+check_include_file(quadmath.h QUADMATH_HEADER)
+
+include(CheckCSourceCompiles)
+include(CMakePushCheckState)
+
+cmake_push_check_state() # Save variables
+set(CMAKE_REQUIRED_LIBRARIES quadmath)
+check_c_source_compiles("
+#include <quadmath.h>
+
+int main ()
+{
+ __float128 r = 1.0q;
+ r = strtoflt128(\"1.2345678\", NULL);
+ return 0;
+}" QUADMATH_COMPILES)
+cmake_pop_check_state()
+
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+ "QuadMath"
+ DEFAULT_MSG
+ QUADMATH_HEADER
+ QUADMATH_COMPILES
+)
+
+# text for feature summary
+set_package_properties("QuadMath" PROPERTIES
+ DESCRIPTION "GCC Quad-Precision library")
+
+# set HAVE_QUADMATH for config.h
+set(HAVE_QUADMATH ${QUADMATH_FOUND})
+
+# -fext-numeric-literals is a GCC extension not available in other compilers like clang
+if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
+ set(_QUADMATH_EXT_NUMERIC_LITERALS "-fext-numeric-literals")
+endif()
+
+# register all QuadMath related flags
+if(HAVE_QUADMATH)
+ dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_QUADMATH=1" "_GLIBCXX_USE_FLOAT128=1"
+ COMPILE_OPTIONS ${_QUADMATH_EXT_NUMERIC_LITERALS}
+ LIBRARIES "quadmath")
+endif()

View File

@ -0,0 +1,128 @@
# Copyright 2013-2020 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)
# ----------------------------------------------------------------------------
# If you submit this package back to Spack as a pull request,
# please first remove this boilerplate and all FIXME comments.
#
# This is a template package file for Spack. We've put "FIXME"
# next to all the things you'll want to change. Once you've handled
# them, you can save this file and test your package like this:
#
# spack install dune-functions
#
# You can edit this file again by typing:
#
# spack edit dune-functions
#
# See the Spack documentation for more information on packaging.
# ----------------------------------------------------------------------------
from spack import *
class DuneFunctions(CMakePackage):
"""Abstractions for functions and discrete function space bases"""
homepage = "https://www.dune-project.org"
url = "https://gitlab.dune-project.org/staging/dune-functions/-/archive/releases/2.7/dune-functions-releases-2.7.tar.gz"
list_url = 'https://gitlab.dune-project.org/staging/dune-functions/-/archive/releases/'
list_depth = 1
version('2.7', sha256='cd9b16748f285ded2c9a4378d5b2b320e81180c9da88ea647f5a712cba442f80')
version('2.6', sha256='3df99f6d741ceb0b0f2fbba05e5562f5c65b9e45385991801f68fa163a2474a1')
#option
variant('blas', default=True, description='Build with BLAS support')
variant('lapack', default=True, description='Build with LAPACK support')
variant('gmp', default=True, description='Build with GNU multi-precision library support')
variant('tbb', default=True, description='Build with Threading Building Blocks library support')
variant('mkl', default=True, description='Build with Math Kernel library support')
variant('doxygen', default=True, description='Create Doxygen documentation')
variant('sphinx', default=True, description='Create Sphinx documentation')
variant('vc', default=True, description='Build C++ Vectorization library support')
variant('uggrid', default=True, description='Build with dune-uggrid support')
variant('imagemagick', default=False, description='Imagemagick support')
variant('metis', default=True, description='Build METIS library support')
variant('parmetis', default=True, description='Build ParMETIS library support')
variant('arpack', default=True, description='Build ARnoldi PACKage library support')
variant('suitesparse', default=True, description='Build SuiteSparse library support')
variant('superlu', default=True, description='Build Supernodal LU library support')
variant('alberta', default=False, description='Build with Alberta support')
variant('psurface', default=False, description='Build with Psurface support')
variant('amiramesh', default=False, description='Build with AmiraMesh support')
variant('selector', default=True, description='Grid selector definition added to config.h')
variant('oldcategory', default=True, description='Enable/Disable the backwards compatibility of the category enum/method in dune-istl solvers, preconditioner, etc.')
variant('threads', default=True, description='Activate pThread support')
variant('shared', default=True, description='Enables the build of shared libraries.')
variant('alugrid', default=False, description='Support of dune-alugrid module')
variant('fempy', default=False, description='Support of dune-fempy module')
variant('spgrid', default=False, description='Support of dune-spgrid module')
#dependencies
depends_on('dune-localfunctions')
depends_on('dune-grid')
depends_on('dune-grid+uggrid', when='+uggrid')
depends_on('dune-typetree')
depends_on('dune-istl')
depends_on('dune-common+python+shared')
depends_on('cmake@3.1:', type='build')
depends_on('mpi')
depends_on('blas', when='+blas')
depends_on('lapack', when='+lapack')
depends_on('doxygen', type='build', when='+doxygen')
depends_on('gmp', when='+gmp')
depends_on('intel-tbb', when='+tbb')
depends_on('intel-mkl', when='+mkl')
depends_on('python@3.8.2:')
depends_on('py-sphinx', type='build', when='+sphinx')
depends_on('vc', when='+vc')
depends_on('pkg-config', type='build')
depends_on('imagemagick', type='build', when='+imagemagick')
depends_on('metis', when='+metis')
depends_on('parmetis', when='+parmetis')
depends_on('arpack-ng', when='+arpack')
depends_on('suite-sparse', when='+suitesparse')
depends_on('superlu', when='+superlu')
depends_on('alberta', when='+alberta')
depends_on('psurface', when='+psurface')
depends_on('amiramesh', when='+amiramesh')
def url_for_version(self, version):
url = 'https://gitlab.dune-project.org/staging/dune-functions/-/archive/releases/{1}/dune-functions-releases-{1}.tar.gz'
return url.format(version.up_to(2), version)
patch('AddQuadMathFlags.cmake.patch')
patch('FindQuadMath.cmake.patch')
def cmake_args(self):
"""Populate cmake arguments."""
spec = self.spec
def variant_bool(feature, on='ON', off='OFF'):
"""Ternary for spec variant to ON/OFF string"""
if feature in spec:
return on
return off
def nvariant_bool(feature):
"""Negated ternary for spec variant to OFF/ON string"""
return variant_bool(feature, on='OFF', off='ON')
cmake_args = [
# '-DDUNE_BUILD_BOTH_LIBS=%s' % variant_bool('+shared'),
'-DBUILD_SHARED_LIBS:BOOL=%s' % variant_bool('+shared'),
'-DDUNE_GRID_EXTRA_UTILS:BOOL=%s' % variant_bool('+extrautils'),
'-DDUNE_GRID_GRIDTYPE_SELECTOR:BOOL=%s' % variant_bool('+selector'),
'-DDUNE_ISTL_SUPPORT_OLD_CATEGORY=%s' % variant_bool('+oldcategory'),
'-DUSE_PTHREADS:BOOL=%s' % variant_bool('+threads'),
]
if 'python' in spec:
cmake_args.append('-DPYTHON_INSTALL_LOCATION:STRING="system"')
return cmake_args

View File

@ -21,7 +21,6 @@
# ----------------------------------------------------------------------------
from spack import *
import os
class DunePython(CMakePackage):
@ -33,9 +32,7 @@ class DunePython(CMakePackage):
# url = "https://www.dune-project.org/download/2.6.0/dune-python-2.6.0.tar.gz"
url = 'https://gitlab.dune-project.org/staging/dune-python/-/archive/releases/2.7/dune-python-releases-2.7.tar.gz'
list_url = 'https://gitlab.dune-project.org/staging/dune-python/-/archive/releases/'
# list_url = "https://www.dune-project.org/download/"
list_depth = 1
# version('2.7.0', url = 'https://gitlab.dune-project.org/staging/dune-python/-/archive/releases/2.7/dune-python-releases-2.7.tar.gz')
python_components = [ 'dune' ]
@ -81,7 +78,7 @@ class DunePython(CMakePackage):
extends('python')
#dependencies
depends_on('dune-grid+python+shared')
depends_on('dune-grid+uggrid+python+shared')
depends_on('dune-istl+python+shared')
depends_on('dune-geometry+python+shared')
# depends_on('dune-uggrid', when='+uggrid')
@ -155,11 +152,6 @@ class DunePython(CMakePackage):
@run_after('install')
def install_python_components(self):
for package in self.python_components:
print(os.path.dirname(os.path.abspath(__file__)))
build_directory = 'python'
print(self)
with working_dir(join_path(self.build_directory,'python')):
print(working_dir)
print(os.path.dirname(os.path.abspath(__file__)))
print(join_path(self.build_directory,'python'))
setup_py('install', '--prefix={0}'.format(self.prefix))

View File

@ -11,11 +11,11 @@
# next to all the things you'll want to change. Once you've handled
# them, you can save this file and test your package like this:
#
# spack install dune-istl
# spack install dune-typetree
#
# You can edit this file again by typing:
#
# spack edit dune-istl
# spack edit dune-typetree
#
# See the Spack documentation for more information on packaging.
# ----------------------------------------------------------------------------
@ -24,47 +24,35 @@ from spack import *
class DuneTypetree(CMakePackage):
"""
@description@
"""
"""TypeTree is a template library for constructing and operating on statically typed trees of objects."""
homepage = "https://www.dune-project.org"
url = "https://gitlab.dune-project.org/staging/dune-typetree/-/archive/v2.6.0/dune-typetree-v2.6.0.tar.gz"
list_url = "https://www.dune-project.org/download/"
url = "https://gitlab.dune-project.org/staging/dune-typetree/-/archive/releases/2.7/dune-typetree-releases-2.7.tar.gz"
list_url = 'https://gitlab.dune-project.org/staging/dune-typetree/-/archive/releases/'
list_depth = 1
version('2.7.0', sha256='c98d218bdf79549bb2e96fc465e9f9a72f5d88b78090812a59dae85cfee3833e')
version('2.6.0', sha256='5ce06fc396624f654c3f34e333fd5900e992c4596b3230abe68617ed77f64f50')
version('2.5.2', sha256='9fe33fb60b9c9f98100bfc909eb4d56598bae4f036f01f00b4a9fd2498387178')
version('2.5.1', sha256='7e183b1361419620e3df7287d962bcbc1860fa8233588f5b25507ef7a20649dc')
version('2.5.0', sha256='f9af37af1e8186443df384f155d66d2f16e95a909f9574d2bcae85d6d14b95ab')
version('2.4.2', sha256='7e02eaa3d2d054f056709d1c9a91235b73bc0f96b47630f91c914d349093f572')
version('2.4.1', sha256='0ea512e538935812cd6f3a9504f3b06fadff5c15d9d1b0dc499a5a913ea02a4d')
version('2.4.0', sha256='205686b77f7e36d6bc0d2771b1514d98d221b608e5f4efdeeafb1a750e3ca2ba')
version('2.7', sha256='b546c2588576d4e8b22e675865628734f2f3d9a8688255742d099f41e5db574e')
version('2.6', sha256='a5d78b00ff45a30163062812c8c85f18091b6874df72ceadb9c5c718e0db07de')
version('2.5', sha256='7596858584e6805db9db701baa6362bbda0607fe19163c99a69ffa3335eee7a2')
#option
variant('blas', default=True, description='Build with BLAS support')
variant('lapack', default=True, description='Build with LAPACK support')
variant('gmp', default=True, description='Build with GNU multi-precision library support')
variant('tbb', default=True, description='Build with Threading Building Blocks library support')
variant('mkl', default=True, description='Build with Threading Building Blocks library support')
variant('mkl', default=True, description='Build with Math Kernel library support')
variant('doxygen', default=True, description='Create Doxygen documentation')
variant('sphinx', default=True, description='Create Sphinx documentation')
variant('python', default=True, description='Build with Python')
variant('vc', default=True, description='Build C++ Vectorization library support')
variant('imagemagick', default=False, description='Imagemagick support')
variant('metis', default=True, description='Build METIS library support')
variant('parmetis', default=True, description='Build ParMETIS library support')
variant('suitesparse', default=True, description='Build SuiteSparse library support')
variant('superlu', default=True, description='Build Supernodal LU library support')
variant('arpack', default=True, description='Build ARnoldi PACKage library support')
variant('oldcategory', default=True, description='Enable/Disable the backwards compatibility of the category enum/method in dune-istl solvers, preconditioner, etc.')
variant('threads', default=True, description='Activate pThread support')
variant('shared', default=False, description='Enables the build of shared libraries.')
variant('extrautils', default=True, description='Enable compilation and installation of extra utilities from the src subdirectory')
variant('selector', default=True, description='Grid selector definition added to config.h')
variant('shared', default=True, description='Enables the build of shared libraries.')
#dependencies
depends_on('dune-common')
depends_on('dune-common+shared')
depends_on('cmake@3.1:', type='build')
depends_on('mpi')
depends_on('blas', when='+blas')
@ -73,24 +61,19 @@ class DuneTypetree(CMakePackage):
depends_on('gmp', when='+gmp')
depends_on('intel-tbb', when='+tbb')
depends_on('intel-mkl', when='+mkl')
depends_on('python@3.0:')
depends_on('python@3.8.2:')
depends_on('py-sphinx', type='build', when='+sphinx')
depends_on('vc', when='+vc')
depends_on('pkg-config', type='build')
depends_on('imagemagick', type='build', when='+imagemagick')
depends_on('metis', when='+metis')
depends_on('parmetis', when='+parmetis')
depends_on('suite-sparse', when='+suitesparse')
depends_on('superlu', when='+superlu')
depends_on('arpack-ng', when='+arpack')
patch('AddQuadMathFlags.cmake.patch', when='@2.6')
patch('FindQuadMath.cmake.patch', when='@2.6')
def url_for_version(self, version):
url = "https://gitlab.dune-project.org/staging/dune-typetree/-/archive/{1}/dune-typetree-{1}.tar.gz"
url = 'https://gitlab.dune-project.org/staging/dune-typetree/-/archive/releases/{1}/dune-typetree-releases-{1}.tar.gz'
return url.format(version.up_to(2), version)
patch('AddQuadMathFlags.cmake.patch')
patch('FindQuadMath.cmake.patch')
def cmake_args(self):
"""Populate cmake arguments."""
spec = self.spec