adios2: Define custom libs property (#20848)

This commit is contained in:
Chuck Atkins 2021-01-13 17:42:36 -05:00 committed by GitHub
parent fc4e66ef3c
commit 4f49b1a930
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
import os
class Adios2(CMakePackage):
@ -210,14 +211,41 @@ def cmake_args(self):
return args
def setup_run_environment(self, env):
# Make sure the libadiso2_h5vol.so plugin in the search path for hdf5
# plugins. Note that we're not actually testing if the vol lib is
# found and just assuming it is. If libadiso2_h5vol.so does not exist
# it's certainly an error regardless. By not guarding with an "if vol"
# we help ensure that it doesn't silently break.
@property
def libs(self):
spec = self.spec
libs_to_seek = set()
if spec.satisfies('@2.6:'):
libs_to_seek.add('libadios2_core')
libs_to_seek.add('libadios2_c')
libs_to_seek.add('libadios2_cxx11')
if '+fortran' in spec:
libs_to_seek.add('libadios2_fortran')
if '+mpi' in spec:
libs_to_seek.add('libadios2_core_mpi')
libs_to_seek.add('libadios2_c_mpi')
libs_to_seek.add('libadios2_cxx11_mpi')
if '+fortran' in spec:
libs_to_seek.add('libadios2_fortran_mpi')
if (self.spec.satisfies('@2.7: +shared+hdf5') and
self.spec['hdf5'].satisfies('@1.12:')):
vol = find_libraries('libadios2_h5vol', root=self.spec.prefix,
recursive=True)
env.prepend_path('HDF5_PLUGIN_PATH', vol.directories[0])
libs_to_seek.add('libadios2_h5vol')
else:
libs_to_seek.add('libadios2')
if '+fortran' in spec:
libs_to_seek.add('libadios2_fortran')
return find_libraries(list(libs_to_seek), root=self.spec.prefix,
shared=('+shared' in spec), recursive=True)
def setup_run_environment(self, env):
try:
all_libs = self.libs
idx = all_libs.basenames.index('libadios2_h5vol.so')
env.prepend_path('HDF5_PLUGIN_PATH', os.path.dirname(all_libs[idx]))
except ValueError:
pass