precice: add version 2.0.0 (#14842)

Added python3 dependency
Added support for new CMake variables
This commit is contained in:
Frédéric Simonis 2020-02-11 10:06:03 +01:00 committed by GitHub
parent 7706b76d3a
commit e8b6c40b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ class Precice(CMakePackage):
maintainers = ['fsimonis', 'MakisH'] maintainers = ['fsimonis', 'MakisH']
version('develop', branch='develop') version('develop', branch='develop')
version('2.0.0', sha256='c8979d366f06e35626a8da08a1c589df77ec13972eb524a1ba99a011e245701f')
version('1.6.1', sha256='7d0c54faa2c69e52304f36608d93c408629868f16f3201f663a0f9b2008f0763') version('1.6.1', sha256='7d0c54faa2c69e52304f36608d93c408629868f16f3201f663a0f9b2008f0763')
version('1.6.0', sha256='c3b16376fda9eb3449adb6cc3c1e267c3dc792a5d118e37d93a32a59b5a4bc6f') version('1.6.0', sha256='c3b16376fda9eb3449adb6cc3c1e267c3dc792a5d118e37d93a32a59b5a4bc6f')
version('1.5.2', sha256='051e0d7655a91f8681901e5c92812e48f33a5779309e2f104c99f5a687e1a418') version('1.5.2', sha256='051e0d7655a91f8681901e5c92812e48f33a5779309e2f104c99f5a687e1a418')
@ -44,9 +45,14 @@ class Precice(CMakePackage):
depends_on('libxml2') depends_on('libxml2')
depends_on('mpi', when='+mpi') depends_on('mpi', when='+mpi')
depends_on('petsc@3.6:', when='+petsc') depends_on('petsc@3.6:', when='+petsc')
depends_on('python@2.7:2.8', when='+python', type=('build', 'run'))
# Python 3 support was added in version 2.0
depends_on('python@2.7:2.8', when='@:1.9+python', type=('build', 'run'))
depends_on('python@3:', when='@2:+python', type=('build', 'run'))
# numpy 1.17+ requires Python 3 # numpy 1.17+ requires Python 3
depends_on('py-numpy@:1.16', when='+python', type=('build', 'run')) depends_on('py-numpy@:1.16', when='@:1.9+python', type=('build', 'run'))
depends_on('py-numpy@1.17:', when='@2:+python', type=('build', 'run'))
# We require C++11 compiler support as well as # We require C++11 compiler support as well as
# library support for time manipulators (N2071, N2072) # library support for time manipulators (N2071, N2072)
@ -62,6 +68,17 @@ def cmake_args(self):
# The xSDK installation policies were implemented after 1.5.2 # The xSDK installation policies were implemented after 1.5.2
xsdk_mode = spec.satisfies("@1.6:") xsdk_mode = spec.satisfies("@1.6:")
# Select the correct CMake variables by version
mpi_option = "MPI"
if spec.satisfies("@2:"):
mpi_option = "PRECICE_MPICommunication"
petsc_option = "PETSC"
if spec.satisfies("@2:"):
petsc_option = "PRECICE_PETScMapping"
python_option = "PYTHON"
if spec.satisfies("@2:"):
python_option = "PRECICE_PythonActions"
def variant_bool(feature, on='ON', off='OFF'): def variant_bool(feature, on='ON', off='OFF'):
"""Ternary for spec variant to ON/OFF string""" """Ternary for spec variant to ON/OFF string"""
if feature in spec: if feature in spec:
@ -70,9 +87,10 @@ def variant_bool(feature, on='ON', off='OFF'):
cmake_args = [ cmake_args = [
'-DBUILD_SHARED_LIBS:BOOL=%s' % variant_bool('+shared'), '-DBUILD_SHARED_LIBS:BOOL=%s' % variant_bool('+shared'),
'-DMPI:BOOL=%s' % variant_bool('+mpi'),
] ]
cmake_args.append('-D%s:BOOL=%s' % (mpi_option, variant_bool('+mpi')))
# Boost # Boost
if xsdk_mode: if xsdk_mode:
cmake_args.append('-DTPL_ENABLE_BOOST=ON') cmake_args.append('-DTPL_ENABLE_BOOST=ON')
@ -95,13 +113,16 @@ def variant_bool(feature, on='ON', off='OFF'):
# PETSc # PETSc
if '+petsc' in spec: if '+petsc' in spec:
if xsdk_mode:
cmake_args.append('-DTPL_ENABLE_PETSC:BOOL=ON')
else:
cmake_args.append('-D%s:BOOL=ON' % petsc_option)
cmake_args.extend([ cmake_args.extend([
'-DTPL_ENABLE_PETSC:BOOL=ON' if xsdk_mode else '-DPETSC=ON',
'-DPETSC_DIR=%s' % spec['petsc'].prefix, '-DPETSC_DIR=%s' % spec['petsc'].prefix,
'-DPETSC_ARCH=.' '-DPETSC_ARCH=.'
]) ])
else: else:
cmake_args.append('-DPETSC:BOOL=OFF') cmake_args.append('-D%s:BOOL=OFF' % petsc_option)
# Python # Python
if '+python' in spec: if '+python' in spec:
@ -111,13 +132,16 @@ def variant_bool(feature, on='ON', off='OFF'):
spec['py-numpy'].prefix, spec['py-numpy'].prefix,
spec['python'].package.site_packages_dir, spec['python'].package.site_packages_dir,
'numpy', 'core', 'include') 'numpy', 'core', 'include')
if xsdk_mode:
cmake_args.append('-DTPL_ENABLE_PYTHON:BOOL=ON')
else:
cmake_args.append('-D%s:BOOL=ON' % python_option)
cmake_args.extend([ cmake_args.extend([
'-DTPL_ENABLE_PYTHON:BOOL=ON' if xsdk_mode else '-DPYTHON=ON',
'-DPYTHON_INCLUDE_DIR=%s' % python_include, '-DPYTHON_INCLUDE_DIR=%s' % python_include,
'-DNumPy_INCLUDE_DIR=%s' % numpy_include, '-DNumPy_INCLUDE_DIR=%s' % numpy_include,
'-DPYTHON_LIBRARY=%s' % python_library '-DPYTHON_LIBRARY=%s' % python_library
]) ])
else: else:
cmake_args.append('-DPYTHON:BOOL=OFF') cmake_args.append('-D%s:BOOL=OFF' % python_option)
return cmake_args return cmake_args