diff --git a/var/spack/repos/builtin/packages/netcdf-c/package.py b/var/spack/repos/builtin/packages/netcdf-c/package.py index 82d7d6792c..8753edb6e3 100644 --- a/var/spack/repos/builtin/packages/netcdf-c/package.py +++ b/var/spack/repos/builtin/packages/netcdf-c/package.py @@ -367,9 +367,9 @@ def patch_hdf5_pkgconfigcmake(self): settingsconfig_file = find(self.prefix, "libnetcdf.settings", recursive=True) files = pkgconfig_file + cmakeconfig_file + ncconfig_file + settingsconfig_file - - filter_file("hdf5-shared", "hdf5", *files, ignore_absent=True) - filter_file("hdf5_hl-shared", "hdf5_hl", *files, ignore_absent=True) + config = "shared" if self.spec.satisfies("+shared") else "static" + filter_file(f"hdf5-{config}", "hdf5", *files, ignore_absent=True) + filter_file(f"hdf5_hl-{config}", "hdf5_hl", *files, ignore_absent=True) class AutotoolsBuilder(BaseBuilder, autotools.AutotoolsBuilder):