]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Harden cmake regexes when looking for #define strings. 13401/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 17 Feb 2022 16:01:52 +0000 (09:01 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 17 Feb 2022 16:01:52 +0000 (09:01 -0700)
cmake/modules/FindADOLC.cmake
cmake/modules/FindGSL.cmake
cmake/modules/FindMUPARSER.cmake
cmake/modules/FindOPENCASCADE.cmake
cmake/modules/FindP4EST.cmake
cmake/modules/FindTRILINOS.cmake

index 8301e437cb72a5eb89b00e8bd64278c2518c57bf..8cf2a765d20b085151f36930d56d3c6012caf061 100644 (file)
@@ -57,7 +57,7 @@ IF(EXISTS ${ADOLC_SETTINGS_H})
   # Check whether ADOL-C is configured with extra trig functions
   #
   FILE(STRINGS "${ADOLC_SETTINGS_H}" ADOLC_ATRIG_ERF_STRING
-    REGEX "#define ATRIG_ERF"
+    REGEX "^[ \t]*#[ \t]*define[ \t]+ATRIG_ERF"
     )
   IF(NOT "${ADOLC_ATRIG_ERF_STRING}" STREQUAL "")
     SET(ADOLC_WITH_ATRIG_ERF TRUE)
@@ -69,7 +69,7 @@ IF(EXISTS ${ADOLC_SETTINGS_H})
   # Check whether ADOL-C is configured with advanced branching
   #
   FILE(STRINGS "${ADOLC_SETTINGS_H}" ADOLC_ADVANCED_BRANCHING_STRING
-    REGEX "#define ADOLC_ADVANCED_BRANCHING"
+    REGEX "^[ \t]*#[ \t]*define[ \t]+ADOLC_ADVANCED_BRANCHING"
     )
   IF(NOT "${ADOLC_ADVANCED_BRANCHING_STRING}" STREQUAL "")
     SET(ADOLC_WITH_ADVANCED_BRANCHING TRUE)
@@ -81,7 +81,7 @@ IF(EXISTS ${ADOLC_SETTINGS_H})
   # Check whether ADOL-C is configured with tapeless number reference counting
   #
   FILE(STRINGS "${ADOLC_SETTINGS_H}" ADOLC_WITH_TAPELESS_REFCOUNTING_STRING
-    REGEX "#define USE_ADTL_REFCOUNTING 1"
+    REGEX "^[ \t]*#[ \t]*define[ \t]+USE_ADTL_REFCOUNTING 1"
     )
   IF(NOT "${ADOLC_WITH_TAPELESS_REFCOUNTING_STRING}" STREQUAL "")
     SET(ADOLC_WITH_TAPELESS_REFCOUNTING TRUE)
@@ -93,7 +93,7 @@ IF(EXISTS ${ADOLC_SETTINGS_H})
   # Check whether ADOL-C is configured to use the Boost pool allocator
   #
   FILE(STRINGS "${ADOLC_SETTINGS_H}" ADOLC_BOOST_POOL_STRING
-    REGEX "#define USE_BOOST_POOL 1"
+    REGEX "^[ \t]*#[ \t]*define[ \t]+USE_BOOST_POOL 1"
     )
   IF(NOT "${ADOLC_BOOST_POOL_STRING}" STREQUAL "")
     SET(ADOLC_WITH_BOOST_ALLOCATOR TRUE)
index 6ed03d06ad6a4e302cce367ade4a9d6a6ddc50e3..7f26dba5f59cc1a738bbb27db993d856cfd30b02 100644 (file)
@@ -63,7 +63,7 @@ DEAL_II_FIND_PATH(GSL_INCLUDE_DIR gsl/gsl_version.h
 
 IF(EXISTS "${GSL_INCLUDE_DIR}/gsl/gsl_version.h" )
   FILE(STRINGS "${GSL_INCLUDE_DIR}/gsl/gsl_version.h" GSL_VERSION_STRING_LINE
-    REGEX "#define GSL_VERSION"
+    REGEX "^[ \t]*#[ \t]*define[ \t]+GSL_VERSION"
     )
   STRING(REGEX REPLACE ".*([0-9].[0-9]+).*" "\\1" GSL_VERSION
     "${GSL_VERSION_STRING_LINE}"
index 8ade190319aad17046dd458e6f09d0ba8923ed4c..865b6eb4dd3f6742edfba6fb2eb85a0cabc2b006 100644 (file)
@@ -45,7 +45,7 @@ IF(EXISTS ${MUPARSER_INCLUDE_DIR}/muParserDef.h)
     # Try to match the line
     #
     #     #define MUP_VERSION _T("2.2.4")
-    REGEX "#define MUP_VERSION _T"
+    REGEX "^[ \t]*#[ \t]*define[ \t]+MUP_VERSION _T"
     )
 
   IF("${MUPARSER_VERSION_STRING_LINE}" STREQUAL "")
index 575a9e0c80e614dad71079d17196af4c5f85d16b..25db00d14937ca82dbdf46bae0e0313c1fffb400 100644 (file)
@@ -43,7 +43,7 @@ DEAL_II_FIND_PATH(OPENCASCADE_INCLUDE_DIR Standard_Version.hxx
 
 IF(EXISTS ${OPENCASCADE_INCLUDE_DIR}/Standard_Version.hxx)
   FILE(STRINGS "${OPENCASCADE_INCLUDE_DIR}/Standard_Version.hxx" OPENCASCADE_VERSION
-    REGEX "#define OCC_VERSION_COMPLETE "
+    REGEX "^[ \t]*#[ \t]*define[ \t]+OCC_VERSION_COMPLETE "
     )
   STRING(REGEX REPLACE
     "#define OCC_VERSION_COMPLETE.*\"(.*)\"" "\\1"
index d32cadf28155fd018f7e36564da0ba14a0d86d9a..ed741999819bc355d9d62ee4e754e8cbd15e5be2 100644 (file)
@@ -162,7 +162,7 @@ IF(EXISTS ${P4EST_INCLUDE_DIR}/p4est_config.h)
   # Extract version numbers:
   #
   FILE(STRINGS "${P4EST_INCLUDE_DIR}/p4est_config.h" P4EST_VERSION
-    REGEX "#define P4EST_VERSION \"")
+    REGEX "^[ \t]*#[ \t]*define[ \t]+P4EST_VERSION \"")
   STRING(REGEX REPLACE "^.*P4EST_VERSION.*\"([0-9]+.*)\".*" "\\1"
     P4EST_VERSION "${P4EST_VERSION}"
     )
index e13b311400e767f0ea427d39acccf66957980c6d..0e60a45cbede00e3663f27621bf49e41f0c2a636 100644 (file)
@@ -89,21 +89,21 @@ IF(EXISTS ${EPETRA_CONFIG_H})
   # Determine whether Trilinos was configured with MPI and 64bit indices:
   #
   FILE(STRINGS "${EPETRA_CONFIG_H}" EPETRA_MPI_STRING
-    REGEX "#define HAVE_MPI")
+    REGEX "^[ \t]*#[ \t]*define[ \t]+HAVE_MPI")
   IF("${EPETRA_MPI_STRING}" STREQUAL "")
     SET(TRILINOS_WITH_MPI FALSE)
   ELSE()
     SET(TRILINOS_WITH_MPI TRUE)
   ENDIF()
   FILE(STRINGS "${EPETRA_CONFIG_H}" EPETRA_32BIT_STRING
-    REGEX "#define EPETRA_NO_32BIT_GLOBAL_INDICES")
+    REGEX "^[ \t]*#[ \t]*define[ \t]+EPETRA_NO_32BIT_GLOBAL_INDICES")
   IF("${EPETRA_64BIT_STRING}" STREQUAL "")
     SET(TRILINOS_WITH_NO_32BITS_INDICES TRUE)
   ELSE()
     SET(TRILINOS_WITH_NO_32BITS_INDICES FALSE)
   ENDIF()
   FILE(STRINGS "${EPETRA_CONFIG_H}" EPETRA_64BIT_STRING
-    REGEX "#define EPETRA_NO_64BIT_GLOBAL_INDICES")
+    REGEX "^[ \t]*#[ \t]*define[ \t]+EPETRA_NO_64BIT_GLOBAL_INDICES")
   IF("${EPETRA_64BIT_STRING}" STREQUAL "")
     SET(TRILINOS_WITH_NO_64BITS_INDICES TRUE)
   ELSE()

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.