From de71b2828f1813e7cb4b1ae556aee0a78850a3e1 Mon Sep 17 00:00:00 2001
From: Jennifer Green <jgreen@lanl.gov>
Date: Tue, 5 May 2020 12:02:49 -0600
Subject: CMake: Cray XC40 system errors bootstrapping CMake (#16459)

* CMake: fix https://github.com/spack/spack/issues/16453 with a patch addressing both libhugetlbfs and icpc warnings on Cray XC40 systems

* Including CMake v3.17.2 in the patched versions
---
 .../repos/builtin/packages/cmake/ignore_crayxc_warnings.patch | 11 +++++++++++
 var/spack/repos/builtin/packages/cmake/package.py             |  5 +++++
 2 files changed, 16 insertions(+)
 create mode 100644 var/spack/repos/builtin/packages/cmake/ignore_crayxc_warnings.patch

diff --git a/var/spack/repos/builtin/packages/cmake/ignore_crayxc_warnings.patch b/var/spack/repos/builtin/packages/cmake/ignore_crayxc_warnings.patch
new file mode 100644
index 0000000000..85928f0e84
--- /dev/null
+++ b/var/spack/repos/builtin/packages/cmake/ignore_crayxc_warnings.patch
@@ -0,0 +1,11 @@
+diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake
+index fb68ed78c9..c6c1ba667f 100644
+--- a/Source/Checks/cm_cxx_features.cmake
++++ b/Source/Checks/cm_cxx_features.cmake
+@@ -17,2 +17,6 @@ function(cm_check_cxx_feature name)
+     set(check_output "${OUTPUT}")
++    # Filter out libhugetlbfs warnings
++    string(REGEX REPLACE "[^\n]*libhugetlbfs [^\n]*: WARNING[^\n]*" "" check_output "${check_output}")
++    # Filter out icpc warnings
++    string(REGEX REPLACE "[^\n]*icpc: command line warning #10121: overriding [^\n]*" "" check_output "${check_output}")
+     # Filter out MSBuild output that looks like a warning.
diff --git a/var/spack/repos/builtin/packages/cmake/package.py b/var/spack/repos/builtin/packages/cmake/package.py
index 833573bf80..acf5b1fcdc 100644
--- a/var/spack/repos/builtin/packages/cmake/package.py
+++ b/var/spack/repos/builtin/packages/cmake/package.py
@@ -132,6 +132,11 @@ class Cmake(Package):
     # https://gitlab.kitware.com/cmake/cmake/issues/18232
     patch('nag-response-files.patch', when='@3.7:3.12')
 
+    # Cray libhugetlbfs and icpc warnings failing CXX tests
+    # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4698
+    # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4681
+    patch('ignore_crayxc_warnings.patch', when='@3.7:3.17.2')
+
     conflicts('+qt', when='^qt@5.4.0')  # qt-5.4.0 has broken CMake modules
 
     # https://gitlab.kitware.com/cmake/cmake/issues/18166
-- 
cgit v1.2.3-70-g09d2