1import config.package 2 3class Configure(config.package.CMakePackage): 4 def __init__(self, framework): 5 config.package.CMakePackage.__init__(self, framework) 6 self.versionname = 'METIS_VER_MAJOR.METIS_VER_MINOR.METIS_VER_SUBMINOR' 7 self.gitcommit = 'v5.1.0-p12' 8 self.download = ['git://https://bitbucket.org/petsc/pkg-metis.git','https://bitbucket.org/petsc/pkg-metis/get/'+self.gitcommit+'.tar.gz'] 9 self.downloaddirnames = ['petsc-pkg-metis'] 10 self.functions = ['METIS_PartGraphKway'] 11 self.includes = ['metis.h'] 12 self.liblist = [['libmetis.a'],['libmetis.a','libexecinfo.a']] 13 self.hastests = 1 14 self.useddirectly = 0 15 self.downloadonWindows = 1 16 self.need35policy = True 17 return 18 19 def setupHelp(self, help): 20 config.package.CMakePackage.setupHelp(self,help) 21 import nargs 22 help.addArgument('METIS', '-download-metis-use-doubleprecision=<bool>', nargs.ArgBool(None, 0, 'enable METIS_USE_DOUBLEPRECISION')) 23 return 24 25 def setupDependencies(self, framework): 26 config.package.CMakePackage.setupDependencies(self, framework) 27 self.compilerFlags = framework.require('config.compilerFlags', self) 28 self.mathlib = framework.require('config.packages.mathlib', self) 29 self.deps = [self.mathlib] 30 return 31 32 def formCMakeConfigureArgs(self): 33 args = config.package.CMakePackage.formCMakeConfigureArgs(self) 34 args.append('-DGKLIB_PATH=../GKlib') 35 # force metis/parmetis to use a portable random number generator that will produce the same partitioning results on all systems 36 args.append('-DGKRAND=1') 37 if not config.setCompilers.Configure.isWindows(self.setCompilers.CC, self.log) and self.checkSharedLibrariesEnabled(): 38 args.append('-DSHARED=1') 39 if self.compilerFlags.debugging: 40 args.append('-DDEBUG=1') 41 if self.getDefaultIndexSize() == 64: 42 args.append('-DMETIS_USE_LONGINDEX=1') 43 if config.setCompilers.Configure.isWindows(self.setCompilers.CC, self.log): 44 args.append('-DMSVC=1') 45 if self.framework.argDB['download-metis-use-doubleprecision']: 46 args.append('-DMETIS_USE_DOUBLEPRECISION=1') 47 args.append('-DMATH_LIB="'+self.libraries.toStringNoDupes(self.mathlib.lib)+'"') 48 return args 49 50 def configureLibrary(self): 51 config.package.Package.configureLibrary(self) 52 oldFlags = self.compilers.CPPFLAGS 53 self.compilers.CPPFLAGS += ' '+self.headers.toString(self.include) 54 if not self.checkCompile('#include "metis.h"', '#if (IDXTYPEWIDTH != '+ str(self.getDefaultIndexSize())+')\n#error incompatible IDXTYPEWIDTH\n#endif\n'): 55 if self.defaultIndexSize == 64: 56 msg= '--with-64-bit-indices option requires a metis build with IDXTYPEWIDTH=64.\n' 57 else: 58 msg= 'IDXTYPEWIDTH=64 metis build appears to be specified for a default 32-bit-indices build of PETSc.\n' 59 raise RuntimeError('Metis specified is incompatible!\n'+msg+'Suggest using --download-metis for a compatible metis') 60 61 self.compilers.CPPFLAGS = oldFlags 62 return 63