# 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."
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
)
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)