diff options
author | Brad King <brad.king@kitware.com> | 2014-07-31 13:48:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-07-31 13:48:41 (GMT) |
commit | 4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b (patch) | |
tree | b54f99738b9ae58df6f6c64d04938a768a1f15a9 /Modules/CheckLibraryExists.cmake | |
parent | b48211d4261840136e750d3d82f195ad48b17a8f (diff) | |
download | CMake-4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b.zip CMake-4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b.tar.gz CMake-4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b.tar.bz2 |
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.
Diffstat (limited to 'Modules/CheckLibraryExists.cmake')
-rw-r--r-- | Modules/CheckLibraryExists.cmake | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index 2b41379..fac5dd1 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -41,7 +41,7 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) - if("${VARIABLE}" MATCHES "^${VARIABLE}$") + if(NOT DEFINED "${VARIABLE}") set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") if(NOT CMAKE_REQUIRED_QUIET) |