HDF5: Utilize flag_handler for handling all compiler flags (#23413)
* convert pic and compiler compat flags to flag_handler
This commit is contained in:
parent
28ef63bc1b
commit
fa12ca585a
@ -173,6 +173,22 @@ def url_for_version(self, version):
|
||||
url = "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-{0}/hdf5-{1}/src/hdf5-{1}.tar.gz"
|
||||
return url.format(version.up_to(2), version)
|
||||
|
||||
def flag_handler(self, name, flags):
|
||||
if '+pic' in self.spec:
|
||||
if name == "cflags":
|
||||
flags.append(self.compiler.cc_pic_flag)
|
||||
elif name == "cxxflags":
|
||||
flags.append(self.compiler.cxx_pic_flag)
|
||||
elif name == "fflags":
|
||||
flags.append(elf.compiler.fc_pic_flag)
|
||||
|
||||
# Quiet warnings/errors about implicit declaration of functions in C99
|
||||
if name == "cflags":
|
||||
if "clang" in self.compiler.cc or "gcc" in self.compiler.cc:
|
||||
flags.append("-Wno-implicit-function-declaration")
|
||||
|
||||
return (None, None, flags)
|
||||
|
||||
@when('@develop')
|
||||
def autoreconf(self, spec, prefix):
|
||||
autogen = Executable('./autogen.sh')
|
||||
@ -317,27 +333,6 @@ def configure_args(self):
|
||||
if '+fortran' in self.spec:
|
||||
extra_args.append('FC=%s' % self.spec['mpi'].mpifc)
|
||||
|
||||
# Append package specific compiler flags to the global ones
|
||||
cflags = ' '.join(self.spec.compiler_flags['cflags'])
|
||||
cxxflags = ' '.join(self.spec.compiler_flags['cxxflags'])
|
||||
fflags = ' '.join(self.spec.compiler_flags['fflags'])
|
||||
|
||||
if '+pic' in self.spec:
|
||||
cflags += " " + self.compiler.cc_pic_flag
|
||||
cxxflags += " " + self.compiler.cxx_pic_flag
|
||||
fflags += " " + self.compiler.fc_pic_flag
|
||||
|
||||
# Quiet warnings/errors about implicit declaration of functions in C99
|
||||
if "clang" in self.compiler.cc or "gcc" in self.compiler.cc:
|
||||
cflags += " -Wno-implicit-function-declaration"
|
||||
|
||||
if cflags:
|
||||
extra_args.append('CFLAGS={0}'.format(cflags))
|
||||
if cxxflags and '+cxx' in self.spec:
|
||||
extra_args.append('CXXFLAGS={0}'.format(cxxflags))
|
||||
if fflags and '+fortran' in self.spec:
|
||||
extra_args.append('FCFLAGS={0}'.format(fflags))
|
||||
|
||||
return extra_args
|
||||
|
||||
@run_after('configure')
|
||||
|
Loading…
Reference in New Issue
Block a user