From 7ebcb83ac3c604396bf25cab42cf31c102993364 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 7 Feb 2021 02:32:01 -0800 Subject: [PATCH] scons: Simplify the check for hdf5 support. Collapse the check_hdf5 to the only place it was called, to set a simple flag variable. Pull the invariant have_pkg_config check out of check_hdf5_pkg, since if we don't have pkg-config there's no reason to even try to use to set up hdf5. Turn the one-off, non-standard "Warning" print into an actual warning(). Change-Id: I04793ae862aeaf1605467d205837b9dd744f93cb Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40865 Tested-by: kokoro Maintainer: Gabe Black Reviewed-by: Andreas Sandberg --- SConstruct | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/SConstruct b/SConstruct index a3c330f69..9e3af3768 100755 --- a/SConstruct +++ b/SConstruct @@ -724,42 +724,35 @@ def is_isa_kvm_compatible(isa): main['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember( 'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host') -def check_hdf5(): - return \ - conf.CheckLibWithHeader('hdf5', 'hdf5.h', 'C', - 'H5Fcreate("", 0, 0, 0);') and \ - conf.CheckLibWithHeader('hdf5_cpp', 'H5Cpp.h', 'C++', - 'H5::H5File("", 0);') - def check_hdf5_pkg(name): print("Checking for %s using pkg-config..." % name, end="") - if not have_pkg_config: - print(" pkg-config not found") - return False - try: main.ParseConfig('pkg-config --cflags-only-I --libs-only-L %s' % name) - print(" yes") - return True except: print(" no") return False + print(" yes") + return True # Check if there is a pkg-config configuration for hdf5. If we find # it, setup the environment to enable linking and header inclusion. We # don't actually try to include any headers or link with hdf5 at this # stage. -if not check_hdf5_pkg('hdf5-serial'): - check_hdf5_pkg('hdf5') +if have_pkg_config: + if not check_hdf5_pkg('hdf5-serial'): + check_hdf5_pkg('hdf5') # Check if the HDF5 libraries can be found. This check respects the # include path and library path provided by pkg-config. We perform # this check even if there isn't a pkg-config configuration for hdf5 # since some installations don't use pkg-config. -have_hdf5 = check_hdf5() +have_hdf5 = \ + conf.CheckLibWithHeader('hdf5', 'hdf5.h', 'C', + 'H5Fcreate("", 0, 0, 0);') and \ + conf.CheckLibWithHeader('hdf5_cpp', 'H5Cpp.h', 'C++', + 'H5::H5File("", 0);') if not have_hdf5: - print("Warning: Couldn't find any HDF5 C++ libraries. Disabling") - print(" HDF5 support.") + warning("Couldn't find any HDF5 C++ libraries. Disabling HDF5 support.") ###################################################################### # -- 2.30.2