# 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
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
PETSC_INCLUDE_DIRS
)
-
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
)
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)
-