From 23c83bc31ea71839fe0f8329013732551e4dcfd8 Mon Sep 17 00:00:00 2001
From: Christoph Grueninger <christoph.grueninger@iws.uni-stuttgart.de>
Date: Mon, 6 Feb 2012 18:14:12 +0000
Subject: [PATCH] Added test for dune-geometry to stay compatible with dune
 2.2-svn. dune-PDELab and dune-geometry are now optional dependencies. Added
 stokes modes to testing though they fail.

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7642 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 CMakeLists.txt                          | 17 ++++++++++++++---
 cmake/Modules/FindDUNE_geometry.cmake   | 17 +++++++++++++++++
 cmake/Modules/FindSuperLU.cmake         |  2 +-
 test/freeflow/CMakeLists.txt            |  6 +++---
 test/freeflow/stokes/CMakeLists.txt     |  4 ++--
 test/freeflow/stokes2c/CMakeLists.txt   |  1 +
 test/freeflow/stokes2cni/CMakeLists.txt |  1 +
 7 files changed, 39 insertions(+), 9 deletions(-)
 create mode 100644 cmake/Modules/FindDUNE_geometry.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c67d3fc71e..69182d370e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,11 +27,12 @@ endif(COMMAND cmake_policy)
 find_package(DUNE_grid REQUIRED)
 find_package(DUNE_istl REQUIRED)
 find_package(DUNE_localfunctions REQUIRED)
-#find_package(DUNE_pdelab REQUIRED)
 find_package(DUNE_common REQUIRED)
 
 ##############
 # Find the optional packages
+find_package(DUNE_geometry)
+find_package(DUNE_pdelab)
 find_package(MPI)
 find_package(Boost)
 find_package(Alberta)
@@ -42,6 +43,7 @@ find_package(SuperLU)
 if(SUPERLU_FOUND)
   set(SUPERLU_CPPFLAGS "-I${SUPERLU_INCLUDE_DIRS} -DENABLE_SUPERLU")
   set(SUPERLU_LIBS "-L${SUPERLU_LIBRARIES} -lsuperlu -L${BLAS_LIBRARIES} -lblas")
+  #set(SUPERLU_LIBS "${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}")
   #define HAVE_MEM_USAGE_T_EXPANSIONS 1
 endif(SUPERLU_FOUND)
 
@@ -214,10 +216,12 @@ CHECK_CXX_SOURCE_COMPILES("
 # -> for TARGET_LINK_LIBRARIES
 set(DumuxLinkLibraries 
 #    "dumux" # the DUMUX library. CMake replaces this by the proper file location
-    ${DUNE_grid_LIBRARIES}
     ${DUNE_common_LIBRARIES}
+    ${DUNE_geometry_LIBRARIES}
+    ${DUNE_grid_LIBRARIES}
     ${DUNE_mux_LIBRARIES}
-    ${Boost_LIBRARIES})
+    ${Boost_LIBRARIES}
+    "-lm")
 
 # -> for LINK_DIRECTORIES
 set(DumuxLinkDirectories ${Boost_LIBRARY_DIRS})
@@ -227,6 +231,7 @@ set(DumuxIncludeDirectories
     ${CMAKE_CURRENT_BINARY_DIR}
     ${CMAKE_SOURCE_DIR}
     ${DUNE_grid_INCLUDE_DIRS}
+    ${DUNE_geometry_INCLUDE_DIRS}
     ${DUNE_common_INCLUDE_DIRS}
     ${DUNE_istl_INCLUDE_DIRS}
     ${DUNE_localfunctions_INCLUDE_DIRS}
@@ -381,3 +386,9 @@ add_test(test_dec2p2c bin/runTest.sh test/decoupled/2p2c/test_dec2p2c-reference.
 
 add_test(tutorial_coupled tutorial/tutorial_coupled 1 1)
 add_test(tutorial_decoupled tutorial/tutorial_decoupled 1)
+
+if(SUPERLU_FOUND AND DUNE_pdelab_FOUND)
+  add_test(test_stokes test/freeflow/stokes/test_stokes)
+  add_test(test_stokes2c test/freeflow/stokes2c/test_stokes2c)
+  add_test(test_stokes2cni test/freeflow/stokes2cni/test_stokes2cni)
+endif(SUPERLU_FOUND AND DUNE_pdelab_FOUND)
diff --git a/cmake/Modules/FindDUNE_geometry.cmake b/cmake/Modules/FindDUNE_geometry.cmake
new file mode 100644
index 0000000000..fab1164f98
--- /dev/null
+++ b/cmake/Modules/FindDUNE_geometry.cmake
@@ -0,0 +1,17 @@
+# -*-cmake-*-
+# - Try to find the DUNE geometry library
+# Once done this will define:
+#  DUNE_geometry_FOUND        - system has dune-geometry
+#  DUNE_geometry_INCLUDE_DIR  - incude paths to use dune-geometry
+#  DUNE_geometry_LIBRARIES    - Link these to use dune-geometry
+INCLUDE(DumuxMacros)
+
+DumuxSetup("DUNE_geometry" "dune-geometry" "DUNE")
+
+DumuxFindIncludeDir("dune/geometry/type.hh")
+
+DumuxRequiredLibsFound()
+DumuxIncludeDirsFound()
+DumuxCheckFound()
+
+
diff --git a/cmake/Modules/FindSuperLU.cmake b/cmake/Modules/FindSuperLU.cmake
index ff10a8a73c..62a5dbdbb9 100644
--- a/cmake/Modules/FindSuperLU.cmake
+++ b/cmake/Modules/FindSuperLU.cmake
@@ -29,8 +29,8 @@ mark_as_advanced(SUPERLU_INCLUDE_DIRS SUPERLU_LIBRARIES)
 
 # if both headers and library are found, store results
 if(SUPERLU_FOUND)
-  set(SUPERLU_LIBRARIES    ${SUPERLU_LIBRARY})
   set(SUPERLU_INCLUDE_DIRS ${SUPERLU_INCLUDE_DIR})
+  set(SUPERLU_LIBRARIES    ${SUPERLU_LIBRARY})
   # log result
   file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
     "Determing location of SuperLU succeded:\n"
diff --git a/test/freeflow/CMakeLists.txt b/test/freeflow/CMakeLists.txt
index 951fe63688..c6ef2f5823 100644
--- a/test/freeflow/CMakeLists.txt
+++ b/test/freeflow/CMakeLists.txt
@@ -1,3 +1,3 @@
-#add_subdirectory("stokes")
-#add_subdirectory("stokes2c")
-#add_subdirectory("stokes2cni")
+add_subdirectory("stokes")
+add_subdirectory("stokes2c")
+add_subdirectory("stokes2cni")
diff --git a/test/freeflow/stokes/CMakeLists.txt b/test/freeflow/stokes/CMakeLists.txt
index b0c42a4bdb..a4b0c8f033 100644
--- a/test/freeflow/stokes/CMakeLists.txt
+++ b/test/freeflow/stokes/CMakeLists.txt
@@ -3,8 +3,8 @@ add_executable("test_stokes" test_stokes.cc)
 target_link_libraries("test_stokes" ${DumuxLinkLibraries})
 set_target_properties("test_stokes"
   PROPERTIES
-  COMPILE_FLAGS ${SUPERLU_CPPFLAGS}
-  LINK_FLAGS ${SUPERLU_LIBS})
+  COMPILE_FLAGS ${SUPERLU_CPPFLAGS})
+target_link_libraries("test_stokes" ${SUPERLU_LIBS})
 
 # add required libraries and includes to the build flags
 link_directories(${DumuxLinkDirectories})
diff --git a/test/freeflow/stokes2c/CMakeLists.txt b/test/freeflow/stokes2c/CMakeLists.txt
index 000d67bc44..5380199e81 100644
--- a/test/freeflow/stokes2c/CMakeLists.txt
+++ b/test/freeflow/stokes2c/CMakeLists.txt
@@ -4,6 +4,7 @@ target_link_libraries("test_stokes2c" ${DumuxLinkLibraries})
 set_target_properties("test_stokes2c"
   PROPERTIES
   COMPILE_FLAGS ${SUPERLU_CPPFLAGS})
+target_link_libraries("test_stokes2c" ${SUPERLU_LIBS})
 
 # add required libraries and includes to the build flags
 link_directories(${DumuxLinkDirectories})
diff --git a/test/freeflow/stokes2cni/CMakeLists.txt b/test/freeflow/stokes2cni/CMakeLists.txt
index b91dac3e99..d0933b5cbd 100644
--- a/test/freeflow/stokes2cni/CMakeLists.txt
+++ b/test/freeflow/stokes2cni/CMakeLists.txt
@@ -4,6 +4,7 @@ target_link_libraries("test_stokes2cni" ${DumuxLinkLibraries})
 set_target_properties("test_stokes2cni"
   PROPERTIES
   COMPILE_FLAGS ${SUPERLU_CPPFLAGS})
+target_link_libraries("test_stokes2cni" ${SUPERLU_LIBS})
 
 # add required libraries and includes to the build flags
 link_directories(${DumuxLinkDirectories})
-- 
GitLab