From a6e2dd639fab7af1f1e5d8c7bff6c06e2ea65f21 Mon Sep 17 00:00:00 2001
From: Felix Geyer <fgeyer@debian.org>
Date: Wed, 29 Apr 2015 22:33:01 +0200
Subject: [PATCH] Add protect-tests-from-makeflags.patch, cherry-picked from
 upstream.

* Add protect-tests-from-makeflags.patch, cherry-picked from upstream.
  - Fixes running the test suite in parallel from dh_auto_test.
---
 debian/changelog                              |  2 ++
 .../protect-tests-from-makeflags.patch        | 21 +++++++++++++++++++
 debian/patches/series                         |  1 +
 3 files changed, 24 insertions(+)
 create mode 100644 debian/patches/protect-tests-from-makeflags.patch

diff --git a/debian/changelog b/debian/changelog
index db699e712..d15777b70 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,8 @@ cmake (3.2.2-1) UNRELEASED; urgency=low
 
   [ Felix Geyer ]
   * Build cmake-qt-gui against Qt 5 again.
+  * Add protect-tests-from-makeflags.patch, cherry-picked from upstream.
+    - Fixes running the test suite in parallel from dh_auto_test.
 
  -- Mario Lang <mlang@debian.org>  Mon, 27 Apr 2015 22:31:13 +0200
 
diff --git a/debian/patches/protect-tests-from-makeflags.patch b/debian/patches/protect-tests-from-makeflags.patch
new file mode 100644
index 000000000..355a14119
--- /dev/null
+++ b/debian/patches/protect-tests-from-makeflags.patch
@@ -0,0 +1,21 @@
+From 703e76252930429ac39d3ebf456e3e1e688d1982 Mon Sep 17 00:00:00 2001
+From: Brad King <brad.king@kitware.com>
+Date: Wed, 29 Apr 2015 16:13:50 -0400
+Subject: [PATCH] Tests: Protect RunCMake tests from MAKEFLAGS in environment
+ (#15542)
+
+---
+ Tests/RunCMake/RunCMake.cmake |    3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
+index b24ae0b..70c0d6c 100644
+--- a/Tests/RunCMake/RunCMake.cmake
++++ b/Tests/RunCMake/RunCMake.cmake
+@@ -135,3 +135,6 @@ function(run_cmake_command test)
+   set(RunCMake_TEST_COMMAND "${ARGN}")
+   run_cmake(${test})
+ endfunction()
++
++# Protect RunCMake tests from calling environment.
++unset(ENV{MAKEFLAGS})
diff --git a/debian/patches/series b/debian/patches/series
index 8c1823de9..ad02e6871 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@ fix-ftbfs-on-kfreebsd.patch
 FindJNI.cmake.mips.patch
 fix-hdf5-hl.patch
 cpack-doc-typo.patch
+protect-tests-from-makeflags.patch