From 0aaad2ece8289b0ad9d0b3bd0ad59f30aa542b3d Mon Sep 17 00:00:00 2001
From: Christoph Grueninger <christoph.grueninger@iws.uni-stuttgart.de>
Date: Wed, 15 Feb 2012 18:19:33 +0000
Subject: [PATCH] Fixed CMake support for UG, Alberta and ALUGrid. Imporved
 output of DumuxMacros. Small cosmetic changes in FindSuperLU.cmake.

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7793 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 CMakeLists.txt                  | 62 ++++++++++++++-------------------
 cmake/Modules/DumuxMacros.cmake | 34 ++++++++++++------
 cmake/Modules/FindSuperLU.cmake |  6 ++--
 cmake/Modules/FindUG.cmake      |  4 +--
 4 files changed, 55 insertions(+), 51 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff2f7b3f52..41629d948e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -263,7 +263,7 @@ SetConfigHVar(HAVE_DUNE                DUNE_common_FOUND)
 SetConfigHVar(HAVE_DUNE_GRID           DUNE_grid_FOUND)
 SetConfigHVar(HAVE_DUNE_ISTL           DUNE_istl_FOUND)
 SetConfigHVar(HAVE_DUNE_LOCALFUNCTIONS DUNE_localfunctions_FOUND)
-#SetConfigHVar(HAVE_DUNE_PDELAB         DUNE_pdelab_FOUND)
+SetConfigHVar(HAVE_DUNE_PDELAB         DUNE_pdelab_FOUND)
 SetConfigHVar(HAVE_MPI                 MPI_FOUND)
 SetConfigHVar(HAVE_SUPERLU             SUPERLU_FOUND)
 SetConfigHVar(PROJECT_NAME             ProjectName)
@@ -276,53 +276,43 @@ SetConfigHVar(PROJECT_MAINTAINER_EMAIL ProjectMaintainerEmail)
 # adapt build system to detected packages
 
 # deal with UG
-#if (UG_FOUND)
-#  set(DumuxLinkLibraries ${DumuxLinkLibraries} 
-#      ${UG_LIBRARIES})
-#  set(DumuxIncludeDirectories ${DumuxIncludeDirectories} 
-#      ${UG_INCLUDE_DIRS})
-#endif(UG_FOUND)
-#SetConfigHVar(HAVE_UG UG_FOUND)
+if(UG_FOUND)
+  set(DumuxIncludeDirectories ${DumuxIncludeDirectories} ${UG_INCLUDE_DIRS})
+  set(DumuxLinkLibraries ${DumuxLinkLibraries} ${UG_LIBRARIES})
+endif(UG_FOUND)
+SetConfigHVar(HAVE_UG UG_FOUND)
 
 # deal with ALUGrid
-#if (ALUGrid_FOUND)
-#  set(DumuxLinkLibraries ${DumuxLinkLibraries} 
-#      ${ALUGrid_LIBRARIES})
-#  set(DumuxIncludeDirectories ${DumuxIncludeDirectories} 
-#      ${ALUGrid_INCLUDE_DIRS})
-#endif(ALUGrid_FOUND)
-#SetConfigHVar(HAVE_ALUGRID ALUGrid_FOUND)
-
-# deal with METIS
-#if (METIS_FOUND)
-#  set(DumuxLinkLibraries ${DumuxLinkLibraries} 
-#      ${METIS_LIBRARIES})
-#  set(DumuxIncludeDirectories ${DumuxIncludeDirectories} 
-#      ${METIS_INCLUDE_DIRS})
-#endif(METIS_FOUND)
-#SetConfigHVar(HAVE_METIS METIS_FOUND)
+if(ALUGrid_FOUND)
+  set(DumuxIncludeDirectories ${DumuxIncludeDirectories} ${ALUGrid_INCLUDE_DIRS})
+  set(DumuxLinkLibraries ${DumuxLinkLibraries} ${ALUGrid_LIBRARIES})
+endif(ALUGrid_FOUND)
+SetConfigHVar(HAVE_ALUGRID ALUGrid_FOUND)
 
 # deal with Alberta
-#if (Alberta_FOUND)
-#  set(DumuxLinkLibraries ${DumuxLinkLibraries} 
-#      ${Alberta_LIBRARIES})
-#  set(DumuxIncludeDirectories ${DumuxIncludeDirectories} 
-#      ${Alberta_INCLUDE_DIRS})
-#endif(Alberta_FOUND)
-#SetConfigHVar(HAVE_ALBERTA Alberta_FOUND)
+if(Alberta_FOUND)
+ set(DumuxIncludeDirectories ${DumuxIncludeDirectories} ${Alberta_INCLUDE_DIRS})
+ set(DumuxLinkLibraries ${DumuxLinkLibraries} ${Alberta_LIBRARIES})
+endif(Alberta_FOUND)
+SetConfigHVar(HAVE_ALBERTA Alberta_FOUND)
+
+# deal with METIS
+if(METIS_FOUND)
+ set(DumuxIncludeDirectories ${DumuxIncludeDirectories} ${METIS_INCLUDE_DIRS})
+ set(DumuxLinkLibraries ${DumuxLinkLibraries} ${METIS_LIBRARIES})
+endif(METIS_FOUND)
+SetConfigHVar(HAVE_METIS METIS_FOUND)
 ##############
 
-if (MPI_FOUND)
+if(MPI_FOUND)
    set(TMP ${MPI_COMPILE_FLAGS})
    separate_arguments(TMP)
    add_definitions(${TMP})
    add_definitions(-DENABLE_MPI=1)
-#   add_definitions(-DModelP) # tell UG that the model is parallelized
-
+# add_definitions(-DModelP) # tell UG that the model is parallelized
    set(DumuxLinkLibraries ${DumuxLinkLibraries} ${MPI_LIBRARIES})
    set(DumuxIncludeDirectories ${DumuxIncludeDirectories} ${MPI_INCLUDE_PATH})
-
-endif (MPI_FOUND)
+endif(MPI_FOUND)
 
 # actually write the config.h file to disk 
 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
diff --git a/cmake/Modules/DumuxMacros.cmake b/cmake/Modules/DumuxMacros.cmake
index 589878cb22..77596d9dd1 100644
--- a/cmake/Modules/DumuxMacros.cmake
+++ b/cmake/Modules/DumuxMacros.cmake
@@ -34,10 +34,10 @@ the ${DumuxFramework}_DIR entry where all ${DumuxFramework} sub-modules have bee
   # Path to look for includes (->DumuxIncludePath) and libraries (-> DumuxLibraryPath)
   foreach(tmp ${DumuxModulePath})
     list(APPEND DumuxIncludePath "${tmp}" "${tmp}/include")
-    list(APPEND DumuxLibraryPath "${tmp}" "${tmp}/lib")
+    list(APPEND DumuxLibraryPath "${tmp}" "${tmp}/lib" "${tmp}/lib64")
   endforeach(tmp)
   list(APPEND DumuxIncludePath "/usr/include" "/usr/local/include")
-  list(APPEND DumuxLibraryPath "/usr/lib" "/usr/local/lib")
+  list(APPEND DumuxLibraryPath "/usr/lib" "/usr/lib64" "/usr/local/lib" "/usr/local/lib64")
 
   set(DumuxLibraries)
   set(DumuxFailedLibraries)
@@ -163,21 +163,35 @@ macro(DumuxCheckFound)
 
   if(DumuxLibsFound AND ${DumuxModule}_INCLUDE_DIR)
     set(DumuxFound 1)
+    # log result
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+      "Determing location of ${DumuxModule} succeded:\n"
+      "Include directory: ${${DumuxModule}_INCLUDE_DIR}\n"
+      "Library directory: ${DumuxLibraries}\n\n")
+  else()
+    # log errornous result
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+      "Determing location of ${DumuxModule} failed:\n"
+      "Include directory: ${${DumuxModule}_INCLUDE_DIR}\n"
+      "Library directory: ${DumuxLibraries}\n\n")
   endif(DumuxLibsFound AND ${DumuxModule}_INCLUDE_DIR)
   set(${DumuxModule}_FOUND ${DumuxFound})
   set(${DumuxModule}_LIBRARIES ${DumuxLibraries})
 
   # print status message if requested
-  if(NOT ${DumuxModule}_FIND_QUIETLY AND DumuxFound)
-    message(STATUS "Found ${DumuxModule}")
-  endif(NOT ${DumuxModule}_FIND_QUIETLY AND DumuxFound)
+  if(NOT ${DumuxModule}_FIND_QUIETLY)
+    if(DumuxFound)
+      message(STATUS "Found ${DumuxModule}")
+    else()
+      message(STATUS "Could not find ${DumuxModule}")
+    endif(DumuxFound)
+  endif(NOT ${DumuxModule}_FIND_QUIETLY)
 
   if(NOT DumuxFound AND ${DumuxModule}_FIND_REQUIRED)
-    if (DumuxLibsFound)
+    if(DumuxLibsFound)
       message(FATAL_ERROR "${DumuxPathMessage}")
-    else (DumuxLibsFound)
-      message(FATAL_ERROR "${DumuxPathMessage}
-${DumuxFailedLibsMessage}")
-    endif( DumuxLibsFound)
+    else(DumuxLibsFound)
+      message(FATAL_ERROR "${DumuxPathMessage} ${DumuxFailedLibsMessage}")
+    endif(DumuxLibsFound)
   endif(NOT DumuxFound AND ${DumuxModule}_FIND_REQUIRED)
 endmacro(DumuxCheckFound)
diff --git a/cmake/Modules/FindSuperLU.cmake b/cmake/Modules/FindSuperLU.cmake
index c329e2beef..7661138038 100644
--- a/cmake/Modules/FindSuperLU.cmake
+++ b/cmake/Modules/FindSuperLU.cmake
@@ -4,8 +4,6 @@ if(NOT BLAS_FOUND)
   return()
 endif(NOT BLAS_FOUND)
 
-include(FindPackageHandleStandardArgs)
-
 # look for header files
 find_path(SUPERLU_INCLUDE_DIR
   NAMES supermatrix.h
@@ -19,7 +17,9 @@ find_library(SUPERLU_LIBRARY
 )
 
 # behave like a CMake module is supposed to behave
-find_package_handle_standard_args(SUPERLU
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+  "SuperLU"
   DEFAULT_MSG
   SUPERLU_INCLUDE_DIR
   SUPERLU_LIBRARY
diff --git a/cmake/Modules/FindUG.cmake b/cmake/Modules/FindUG.cmake
index e964a4a8b1..544845c443 100644
--- a/cmake/Modules/FindUG.cmake
+++ b/cmake/Modules/FindUG.cmake
@@ -11,7 +11,8 @@ DumuxSetup("UG" "UG" "UG")
 
 set(MyIncludeSuffixes 
     "gm"
-    "np")
+    "np"
+    "include/ug")
 set(MyLibSuffixes 
     "np" 
     "np/field"
@@ -49,7 +50,6 @@ set(MyUgLibs
 DumuxAddPathSuffixes("${MyIncludeSuffixes}" "${MyLibSuffixes}" )
 
 DumuxFindIncludeDir("ugm.h")
-DumuxFindExtraIncludeDir("GM_H" "gm.h")
 
 foreach(tmp ${MyUgLibs})
   DumuxFindLibrary(${tmp})
-- 
GitLab