From 229ed5c22861c4a5ccd8d7b09db9e005bb9f9c59 Mon Sep 17 00:00:00 2001
From: Dustin Lagoy <dustin.lagoy@gmail.com>
Date: Tue, 2 Apr 2019 17:04:09 -0700
Subject: [PATCH] netcdf-cxx package: set ldflags for hdf5 and netcdf (#11026)

Ensure that netcdf-cxx uses the Spack-installed hdf5 and netcdf4
rather than system-installed versions.
---
 var/spack/repos/builtin/packages/netcdf-cxx/package.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/var/spack/repos/builtin/packages/netcdf-cxx/package.py b/var/spack/repos/builtin/packages/netcdf-cxx/package.py
index 10353df52c..3d610eb7ca 100644
--- a/var/spack/repos/builtin/packages/netcdf-cxx/package.py
+++ b/var/spack/repos/builtin/packages/netcdf-cxx/package.py
@@ -35,4 +35,11 @@ def configure_args(self):
             # There is no clear way to set this via configure, so set the flag
             # explicitly
             args.append('CPPFLAGS=-DUSE_NETCDF4')
+        # Add these to LDFLAGS explicitly, so the linker doesn't accidentally
+        # use system versions
+        ldflags = [
+            self.spec['netcdf'].libs.search_flags,
+            self.spec['hdf5'].libs.search_flags,
+        ]
+        args.append('LDFLAGS=' + ' '.join(ldflags))
         return args
-- 
GitLab