From 48ae4c22b24d04ed4004dababde53d37c931adf7 Mon Sep 17 00:00:00 2001
From: Geoffrey Malcolm Oxberry <goxberry@gmail.com>
Date: Tue, 16 Jan 2018 03:29:00 -0800
Subject: [PATCH] vtk@:6.1.0 : fix NetCDF C++ bindings detection

VTK 6.1.0 and earlier do not use paths stored in `NETCDF_CXX_ROOT` to
detect the presence of NetCDF C++ headers and libraries. Consequently,
VTK 6.1.0 does not build.

This commit fixes this bug by setting the advanced variables
`NETCDF_CXX_INCLUDE_DIR` and `NETCDF_CXX_LIBRARY` at the command line
to specify the directory containing headers and the full library path
for the NetCDF C++ bindings.
---
 var/spack/repos/builtin/packages/vtk/package.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/var/spack/repos/builtin/packages/vtk/package.py b/var/spack/repos/builtin/packages/vtk/package.py
index f5b95108c9..bce6cc2475 100644
--- a/var/spack/repos/builtin/packages/vtk/package.py
+++ b/var/spack/repos/builtin/packages/vtk/package.py
@@ -103,4 +103,15 @@ def cmake_args(self):
                 '-DCMAKE_CXX_FLAGS=-DGLX_GLXEXT_LEGACY'
             ])
 
+            # VTK 6.1.0 (and possibly earlier) does not use
+            # NETCDF_CXX_ROOT to detect NetCDF C++ bindings, so
+            # NETCDF_CXX_INCLUDE_DIR and NETCDF_CXX_LIBRARY must be
+            # used instead to detect these bindings
+            netcdf_cxx_lib = spec['netcdf-cxx'].libs.joined()
+            cmake_args.extend([
+                '-DNETCDF_CXX_INCLUDE_DIR={0}'.format(
+                    spec['netcdf-cxx'].prefix.include),
+                '-DNETCDF_CXX_LIBRARY={0}'.format(netcdf_cxx_lib),
+            ])
+
         return cmake_args
-- 
GitLab