Skip to content

Commit f40a5c0

Browse files
committed
Optionally use system provided netcdf
Detect a system wide installed netcdf using pkgconfig and use it, in case --enable-netcdf=system is specified. Fixes libMesh#1542.
1 parent 32b495d commit f40a5c0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

m4/libmesh_optional_packages.m4

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,15 @@ AM_CONDITIONAL(LIBMESH_ENABLE_HDF5, test x$enablehdf5 = xyes)
720720
# --------------------------------------------------------------
721721
CONFIGURE_NETCDF
722722
AS_IF([test $enablenetcdf = yes],
723-
[libmesh_contrib_INCLUDES="$NETCDF_INCLUDE $libmesh_contrib_INCLUDES"])
723+
[
724+
AS_IF([test x$netcdfversion = xsystem],
725+
[
726+
libmesh_optional_INCLUDES="$NETCDF_CFLAGS $libmesh_optional_INCLUDES"
727+
libmesh_optional_LIBS="$NETCDF_LIBS $libmesh_optional_LIBS"
728+
],
729+
[
730+
libmesh_contrib_INCLUDES="$NETCDF_INCLUDE $libmesh_contrib_INCLUDES"])
731+
])
724732
725733
AM_CONDITIONAL(LIBMESH_ENABLE_NETCDF, test x$enablenetcdf = xyes)
726734
AM_CONDITIONAL(LIBMESH_ENABLE_NETCDF_V4, test x$netcdfversion = x4)

m4/netcdf.m4

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ AC_DEFUN([CONFIGURE_NETCDF],
77
AS_HELP_STRING([--disable-netcdf],
88
[build without netCDF binary I/O]),
99
[AS_CASE("${enableval}",
10+
[system], [enablenetcdf=yes
11+
netcdfversion=system],
1012
[yes|new|v4], [enablenetcdf=yes
1113
netcdfversion=4],
1214
[old|v3], [enablenetcdf=yes
@@ -27,6 +29,8 @@ AC_DEFUN([CONFIGURE_NETCDF],
2729
])
2830
2931
AS_CASE("${netcdfversion}",
32+
[system], [PKG_CHECK_MODULES([NETCDF], [netcdf >= 4.2])],
33+
3034
[3], [
3135
dnl We shouldn't get here, see if test above.
3236
AC_MSG_ERROR([>>> Error: netCDF3 is no longer distributed with libMesh <<<])

0 commit comments

Comments
 (0)