Skip to content

Commit

Permalink
CMake: Simplify if() conditions on check result variables
Browse files Browse the repository at this point in the history
Remove use of an old 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.  Use if(DEFINED) instead.
This also avoids warnings for CMake Policy CMP0054 in CMake 3.1.
  • Loading branch information
bradking authored and bagder committed Nov 19, 2014
1 parent 54fc885 commit fba9f41
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CMake/Macros.cmake
Expand Up @@ -27,7 +27,7 @@ endmacro(CHECK_INCLUDE_FILE_CONCAT)

# For other curl specific tests, use this macro.
macro(CURL_INTERNAL_TEST CURL_TEST)
if("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
if(NOT DEFINED "${CURL_TEST}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
Expand Down Expand Up @@ -55,11 +55,11 @@ macro(CURL_INTERNAL_TEST CURL_TEST)
"Performing Curl Test ${CURL_TEST} failed with the following output:\n"
"${OUTPUT}\n")
endif(${CURL_TEST})
endif("${CURL_TEST}" MATCHES "^${CURL_TEST}$")
endif()
endmacro(CURL_INTERNAL_TEST)

macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
if("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
if(NOT DEFINED "${CURL_TEST}_COMPILE")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
Expand Down Expand Up @@ -91,5 +91,5 @@ macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
"\n\n")
endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
endif("${CURL_TEST}_COMPILE" MATCHES "^${CURL_TEST}_COMPILE$")
endif()
endmacro(CURL_INTERNAL_TEST_RUN)

0 comments on commit fba9f41

Please sign in to comment.