Check*: Allow result variables to contain regex special characters (#14923)

Prior to the existence of the if(DEFINED) condition, many of our Check
modules implemented the condition with a hack that takes advantage of
the auto-dereference behavior of the if() command to detect if a
variable is defined.  The hack has the form:

 if("${VAR} MATCHES "^${VAR}$")

where "${VAR}" is a macro argument reference.  However, this does not
work when the variable named in the macro argument contains characters
that have special meaning in regular expressions, such as '+'.  Run the
command

 git grep -E 'if\("\$\{.*\}" MATCHES "\^\$\{.*\}\$"\)' -- Modules/Check*

to identify lines with this problem.  Use if(NOT DEFINED) instead.
This commit is contained in:
Brad King
2014-07-31 09:48:41 -04:00
parent b48211d426
commit 4f2fcce4b9
11 changed files with 11 additions and 11 deletions

View File

@@ -39,7 +39,7 @@
macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
if("${VAR}" MATCHES "^${VAR}$")
if(NOT DEFINED "${VAR}")
set(_FAIL_REGEX)
set(_key)
foreach(arg ${ARGN})