summaryrefslogtreecommitdiff
path: root/Modules/CheckIncludeFileCXX.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-07-31 09:48:41 -0400
committerBrad King <brad.king@kitware.com>2014-07-31 09:48:41 -0400
commit4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b (patch)
treeb54f99738b9ae58df6f6c64d04938a768a1f15a9 /Modules/CheckIncludeFileCXX.cmake
parentb48211d4261840136e750d3d82f195ad48b17a8f (diff)
downloadcmake-4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b.tar.gz
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/CheckIncludeFileCXX.cmake')
-rw-r--r--Modules/CheckIncludeFileCXX.cmake2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index 39abeff5b1..718e667f45 100644
--- a/Modules/CheckIncludeFileCXX.cmake
+++ b/Modules/CheckIncludeFileCXX.cmake
@@ -44,7 +44,7 @@
# License text for the above reference.)
macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
- if("${VARIABLE}" MATCHES "^${VARIABLE}$")
+ if(NOT DEFINED "${VARIABLE}")
if(CMAKE_REQUIRED_INCLUDES)
set(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
else()