openPMD-api: use cmake helpers (#21973)
Modernize the `openpmd-api` package to use fancy new `CMakePackage` helpers when setting options from variants :-)
This commit is contained in:
parent
f28ca41d02
commit
46905bb445
@ -10,7 +10,7 @@ class OpenpmdApi(CMakePackage):
|
|||||||
"""API for easy reading and writing of openPMD files"""
|
"""API for easy reading and writing of openPMD files"""
|
||||||
|
|
||||||
homepage = "http://www.openPMD.org"
|
homepage = "http://www.openPMD.org"
|
||||||
url = "https://github.com/openPMD/openPMD-api/archive/0.13.1.tar.gz"
|
url = "https://github.com/openPMD/openPMD-api/archive/0.13.2.tar.gz"
|
||||||
git = "https://github.com/openPMD/openPMD-api.git"
|
git = "https://github.com/openPMD/openPMD-api.git"
|
||||||
|
|
||||||
maintainers = ['ax3l']
|
maintainers = ['ax3l']
|
||||||
@ -62,42 +62,33 @@ def cmake_args(self):
|
|||||||
spec = self.spec
|
spec = self.spec
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
'-DBUILD_SHARED_LIBS:BOOL={0}'.format(
|
self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
|
||||||
'ON' if '+shared' in spec else 'OFF'),
|
|
||||||
# variants
|
# variants
|
||||||
'-DopenPMD_USE_MPI:BOOL={0}'.format(
|
self.define_from_variant('openPMD_USE_MPI', 'mpi'),
|
||||||
'ON' if '+mpi' in spec else 'OFF'),
|
self.define_from_variant('openPMD_USE_HDF5', 'hdf5'),
|
||||||
'-DopenPMD_USE_HDF5:BOOL={0}'.format(
|
self.define_from_variant('openPMD_USE_ADIOS1', 'adios1'),
|
||||||
'ON' if '+hdf5' in spec else 'OFF'),
|
self.define_from_variant('openPMD_USE_ADIOS2', 'adios2'),
|
||||||
'-DopenPMD_USE_ADIOS1:BOOL={0}'.format(
|
self.define_from_variant('openPMD_USE_PYTHON', 'python'),
|
||||||
'ON' if '+adios1' in spec else 'OFF'),
|
|
||||||
'-DopenPMD_USE_ADIOS2:BOOL={0}'.format(
|
|
||||||
'ON' if '+adios2' in spec else 'OFF'),
|
|
||||||
'-DopenPMD_USE_PYTHON:BOOL={0}'.format(
|
|
||||||
'ON' if '+python' in spec else 'OFF'),
|
|
||||||
# tests and examples
|
# tests and examples
|
||||||
'-DBUILD_TESTING:BOOL={0}'.format(
|
self.define('BUILD_TESTING', self.run_tests),
|
||||||
'ON' if self.run_tests else 'OFF'),
|
self.define('BUILD_EXAMPLES', self.run_tests)
|
||||||
'-DBUILD_EXAMPLES:BOOL={0}'.format(
|
|
||||||
'ON' if self.run_tests else 'OFF'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# switch internally shipped third-party libraries for spack
|
# switch internally shipped third-party libraries for spack
|
||||||
if spec.satisfies('+python'):
|
if spec.satisfies('+python'):
|
||||||
args.append('-DopenPMD_USE_INTERNAL_PYBIND11:BOOL=OFF')
|
py_exe_define = 'Python_EXECUTABLE' \
|
||||||
if spec.version >= Version('0.13.0'):
|
if spec.version >= Version('0.13.0') else 'PYTHON_EXECUTABLE'
|
||||||
args.append('-DPython_ROOT_DIR:FILEPATH={0}'.format(
|
args += [
|
||||||
self.spec['python'].prefix))
|
self.define(py_exe_define, self.spec['python'].command.path),
|
||||||
else:
|
self.define('openPMD_USE_INTERNAL_PYBIND11', False)
|
||||||
args.append('-DPYTHON_EXECUTABLE:FILEPATH={0}'.format(
|
]
|
||||||
self.spec['python'].command.path))
|
|
||||||
|
|
||||||
args.extend([
|
args += [
|
||||||
'-DopenPMD_USE_INTERNAL_JSON:BOOL=OFF',
|
self.define('openPMD_USE_INTERNAL_JSON', False),
|
||||||
'-DopenPMD_USE_INTERNAL_VARIANT:BOOL=OFF'
|
self.define('openPMD_USE_INTERNAL_VARIANT', False)
|
||||||
])
|
]
|
||||||
if self.run_tests:
|
if self.run_tests:
|
||||||
args.append('-DopenPMD_USE_INTERNAL_CATCH:BOOL=OFF')
|
args.append(self.define('openPMD_USE_INTERNAL_CATCH', False))
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user