summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-07-31 13:48:41 (GMT)
committerBrad King <brad.king@kitware.com>2014-07-31 13:48:41 (GMT)
commit4f2fcce4b9f897dfa98cb82f3876cd43ab80f69b (patch)
treeb54f99738b9ae58df6f6c64d04938a768a1f15a9 /Modules
parentb48211d4261840136e750d3d82f195ad48b17a8f (diff)
downloadCMake-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')
-rw-r--r--Modules/CheckCSourceCompiles.cmake2
-rw-r--r--Modules/CheckCSourceRuns.cmake2
-rw-r--r--Modules/CheckCXXSourceCompiles.cmake2
-rw-r--r--Modules/CheckCXXSourceRuns.cmake2
-rw-r--r--Modules/CheckFunctionExists.cmake2
-rw-r--r--Modules/CheckIncludeFile.cmake2
-rw-r--r--Modules/CheckIncludeFileCXX.cmake2
-rw-r--r--Modules/CheckIncludeFiles.cmake2
-rw-r--r--Modules/CheckLibraryExists.cmake2
-rw-r--r--Modules/CheckSymbolExists.cmake2
-rw-r--r--Modules/CheckVariableExists.cmake2
11 files changed, 11 insertions, 11 deletions
diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake
index 8721d55..7523446 100644
--- a/Modules/CheckCSourceCompiles.cmake
+++ b/Modules/CheckCSourceCompiles.cmake
@@ -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})
diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake
index a4fa57e..0fb0f23 100644
--- a/Modules/CheckCSourceRuns.cmake
+++ b/Modules/CheckCSourceRuns.cmake
@@ -39,7 +39,7 @@
macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
- if("${VAR}" MATCHES "^${VAR}$")
+ if(NOT DEFINED "${VAR}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake
index 6ce64a1..edd62a6 100644
--- a/Modules/CheckCXXSourceCompiles.cmake
+++ b/Modules/CheckCXXSourceCompiles.cmake
@@ -39,7 +39,7 @@
macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
- if("${VAR}" MATCHES "^${VAR}$")
+ if(NOT DEFINED "${VAR}")
set(_FAIL_REGEX)
set(_key)
foreach(arg ${ARGN})
diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake
index c655863..02731f8 100644
--- a/Modules/CheckCXXSourceRuns.cmake
+++ b/Modules/CheckCXXSourceRuns.cmake
@@ -39,7 +39,7 @@
macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
- if("${VAR}" MATCHES "^${VAR}$")
+ if(NOT DEFINED "${VAR}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake
index bfd1836..01a652b 100644
--- a/Modules/CheckFunctionExists.cmake
+++ b/Modules/CheckFunctionExists.cmake
@@ -38,7 +38,7 @@
macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
- if("${VARIABLE}" MATCHES "^${VARIABLE}$")
+ if(NOT DEFINED "${VARIABLE}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
if(NOT CMAKE_REQUIRED_QUIET)
diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake
index ea73267..c217bd4 100644
--- a/Modules/CheckIncludeFile.cmake
+++ b/Modules/CheckIncludeFile.cmake
@@ -40,7 +40,7 @@
# License text for the above reference.)
macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
- if("${VARIABLE}" MATCHES "^${VARIABLE}$")
+ if(NOT DEFINED "${VARIABLE}")
if(CMAKE_REQUIRED_INCLUDES)
set(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
else()
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index 39abeff..718e667 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()
diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake
index 6aa0f2b..eb4cf0d 100644
--- a/Modules/CheckIncludeFiles.cmake
+++ b/Modules/CheckIncludeFiles.cmake
@@ -39,7 +39,7 @@
# License text for the above reference.)
macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
- if("${VARIABLE}" MATCHES "^${VARIABLE}$")
+ if(NOT DEFINED "${VARIABLE}")
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
if(CMAKE_REQUIRED_INCLUDES)
set(CHECK_INCLUDE_FILES_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
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)
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index bf2e797..6f50c88 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -50,7 +50,7 @@ macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
endmacro()
macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
- if("${VARIABLE}" MATCHES "^${VARIABLE}$")
+ if(NOT DEFINED "${VARIABLE}")
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
if(CMAKE_REQUIRED_LIBRARIES)
diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake
index 3a7ef13..9e8e984 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)