69 lines
1.8 KiB
CMake
69 lines
1.8 KiB
CMake
#
|
|
# Test SET
|
|
#
|
|
SET (ZERO_VAR 0)
|
|
|
|
IF(ZERO_VAR)
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED)
|
|
ELSE(ZERO_VAR)
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED)
|
|
ENDIF(ZERO_VAR)
|
|
|
|
SET(ONE_VAR 1)
|
|
SET(ONE_VAR2 1)
|
|
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
|
|
|
|
#
|
|
# Test VARIABLE_REQUIRES
|
|
#
|
|
VARIABLE_REQUIRES(ONE_VAR
|
|
ONE_VAR_IS_DEFINED ONE_VAR)
|
|
|
|
#
|
|
# Test various IF/ELSE combinations
|
|
#
|
|
IF(ONE_VAR AND ONE_VAR2)
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
|
|
ELSE(ONE_VAR AND ONE_VAR2)
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND)
|
|
ENDIF(ONE_VAR AND ONE_VAR2)
|
|
|
|
IF(ZERO_VAR OR ONE_VAR2)
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR)
|
|
ELSE(ZERO_VAR OR ONE_VAR2)
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
|
|
ENDIF(ZERO_VAR OR ONE_VAR2)
|
|
|
|
IF(STRING_VAR MATCHES "^CMake")
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
|
|
ELSE(STRING_VAR MATCHES "^CMake")
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
|
ENDIF(STRING_VAR MATCHES "^CMake")
|
|
|
|
IF(COMMAND "IF")
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
|
ELSE(COMMAND "IF")
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
|
ENDIF(COMMAND "IF")
|
|
|
|
#
|
|
# Test FOREACH
|
|
#
|
|
FOREACH (INDEX 1 2)
|
|
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
|
|
ENDFOREACH(INDEX)
|
|
|
|
#
|
|
# Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
|
#
|
|
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
|
|
|
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
|
|
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
|
|
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
|
|
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
|
|
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
|
|
|
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
|
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|