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:
parent
b48211d426
commit
4f2fcce4b9
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
|
||||||
if("${VAR}" MATCHES "^${VAR}$")
|
if(NOT DEFINED "${VAR}")
|
||||||
set(_FAIL_REGEX)
|
set(_FAIL_REGEX)
|
||||||
set(_key)
|
set(_key)
|
||||||
foreach(arg ${ARGN})
|
foreach(arg ${ARGN})
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
|
macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
|
||||||
if("${VAR}" MATCHES "^${VAR}$")
|
if(NOT DEFINED "${VAR}")
|
||||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
|
macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
|
||||||
if("${VAR}" MATCHES "^${VAR}$")
|
if(NOT DEFINED "${VAR}")
|
||||||
set(_FAIL_REGEX)
|
set(_FAIL_REGEX)
|
||||||
set(_key)
|
set(_key)
|
||||||
foreach(arg ${ARGN})
|
foreach(arg ${ARGN})
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
|
macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
|
||||||
if("${VAR}" MATCHES "^${VAR}$")
|
if(NOT DEFINED "${VAR}")
|
||||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
|
macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
|
||||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
if(NOT DEFINED "${VARIABLE}")
|
||||||
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
set(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||||
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(NOT CMAKE_REQUIRED_QUIET)
|
if(NOT CMAKE_REQUIRED_QUIET)
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
|
macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
|
||||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
if(NOT DEFINED "${VARIABLE}")
|
||||||
if(CMAKE_REQUIRED_INCLUDES)
|
if(CMAKE_REQUIRED_INCLUDES)
|
||||||
set(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
|
set(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
|
macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
|
||||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
if(NOT DEFINED "${VARIABLE}")
|
||||||
if(CMAKE_REQUIRED_INCLUDES)
|
if(CMAKE_REQUIRED_INCLUDES)
|
||||||
set(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
|
set(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
|
macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
|
||||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
if(NOT DEFINED "${VARIABLE}")
|
||||||
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
|
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
|
||||||
if(CMAKE_REQUIRED_INCLUDES)
|
if(CMAKE_REQUIRED_INCLUDES)
|
||||||
set(CHECK_INCLUDE_FILES_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
|
set(CHECK_INCLUDE_FILES_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
|
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
|
||||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
if(NOT DEFINED "${VARIABLE}")
|
||||||
set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
|
set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
|
||||||
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(NOT CMAKE_REQUIRED_QUIET)
|
if(NOT CMAKE_REQUIRED_QUIET)
|
||||||
|
|
|
@ -50,7 +50,7 @@ macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
|
macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
|
||||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
if(NOT DEFINED "${VARIABLE}")
|
||||||
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
|
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
|
||||||
set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||||
if(CMAKE_REQUIRED_LIBRARIES)
|
if(CMAKE_REQUIRED_LIBRARIES)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
|
|
||||||
macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
|
macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
|
||||||
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
if(NOT DEFINED "${VARIABLE}")
|
||||||
set(MACRO_CHECK_VARIABLE_DEFINITIONS
|
set(MACRO_CHECK_VARIABLE_DEFINITIONS
|
||||||
"-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
"-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
|
||||||
if(NOT CMAKE_REQUIRED_QUIET)
|
if(NOT CMAKE_REQUIRED_QUIET)
|
||||||
|
|
Loading…
Reference in New Issue