From 81b2918c85e81aa23f017ce20f0f8ab0fa90f259 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <gruenich@dune-project.org>
Date: Sun, 11 Jan 2015 19:17:55 +0100
Subject: [PATCH] eigenvaluetest handles LAPACK dependency

If LAPACK is not available, it return 77 indicating skipped test
---
 dune/common/test/CMakeLists.txt     | 5 ++---
 dune/common/test/eigenvaluestest.cc | 7 +++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/dune/common/test/CMakeLists.txt b/dune/common/test/CMakeLists.txt
index 794bb8c31..5837f73fd 100644
--- a/dune/common/test/CMakeLists.txt
+++ b/dune/common/test/CMakeLists.txt
@@ -79,9 +79,7 @@ add_executable("dynvectortest" dynvectortest.cc)
 
 add_executable("eigenvaluestest" eigenvaluestest.cc)
 target_link_libraries(eigenvaluestest dunecommon)
-if(LAPACK_FOUND)
-  target_link_libraries(eigenvaluestest ${LAPACK_LIBRARIES})
-endif(LAPACK_FOUND)
+target_link_libraries(eigenvaluestest ${LAPACK_LIBRARIES})
 
 add_executable("diagonalmatrixtest" diagonalmatrixtest.cc)
 target_link_libraries("diagonalmatrixtest" "dunecommon")
@@ -172,6 +170,7 @@ endforeach(_TEST)
 
 # treat tests returning code 77 as skipped
 set_tests_properties(
+  eigenvaluestest
   mpicollectivecommunication
   PROPERTIES SKIP_RETURN_CODE 77)
 
diff --git a/dune/common/test/eigenvaluestest.cc b/dune/common/test/eigenvaluestest.cc
index cdd428df9..80af66f13 100644
--- a/dune/common/test/eigenvaluestest.cc
+++ b/dune/common/test/eigenvaluestest.cc
@@ -14,6 +14,7 @@
 
 using namespace Dune;
 
+#if HAVE_LAPACK
 /** \brief Test the eigenvalue code with the Rosser test matrix
 
    This matrix was a challenge for many matrix eigenvalue
@@ -124,14 +125,20 @@ void testSymmetricFieldMatrix()
         DUNE_THROW(MathError, "Values computed by FMatrixHelp::eigenValues are not in ascending order");
   }
 }
+#endif // HAVE_LAPACK
 
 int main() try
 {
+#if HAVE_LAPACK
   testRosserMatrix<double>();
 
   testSymmetricFieldMatrix<double>();
 
   return 0;
+#else
+  std::cout << "WARNING: eigenvaluetest needs LAPACK, test disabled" << std::endl;
+  return 77;
+#endif // HAVE_LAPACK
 } catch (Exception exception)
 {
   std::cerr << exception << std::endl;
-- 
GitLab