]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix PETSc version detection. 14255/head
authorDavid Wells <drwells@email.unc.edu>
Wed, 24 Aug 2022 19:35:42 +0000 (15:35 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 12 Sep 2022 12:49:48 +0000 (08:49 -0400)
New versions of PETSc now define PETSC_VERSION_LT etc. in one line, so
our detection of PETSC_VERSION_MAJOR will now also pick up that
usage. Get around this by making the regex more correct.

cmake/modules/FindPETSC.cmake

index 95643882ac698bf61ce2e07d978cb2d2859ca0d5..ea13227625dc2463e63c136d238094358479e589 100644 (file)
@@ -95,23 +95,23 @@ DEAL_II_FIND_PATH(PETSC_INCLUDE_DIR_COMMON petscversion.h
 SET(PETSC_PETSCVERSION_H "${PETSC_INCLUDE_DIR_COMMON}/petscversion.h")
 IF(EXISTS ${PETSC_PETSCVERSION_H})
   FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_MAJOR_STRING
-    REGEX "#define.*PETSC_VERSION_MAJOR")
-  STRING(REGEX REPLACE "^.*PETSC_VERSION_MAJOR.* ([0-9]+).*" "\\1"
+    REGEX "^#[ \t]*define[ \t]+PETSC_VERSION_MAJOR[ \t]+[0-9]+[ \t]*$")
+  STRING(REGEX REPLACE "^#[ \t]*define[ \t]+PETSC_VERSION_MAJOR[ \t]+([0-9]+)[ \t]*$" "\\1"
     PETSC_VERSION_MAJOR "${PETSC_VERSION_MAJOR_STRING}"
     )
   FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_MINOR_STRING
-    REGEX "#define.*PETSC_VERSION_MINOR")
-  STRING(REGEX REPLACE "^.*PETSC_VERSION_MINOR.* ([0-9]+).*" "\\1"
+    REGEX "^#[ \t]*define[ \t]+PETSC_VERSION_MINOR[ \t]+[0-9]+[ \t]*$")
+  STRING(REGEX REPLACE "^#[ \t]*define[ \t]+PETSC_VERSION_MINOR[ \t]+([0-9]+)[ \t]*$" "\\1"
     PETSC_VERSION_MINOR "${PETSC_VERSION_MINOR_STRING}"
     )
   FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_SUBMINOR_STRING
-    REGEX "#define.*PETSC_VERSION_SUBMINOR")
-  STRING(REGEX REPLACE "^.*PETSC_VERSION_SUBMINOR.* ([0-9]+).*" "\\1"
+    REGEX "^#[ \t]*define[ \t]+PETSC_VERSION_SUBMINOR[ \t]+[0-9]+[ \t]*$")
+  STRING(REGEX REPLACE "^#[ \t]*define[ \t]+PETSC_VERSION_SUBMINOR[ \t]+([0-9]+)[ \t]*$" "\\1"
     PETSC_VERSION_SUBMINOR "${PETSC_VERSION_SUBMINOR_STRING}"
     )
   FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_PATCH_STRING
-    REGEX "#define.*PETSC_VERSION_PATCH")
-  STRING(REGEX REPLACE "^.*PETSC_VERSION_PATCH.* ([0-9]+).*" "\\1"
+    REGEX "^#[ \t]*define[ \t]+PETSC_VERSION_PATCH[ \t]+[0-9]+[ \t]*$")
+  STRING(REGEX REPLACE "^#[ \t]*define[ \t]+PETSC_VERSION_PATCH[ \t]+([0-9]+)[ \t]*$" "\\1"
     PETSC_VERSION_PATCH "${PETSC_VERSION_PATCH_STRING}"
     )
   SET(PETSC_VERSION

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.