# Copyright 2013-2022 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 sys
from spack import *
class Cgns(CMakePackage):
"""The CFD General Notation System (CGNS) provides a general, portable,
and extensible standard for the storage and retrieval of computational
fluid dynamics (CFD) analysis data."""
homepage = "https://cgns.github.io/"
url = "https://github.com/CGNS/CGNS/archive/v3.3.0.tar.gz"
git = "https://github.com/CGNS/CGNS"
parallel = False
version('develop', branch='develop')
version('master', branch='master')
version('4.2.0', sha256='090ec6cb0916d90c16790183fc7c2bd2bd7e9a5e3764b36c8196ba37bf1dc817')
version('4.1.2', sha256='951653956f509b8a64040f1440c77f5ee0e6e2bf0a9eef1248d370f60a400050')
version('4.1.1', sha256='055d345c3569df3ae832fb2611cd7e0bc61d56da41b2be1533407e949581e226')
version('4.1.0', sha256='4674de1fac3c47998248725fd670377be497f568312c5903d1bb8090a3cf4da0')
version('4.0.0', sha256='748585a8e52dff4d250d6b603e6b847d05498e4566aba2dc3d7a7d85c4d55849')
version('3.4.1', sha256='d32595e7737b9332243bd3de1eb8c018a272f620f09b289dea8292eba1365994')
version('3.4.0', sha256='6372196caf25b27d38cf6f056258cb0bdd45757f49d9c59372b6dbbddb1e05da')
version('3.3.1', sha256='81093693b2e21a99c5640b82b267a495625b663d7b8125d5f1e9e7aaa1f8d469')
version('3.3.0', sha256='8422c67994f8dc6a2f201523a14f6c7d7e16313bdd404c460c16079dbeafc662')
variant('hdf5', default=True, description='Enable HDF5 interface')
variant('fortran', default=False, description='Enable Fortran interface')
variant('base_scope', default=False, description='Enable base scope')
variant('scoping', default=True, description='Enable scoping')
variant('mpi', default=True, description='Enable parallel cgns')
variant('int64', default=False, description='Build with 64-bit integers')
variant('shared', default=True, description='Enable shared library')
variant('static', default=False, description='Build static libraries')
variant('testing', default=False, description='Build CGNS testing')
variant('legacy', default=False, description='Enable legacy options')
variant('mem_debug', default=False, description='Enable memory debugging option')
depends_on('cmake@3.8:', when='@4.2:', type='build')
depends_on('cmake@2.8:', when='@:4.1', type='build')
depends_on('hdf5~mpi', when='+hdf5~mpi')
depends_on('hdf5+mpi', when='+hdf5+mpi')
depends_on('mpi', when='+mpi')
def cmake_args(self):
spec = self.spec
options = []
options.extend([
self.define_from_variant('CGNS_ENABLE_FORTRAN', 'fortran'),
self.define_from_variant('CGNS_ENABLE_SCOPING', 'scoping'),
self.define_from_variant('CGNS_ENABLE_PARALLEL', 'mpi'),
'-DCGNS_ENABLE_TESTS:BOOL=OFF',
self.define_from_variant('CGNS_BUILD_TESTING', 'testing'),
'-DCGNS_BUILD_CGNSTOOLS:BOOL=OFF',
self.define_from_variant('CGNS_BUILD_SHARED', 'shared'),
self.define_from_variant('CGNS_BUILD_STATIC', 'static'),
self.define_from_variant('CGNS_ENABLE_BASE_SCOPE', 'base_scope'),
self.define_from_variant('CGNS_ENABLE_LEGACY', 'legacy'),
self.define_from_variant('CGNS_ENABLE_MEM_DEBUG', 'mem_debug')
])
if '+mpi' in spec:
options.extend([
'-DCMAKE_C_COMPILER=%s' % spec['mpi'].mpicc,
'-DCMAKE_CXX_COMPILER=%s' % spec['mpi'].mpicxx,
'-DCMAKE_Fortran_COMPILER=%s' % spec['mpi'].mpifc
])
options.append(
self.define_from_variant('CGNS_ENABLE_64BIT', 'int64'))
if '+hdf5' in spec:
options.extend([
'-DCGNS_ENABLE_HDF5:BOOL=ON',
'-DHDF5_NEED_ZLIB:BOOL=ON',
'-DHDF5_INCLUDE_DIR:PATH=%s' % spec['hdf5'].prefix.include,
'-DHDF5_LIBRARY_DIR:PATH=%s' % spec['hdf5'].prefix.lib
])
if '+mpi' in spec:
options.extend([
'-DHDF5_NEED_MPI:BOOL=ON',
'-DHDF5_ENABLE_PARALLEL:BOOL=ON'
])
else:
options.extend(['-DCGNS_ENABLE_HDF5=OFF'])
if self.version <= Version('3.3.1'):
if sys.platform == 'darwin':
options.extend([
'-DCMAKE_MACOSX_RPATH:BOOL=ON'
])
return options