]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Bugfix: Fix the cache logic in FindPETSC.cmake
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Sep 2012 09:19:04 +0000 (09:19 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Sep 2012 09:19:04 +0000 (09:19 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26709 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/modules/FindPETSC.cmake

index 1b82f4ac2ee28b02b18e694110a51eca8aec6177..68355fbf91020923a2b61729a85413a6c881f218 100644 (file)
@@ -6,8 +6,6 @@
 #     PETSC_FOUND
 #     PETSC_LIBRARIES
 #     PETSC_INCLUDE_DIRS
-#     PETSC_PETSCCONF_H
-#     PETSC_PETSCVERSION_H
 #     PETSC_VERSION
 #     PETSC_VERSION_MAJOR
 #     PETSC_VERSION_MINOR
@@ -26,13 +24,19 @@ INCLUDE(FindPackageHandleStandardArgs)
 SET_IF_EMPTY(PETSC_DIR "$ENV{PETSC_DIR}")
 SET_IF_EMPTY(PETSC_ARCH "$ENV{PETSC_ARCH}")
 
-FIND_PATH(PETSC_INCLUDE_DIRS petscconf.h
+
+#
+# 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_ARCH}/include
+    ${PETSC_INCLUDE_DIRS}
   PATH_SUFFIXES petsc
 )
 
+
 FIND_LIBRARY(PETSC_LIBRARIES
   NAMES petsc
   HINTS
@@ -47,13 +51,19 @@ FIND_LIBRARY(PETSC_LIBRARIES
 # 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
+#   ${PETSC_DIR}/${PETSC_ARCH}/include
 #
-IF("${PETSC_INCLUDE_DIRS}" STREQUAL "${PETSC_DIR}/${PETSC_ARCH}/include")
+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:
   #
-  LIST(APPEND PETSC_INCLUDE_DIRS "${PETSC_DIR}/include")
+  IF(PETSC_INCLUDE_DIRS MATCHES "-NOTFOUND")
+    SET(PETSC_INCLUDE_DIRS "${PETSC_INCLUDE_DIR_ARCH};${PETSC_DIR}/include"
+      CACHE STRING "Include paths for petsc"
+      FORCE
+      )
+  ENDIF()
 ENDIF()
 
 
@@ -82,8 +92,26 @@ FIND_FILE(PETSC_PETSCCONF_H petscconf.h
     NO_CMAKE_FIND_ROOT_PATH
   )
 
+#
+# If no, PETSC_INCLUDE_DIRS is invalid, so reset it to NOTFOUND:
+#
+IF( PETSC_PETSCCONF_H MATCHES "-NOTFOUND" OR
+    PETSC_PETSCVERSION_H MATCHES "-NOTFOUND" )
+  SET(PETSC_INCLUDE_DIRS "PETSC_INCLUDE_DIRS-NOTFOUND"
+    CACHE STRING "Include paths for petsc"
+    FORCE
+    )
+ENDIF()
+
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
+  PETSC_LIBRARIES
+  PETSC_INCLUDE_DIRS
+  PETSC_PETSCCONF_H
+  PETSC_PETSCVERSION_H
+  )
+
 
-IF(NOT PETSC_PETSCCONF_H MATCHES "-NOTFOUND")
+IF(PETSC_FOUND)
 
   #
   # Is petsc compiled with support for MPIUNI?
@@ -117,16 +145,6 @@ IF(NOT PETSC_PETSCCONF_H MATCHES "-NOTFOUND")
     MARK_AS_ADVANCED(PETSC_LIBMPIUNI)
   ENDIF()
 
-ENDIF()
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
-  PETSC_LIBRARIES
-  PETSC_INCLUDE_DIRS
-  PETSC_PETSCCONF_H
-  PETSC_PETSCVERSION_H
-  )
-
-IF(PETSC_FOUND)
 
   FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_MAJOR_STRING
     REGEX "#define.*PETSC_VERSION_MAJOR")
@@ -173,8 +191,13 @@ IF(PETSC_FOUND)
   MARK_AS_ADVANCED(
     PETSC_LIBRARIES
     PETSC_INCLUDE_DIRS
-    PETSC_PETSCCONF_H
-    PETSC_PETSCVERSION_H
   )
 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.