trilinos: switch to CMakePackage and minor cleanup (#2226)

This commit is contained in:
Denis Davydov
2016-11-04 10:00:03 +01:00
committed by Todd Gamblin
parent 453331dba0
commit 29f81b7775

View File

@@ -36,7 +36,7 @@
# https://github.com/trilinos/Trilinos/issues/175 # https://github.com/trilinos/Trilinos/issues/175
class Trilinos(Package): class Trilinos(CMakePackage):
"""The Trilinos Project is an effort to develop algorithms and enabling """The Trilinos Project is an effort to develop algorithms and enabling
technologies within an object-oriented software framework for the solution technologies within an object-oriented software framework for the solution
of large-scale, complex multi-physics engineering and scientific problems. of large-scale, complex multi-physics engineering and scientific problems.
@@ -124,7 +124,8 @@ def variants_check(self):
raise RuntimeError('The superlu-dist variant can only be used' + raise RuntimeError('The superlu-dist variant can only be used' +
' with Trilinos @12.0.1:') ' with Trilinos @12.0.1:')
def install(self, spec, prefix): def cmake_args(self):
spec = self.spec
self.variants_check() self.variants_check()
cxx_flags = [] cxx_flags = []
@@ -157,7 +158,8 @@ def install(self, spec, prefix):
'-DTrilinos_ENABLE_CXX11:BOOL=ON', '-DTrilinos_ENABLE_CXX11:BOOL=ON',
'-DTPL_ENABLE_Netcdf:BOOL=ON', '-DTPL_ENABLE_Netcdf:BOOL=ON',
'-DTPL_ENABLE_HYPRE:BOOL=%s' % ( '-DTPL_ENABLE_HYPRE:BOOL=%s' % (
'ON' if '+hypre' in spec else 'OFF') 'ON' if '+hypre' in spec else 'OFF'),
'-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % self.prefix
]) ])
if spec.satisfies('%intel') and spec.satisfies('@12.6.2'): if spec.satisfies('%intel') and spec.satisfies('@12.6.2'):
@@ -206,11 +208,6 @@ def install(self, spec, prefix):
'-DTrilinos_ENABLE_Fortran=ON' '-DTrilinos_ENABLE_Fortran=ON'
]) ])
# for build-debug only:
# options.extend([
# '-DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE'
# ])
# suite-sparse related # suite-sparse related
if '+suite-sparse' in spec: if '+suite-sparse' in spec:
options.extend([ options.extend([
@@ -330,12 +327,10 @@ def install(self, spec, prefix):
options.extend([ options.extend([
'-DTrilinos_ENABLE_FEI=OFF' '-DTrilinos_ENABLE_FEI=OFF'
]) ])
return options
with working_dir('spack-build', create=True): @CMakePackage.sanity_check('install')
cmake('..', *options) def filter_python(self):
make()
make('install')
# When trilinos is built with Python, libpytrilinos is included # When trilinos is built with Python, libpytrilinos is included
# through cmake configure files. Namely, Trilinos_LIBRARIES in # through cmake configure files. Namely, Trilinos_LIBRARIES in
# TrilinosConfig.cmake contains pytrilinos. This leads to a # TrilinosConfig.cmake contains pytrilinos. This leads to a
@@ -343,14 +338,9 @@ def install(self, spec, prefix):
# Trilinos to be used in any C++ code, which links executable # Trilinos to be used in any C++ code, which links executable
# against the libraries listed in Trilinos_LIBRARIES. See # against the libraries listed in Trilinos_LIBRARIES. See
# https://github.com/Homebrew/homebrew-science/issues/2148#issuecomment-103614509 # https://github.com/Homebrew/homebrew-science/issues/2148#issuecomment-103614509
# A workaround it to remove PyTrilinos from the COMPONENTS_LIST : # A workaround is to remove PyTrilinos from the COMPONENTS_LIST :
if '+python' in self.spec: if '+python' in self.spec:
filter_file(r'(SET\(COMPONENTS_LIST.*)(PyTrilinos;)(.*)', filter_file(r'(SET\(COMPONENTS_LIST.*)(PyTrilinos;)(.*)',
(r'\1\3'), (r'\1\3'),
'%s/cmake/Trilinos/TrilinosConfig.cmake' % '%s/cmake/Trilinos/TrilinosConfig.cmake' %
prefix.lib) self.prefix.lib)
# The shared libraries are not installed correctly on Darwin;
# correct this
if (sys.platform == 'darwin') and ('+shared' in spec):
fix_darwin_install_name(prefix.lib)