netcdf-fortran: fix static linking in some cases (#35466)

* netcdf-fortran: enable building against static netcdf-c

* netcdf-fortran: strip the output of nc-config
This commit is contained in:
Sergey Kosukhin 2024-01-29 12:53:13 +01:00 committed by GitHub
parent 9eb445f0a2
commit 594069961a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -40,6 +40,12 @@ class NetcdfFortran(AutotoolsPackage):
depends_on("netcdf-c@4.7.4:", when="@4.5.3:") # nc_def_var_szip required
depends_on("doxygen", when="+doc", type="build")
# We need to use MPI wrappers when building against static MPI-enabled NetCDF and/or HDF5:
with when("^netcdf-c~shared"):
depends_on("mpi", when="^netcdf-c+mpi")
depends_on("mpi", when="^netcdf-c+parallel-netcdf")
depends_on("mpi", when="^hdf5+mpi~shared")
# Enable 'make check' for NAG, which is too strict.
patch("nag_testing.patch", when="@4.4.5%nag")
@ -129,6 +135,12 @@ def configure_args(self):
# configuration failure, we set the following cache variable:
config_args.append("ac_cv_func_MPI_File_open=yes")
if "~shared" in netcdf_c_spec:
nc_config = which("nc-config")
config_args.append("LIBS={0}".format(nc_config("--libs", output=str).strip()))
if any(s in netcdf_c_spec for s in ["+mpi", "+parallel-netcdf", "^hdf5+mpi~shared"]):
config_args.append("CC=%s" % self.spec["mpi"].mpicc)
return config_args
def check(self):