]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Bugfix: Search for petsc correctly.
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 24 Sep 2012 15:56:08 +0000 (15:56 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 24 Sep 2012 15:56:08 +0000 (15:56 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26670 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/configure/configure_petsc.cmake
deal.II/cmake/modules/FindPETSC.cmake

index a4ac1105810a22fdb9b2df356afe8549f53e0e18..a6eb563494e0d1f38e72a527817c6b50438cefca 100644 (file)
@@ -27,20 +27,21 @@ MACRO(FEATURE_PETSC_FIND_EXTERNAL var)
     # Petsc has to be configured with the same MPI configuration as
     # deal.II.
     #
-    # petscconf.h should export PETSC_HAVE_MPI 1 if mpi support is enabled.
+    # petscconf.h should export PETSC_HAVE_MPIUNI 1 in case  mpi support is
+    # _NOT_ enabled.
     # So we check for this:
     #
-    FILE(STRINGS "${PETSC_INCLUDE_DIR}/petscconf.h" PETSC_RELEASE_STRING
-      REGEX "#define.*PETSC_HAVE_MPI.*1")
+    FILE(STRINGS "${PETSC_PETSCCONF_H}" PETSC_RELEASE_STRING
+      REGEX "#define.*PETSC_HAVE_MPIUNI 1")
     IF("${PETSC_RELEASE_STRING}" STREQUAL "")
-      SET(PETSC_WITH_MPI FALSE)
+      SET(PETSC_WITH_MPIUNI FALSE)
     ELSE()
-      SET(PETSC_WITH_MPI TRUE)
+      SET(PETSC_WITH_MPIUNI TRUE)
     ENDIF()
 
-    IF( (PETSC_WITH_MPI AND NOT DEAL_II_COMPILER_SUPPORTS_MPI)
+    IF( (PETSC_WITH_MPIUNI AND DEAL_II_COMPILER_SUPPORTS_MPI)
          OR
-         (NOT PETSC_WITH_MPI AND DEAL_II_COMPILER_SUPPORTS_MPI))
+         (NOT PETSC_WITH_MPIUNI AND NOT DEAL_II_COMPILER_SUPPORTS_MPI))
       MESSAGE(STATUS
         "Could not find a sufficient petsc installation: "
         "Petsc has to be configured with the same MPI configuration as deal.II."
index fc6d183fc9f7bf25a7f19e71ab6221f7807ae2ce..f8688998d6f376079590673227348a581bf0f626 100644 (file)
@@ -4,11 +4,17 @@
 
 INCLUDE(FindPackageHandleStandardArgs)
 
-FIND_PATH(PETSC_INCLUDE_DIR petscconf.h
+#
+# To safe some logic, promote environment variables to cmake variables if
+# they are not already set.
+#
+SET_IF_EMPTY(PETSC_DIR "$ENV{PETSC_DIR}")
+SET_IF_EMPTY(PETSC_ARCH "$ENV{PETSC_ARCH}")
+
+FIND_PATH(PETSC_INCLUDE_DIRS petscconf.h
   HINTS
     # petsc is special. Account for that
     ${PETSC_DIR}/${PETSC_ARCH}/include
-    $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/include
   PATH_SUFFIXES petsc
 )
 
@@ -17,27 +23,71 @@ FIND_LIBRARY(PETSC_LIBRARY
   HINTS
     # petsc is special. Account for that
     ${PETSC_DIR}/${PETSC_ARCH}
-    $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}
   PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
 )
 
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG PETSC_LIBRARY PETSC_INCLUDE_DIR)
+
+#
+# So, up to this point it was easy. Now, the tricky part.
+# If petsc is not installed, but a source tree is given by PETSC_DIR petsc
+# splits up its include files to two places:
+#   ${PETSC_DIR}/include
+#   ${PETSC_DIR}/${PETSC_ARCH}/incldue
+#
+IF("${PETSC_INCLUDE_DIRS}" STREQUAL "${PETSC_DIR}/${PETSC_ARCH}/include")
+  #
+  # We found petsc and we used PETSC_DIR and PETSC_ARCH for finding it.
+  #
+  LIST(APPEND PETSC_INCLUDE_DIRS "${PETSC_DIR}/include")
+ENDIF()
+
+#
+# Let's see whether we are able to find petscversion.h and petscconf.h:
+#
+FIND_FILE(PETSC_PETSCVERSION_H petscversion.h
+  HINTS
+    ${PETSC_INCLUDE_DIRS}
+    NO_DEFAULT_PATH
+    NO_CMAKE_ENVIRONMENT_PATH
+    NO_CMAKE_PATH
+    NO_SYSTEM_ENVIRONMENT_PATH
+    NO_CMAKE_SYSTEM_PATH
+    NO_CMAKE_FIND_ROOT_PATH
+  )
+
+FIND_FILE(PETSC_PETSCCONF_H petscconf.h
+  HINTS
+    ${PETSC_INCLUDE_DIRS}
+    NO_DEFAULT_PATH
+    NO_CMAKE_ENVIRONMENT_PATH
+    NO_CMAKE_PATH
+    NO_SYSTEM_ENVIRONMENT_PATH
+    NO_CMAKE_SYSTEM_PATH
+    NO_CMAKE_FIND_ROOT_PATH
+  )
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
+  PETSC_LIBRARY
+  PETSC_INCLUDE_DIRS
+  PETSC_PETSCCONF_H
+  PETSC_PETSCVERSION_H
+  )
 
 IF(PETSC_FOUND)
 
-  FILE(STRINGS "${PETSC_INCLUDE_DIR}/petscversion.h" PETSC_MAJOR_STRING
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_MAJOR_STRING
     REGEX "#define.*PETSC_VERSION_MAJOR")
   STRING(REGEX REPLACE "^.*PETSC_VERSION_MAJOR.*([0-9]+).*" "\\1" PETSC_MAJOR "${PETSC_MAJOR_STRING}")
 
-  FILE(STRINGS "${PETSC_INCLUDE_DIR}/petscversion.h" PETSC_MINOR_STRING
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_MINOR_STRING
     REGEX "#define.*PETSC_VERSION_MINOR")
   STRING(REGEX REPLACE "^.*PETSC_VERSION_MINOR.*([0-9]+).*" "\\1" PETSC_MINOR "${PETSC_MINOR_STRING}")
 
-  FILE(STRINGS "${PETSC_INCLUDE_DIR}/petscversion.h" PETSC_SUBMINOR_STRING
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_SUBMINOR_STRING
     REGEX "#define.*PETSC_VERSION_SUBMINOR")
   STRING(REGEX REPLACE "^.*PETSC_VERSION_SUBMINOR.*([0-9]+).*" "\\1" PETSC_SUBMINOR "${PETSC_SUBMINOR_STRING}")
 
-  FILE(STRINGS "${PETSC_INCLUDE_DIR}/petscversion.h" PETSC_RELEASE_STRING
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_RELEASE_STRING
     REGEX "#define.*PETSC_VERSION_RELEASE.*1")
   IF("${PETSC_RELEASE_STRING}" STREQUAL "")
     SET(PETSC_RELEASE FALSE)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.