From 4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 31 Jul 2014 09:48:41 -0400 Subject: 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. --- Modules/CheckVariableExists.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/CheckVariableExists.cmake') diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index 3a7ef13bd6..9e8e984146 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -45,7 +45,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) - if("${VARIABLE}" MATCHES "^${VARIABLE}$") + if(NOT DEFINED "${VARIABLE}") set(MACRO_CHECK_VARIABLE_DEFINITIONS "-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}") if(NOT CMAKE_REQUIRED_QUIET) -- cgit v1.2.1