From 14acfb65c4c045b8db4252fe98c13a47ccba42b5 Mon Sep 17 00:00:00 2001
From: Dustin Lagoy <dustin.lagoy@gmail.com>
Date: Mon, 25 Mar 2019 18:22:15 -0700
Subject: [PATCH] netcdf-cxx package: Add optional netCDF4 support (#10899)

---
 .../repos/builtin/packages/netcdf-cxx/package.py      | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/var/spack/repos/builtin/packages/netcdf-cxx/package.py b/var/spack/repos/builtin/packages/netcdf-cxx/package.py
index d45ef4bf2b..10353df52c 100644
--- a/var/spack/repos/builtin/packages/netcdf-cxx/package.py
+++ b/var/spack/repos/builtin/packages/netcdf-cxx/package.py
@@ -19,9 +19,20 @@ class NetcdfCxx(AutotoolsPackage):
 
     depends_on('netcdf')
 
+    variant(
+        'netcdf4', default=True, description='Compile with netCDF4 support')
+
     @property
     def libs(self):
         shared = True
         return find_libraries(
             'libnetcdf_c++', root=self.prefix, shared=shared, recursive=True
         )
+
+    def configure_args(self):
+        args = []
+        if '+netcdf4' in self.spec:
+            # There is no clear way to set this via configure, so set the flag
+            # explicitly
+            args.append('CPPFLAGS=-DUSE_NETCDF4')
+        return args
-- 
GitLab