]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
A last bugfix for FindPETSC.cmake
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Sep 2012 23:33:25 +0000 (23:33 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Sep 2012 23:33:25 +0000 (23:33 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26875 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/modules/FindPETSC.cmake

index 749d41a867ce05de50323b357e15c6d1d6dc9336..631d0212e8abe17f4b94f968a9d69cb7ce8e0cbd 100644 (file)
@@ -40,18 +40,6 @@ SET_IF_EMPTY(PETSC_ARCH "$ENV{PETSC_ARCH}")
 # against someday to avoid underlinkage
 #
 
-#
-# Search for the first part of the includes:
-#
-FIND_PATH(PETSC_INCLUDE_DIR_ARCH petscconf.h
-  HINTS
-    # petsc is special. Account for that
-    ${PETSC_DIR}
-    ${PETSC_DIR}/${PETSC_ARCH}/include
-    ${PETSC_INCLUDE_DIRS}
-  PATH_SUFFIXES petsc
-)
-
 FIND_LIBRARY(PETSC_LIBRARIES
   NAMES petsc
   HINTS
@@ -61,60 +49,63 @@ FIND_LIBRARY(PETSC_LIBRARIES
   PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
 )
 
+
 #
-# 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}/include
+# So, up to this point it was easy. Now, the tricky part:
 #
-IF("${PETSC_INCLUDE_DIR_ARCH}" STREQUAL "${PETSC_DIR}/${PETSC_ARCH}/include")
-  #
-  # We found petsc and we used PETSC_DIR and PETSC_ARCH for finding it.
-  # So, we assume a source tree layout:
-  #
-  IF( PETSC_INCLUDE_DIRS MATCHES "-NOTFOUND" OR
-      "${PETSC_INCLUDE_DIRS}" STREQUAL "" )
-    SET(PETSC_INCLUDE_DIRS "${PETSC_INCLUDE_DIR_ARCH};${PETSC_DIR}/include"
-      CACHE STRING "Include paths for petsc"
-      FORCE
-      )
-  ENDIF()
-ELSE()
-  IF( PETSC_INCLUDE_DIRS MATCHES "-NOTFOUND" OR
-      "${PETSC_INCLUDE_DIRS}" STREQUAL "" )
-    SET(PETSC_INCLUDE_DIRS "${PETSC_INCLUDE_DIR_ARCH}"
-      CACHE STRING "Include paths for petsc"
-      FORCE
-      )
-  ENDIF()
-ENDIF()
 
 
 #
-# Let's see whether we are able to find petscversion.h and petscconf.h:
+# Search for the first part of the includes:
 #
-FIND_FILE(PETSC_PETSCVERSION_H petscversion.h
+FIND_PATH(PETSC_INCLUDE_DIR_ARCH petscconf.h
   HINTS
+    # petsc is special. Account for that
+    ${PETSC_DIR}
+    ${PETSC_DIR}/${PETSC_ARCH}/include
     ${PETSC_INCLUDE_DIRS}
-  PATH_SUFFIXES petsc
-  )
+  PATH_SUFFIXES include petsc
+)
 
-FIND_FILE(PETSC_PETSCCONF_H petscconf.h
+#
+# Sometimes, this is not enough...
+# If petsc is not installed but in source tree layout, there will be
+#   ${PETSC_DIR}/${PETSC_ARCH}/include - which we should have found by now.
+#   ${PETSC_DIR}/include               - which we still have to find.
+#
+# Or it is installed in a non standard layout in the system (e.g. in
+# Gentoo), where there will be
+#   ${PETSC_DIR}/${PETSC_ARCH}/include
+#   /usr/include/petsc ...
+#
+# Either way, petscversion.h should lie around:
+#
+FIND_PATH(PETSC_INCLUDE_DIR_COMMON petscversion.h
   HINTS
+    ${PETSC_DIR}
+    ${PETSC_DIR}/${PETSC_ARCH}/include
     ${PETSC_INCLUDE_DIRS}
   PATH_SUFFIXES petsc
-  )
+)
 
 #
-# If no, PETSC_INCLUDE_DIRS is invalid, so reset it to NOTFOUND:
+# And finally set PETSC_INCLUDE_DIRS depending on the outcome of our crude
+# guess:
 #
-IF( PETSC_PETSCCONF_H MATCHES "-NOTFOUND" OR
-    PETSC_PETSCVERSION_H MATCHES "-NOTFOUND" )
+IF( PETSC_INCLUDE_DIR_ARCH MATCHES "-NOTFOUND" OR
+    PETSC_INCLUDE_DIR_COMMON MATCHES "-NOTFOUND" )
   SET(PETSC_INCLUDE_DIRS "PETSC_INCLUDE_DIRS-NOTFOUND"
     CACHE STRING "Include paths for petsc"
     FORCE
     )
+  UNSET(PETSC_INCLUDE_DIR_ARCH CACHE)
+  UNSET(PETSC_INCLUDE_DIR_COMMON CACHE)
+ELSE()
+  UNSET(PETSC_INCLUDE_DIRS CACHE)
+  SET(PETSC_INCLUDE_DIRS
+    ${PETSC_INCLUDE_DIR_ARCH}
+    ${PETSC_INCLUDE_DIR_COMMON}
+    )
 ENDIF()
 
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
@@ -122,7 +113,6 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
   PETSC_INCLUDE_DIRS
   )
 
-
 IF(PETSC_FOUND)
 
   #
@@ -138,7 +128,8 @@ IF(PETSC_FOUND)
 
   IF(PETSC_WITH_MPIUNI)
     #
-    # TODO: Still needed?
+    # TODO: Still needed? We have a way bigger problem with underlinkage so
+    #       far...
     #
     # If yes, add libmpiuni.so/a (if available)
     # We need to link with it on some systems where PETSc is built without
@@ -201,11 +192,3 @@ ELSE()
     )
 ENDIF()
 
-#
-# Unset a bunch of cached variables.
-# Only PETSC_INCLUDE_DIRS should remain cached
-#
-UNSET(PETSC_INCLUDE_DIR_ARCH CACHE)
-UNSET(PETSC_PETSCCONF_H CACHE)
-UNSET(PETSC_PETSCVERSION_H CACHE)
-

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.