From: Wolfgang Bangerth Date: Thu, 17 Feb 2022 16:01:52 +0000 (-0700) Subject: Harden cmake regexes when looking for #define strings. X-Git-Tag: v9.4.0-rc1~468^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13401%2Fhead;p=dealii.git Harden cmake regexes when looking for #define strings. --- diff --git a/cmake/modules/FindADOLC.cmake b/cmake/modules/FindADOLC.cmake index 8301e437cb..8cf2a765d2 100644 --- a/cmake/modules/FindADOLC.cmake +++ b/cmake/modules/FindADOLC.cmake @@ -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) diff --git a/cmake/modules/FindGSL.cmake b/cmake/modules/FindGSL.cmake index 6ed03d06ad..7f26dba5f5 100644 --- a/cmake/modules/FindGSL.cmake +++ b/cmake/modules/FindGSL.cmake @@ -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}" diff --git a/cmake/modules/FindMUPARSER.cmake b/cmake/modules/FindMUPARSER.cmake index 8ade190319..865b6eb4dd 100644 --- a/cmake/modules/FindMUPARSER.cmake +++ b/cmake/modules/FindMUPARSER.cmake @@ -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 "") diff --git a/cmake/modules/FindOPENCASCADE.cmake b/cmake/modules/FindOPENCASCADE.cmake index 575a9e0c80..25db00d149 100644 --- a/cmake/modules/FindOPENCASCADE.cmake +++ b/cmake/modules/FindOPENCASCADE.cmake @@ -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" diff --git a/cmake/modules/FindP4EST.cmake b/cmake/modules/FindP4EST.cmake index d32cadf281..ed74199981 100644 --- a/cmake/modules/FindP4EST.cmake +++ b/cmake/modules/FindP4EST.cmake @@ -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}" ) diff --git a/cmake/modules/FindTRILINOS.cmake b/cmake/modules/FindTRILINOS.cmake index e13b311400..0e60a45cbe 100644 --- a/cmake/modules/FindTRILINOS.cmake +++ b/cmake/modules/FindTRILINOS.cmake @@ -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()