2002-11-21 15:11:46 +00:00
|
|
|
#
|
|
|
|
# Check if the variable exists.
|
|
|
|
# # CHECK_VARIABLE_EXISTS - macro which checks if the variable exists
|
|
|
|
# VAR - the name of the variable
|
|
|
|
# VARIABLE - variable to store the result
|
|
|
|
#
|
|
|
|
|
|
|
|
MACRO(CHECK_VARIABLE_EXISTS VAR VARIABLE)
|
2002-12-13 19:58:55 +00:00
|
|
|
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
|
|
|
SET(MACRO_CHECK_VARIABLE_DEFINITIONS -DCHECK_VARIABLE_EXISTS=${VAR})
|
|
|
|
TRY_COMPILE(${VARIABLE}
|
2002-12-17 19:54:25 +00:00
|
|
|
${CMAKE_BINARY_DIR}
|
2002-12-13 19:58:55 +00:00
|
|
|
${CMAKE_ROOT}/Modules/CheckVariableExists.c
|
|
|
|
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_VARIABLE_DEFINITIONS}
|
|
|
|
OUTPUT_VARIABLE OUTPUT)
|
|
|
|
IF(${VARIABLE})
|
|
|
|
SET(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}")
|
|
|
|
ELSE(${VARIABLE})
|
|
|
|
SET(${VARIABLE} "" CACHE INTERNAL "Have variable ${VAR}")
|
2002-12-17 19:54:25 +00:00
|
|
|
WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeError.log
|
2002-12-13 19:58:55 +00:00
|
|
|
"Determining if the variable ${VAR} exists failed with the following output:\n"
|
|
|
|
"${OUTPUT}\n" APPEND)
|
|
|
|
ENDIF(${VARIABLE})
|
|
|
|
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
2002-11-21 15:11:46 +00:00
|
|
|
ENDMACRO(CHECK_VARIABLE_EXISTS)
|