2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test SET
|
|
|
|
#
|
2001-08-23 21:57:45 +04:00
|
|
|
SET (ZERO_VAR 0)
|
2002-01-20 09:58:57 +03:00
|
|
|
SET (ZERO_VAR2 0)
|
2002-01-18 20:03:32 +03:00
|
|
|
|
2001-08-23 21:57:45 +04:00
|
|
|
IF(ZERO_VAR)
|
2002-01-18 20:03:32 +03:00
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED)
|
2001-08-23 21:57:45 +04:00
|
|
|
ELSE(ZERO_VAR)
|
2002-01-18 20:03:32 +03:00
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED)
|
2001-08-23 21:57:45 +04:00
|
|
|
ENDIF(ZERO_VAR)
|
|
|
|
|
|
|
|
SET(ONE_VAR 1)
|
2002-01-20 05:24:55 +03:00
|
|
|
SET(ONE_VAR2 1)
|
|
|
|
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
|
2001-08-23 21:57:45 +04:00
|
|
|
|
2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test VARIABLE_REQUIRES
|
|
|
|
#
|
2002-01-18 20:03:32 +03:00
|
|
|
VARIABLE_REQUIRES(ONE_VAR
|
|
|
|
ONE_VAR_IS_DEFINED ONE_VAR)
|
|
|
|
|
2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test various IF/ELSE combinations
|
|
|
|
#
|
2002-01-20 09:58:57 +03:00
|
|
|
IF(NOT ZERO_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT)
|
|
|
|
ELSE(NOT ZERO_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT)
|
|
|
|
ENDIF(NOT ZERO_VAR)
|
|
|
|
|
|
|
|
IF(NOT ONE_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_NOT2)
|
|
|
|
ELSE(NOT ONE_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_NOT2)
|
|
|
|
ENDIF(NOT ONE_VAR)
|
|
|
|
|
2002-01-19 04:32:06 +03:00
|
|
|
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)
|
|
|
|
|
2002-01-20 09:58:57 +03:00
|
|
|
IF(ONE_VAR AND ZERO_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_AND2)
|
|
|
|
ELSE(ONE_VAR AND ZERO_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND2)
|
|
|
|
ENDIF(ONE_VAR AND ZERO_VAR)
|
|
|
|
|
2002-01-19 04:32:06 +03:00
|
|
|
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)
|
|
|
|
|
2002-01-20 09:58:57 +03:00
|
|
|
IF(ZERO_VAR OR ZERO_VAR2)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR2)
|
|
|
|
ELSE(ZERO_VAR OR ZERO_VAR2)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_OR2)
|
|
|
|
ENDIF(ZERO_VAR OR ZERO_VAR2)
|
|
|
|
|
2002-01-19 04:32:06 +03:00
|
|
|
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")
|
|
|
|
|
2002-01-20 09:58:57 +03:00
|
|
|
IF(STRING_VAR MATCHES "^foo")
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES2)
|
|
|
|
ELSE(STRING_VAR MATCHES "^foo")
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES2)
|
|
|
|
ENDIF(STRING_VAR MATCHES "^foo")
|
|
|
|
|
2002-01-20 08:12:27 +03:00
|
|
|
IF(COMMAND "IF")
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND)
|
|
|
|
ELSE(COMMAND "IF")
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
|
|
|
ENDIF(COMMAND "IF")
|
|
|
|
|
2002-01-20 09:58:57 +03:00
|
|
|
IF(COMMAND "ROQUEFORT")
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_COMMAND2)
|
|
|
|
ELSE(COMMAND "ROQUEFORT")
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_COMMAND2)
|
|
|
|
ENDIF(COMMAND "ROQUEFORT")
|
|
|
|
|
2002-01-20 10:21:25 +03:00
|
|
|
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS)
|
|
|
|
ELSE(EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS)
|
|
|
|
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
|
|
|
|
|
|
|
IF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EXISTS2)
|
|
|
|
ELSE(EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EXISTS2)
|
|
|
|
ENDIF (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
|
|
|
|
|
2002-05-27 18:29:04 +04:00
|
|
|
SET (SNUM1_VAR "1")
|
|
|
|
SET (SNUM2_VAR "2")
|
2004-04-28 18:09:50 +04:00
|
|
|
SET (SNUM3_VAR "1")
|
|
|
|
|
2002-05-27 18:29:04 +04:00
|
|
|
|
|
|
|
IF (SNUM1_VAR LESS SNUM2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS)
|
|
|
|
ELSE (SNUM1_VAR LESS SNUM2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS)
|
|
|
|
ENDIF (SNUM1_VAR LESS SNUM2_VAR)
|
|
|
|
|
|
|
|
IF (SNUM2_VAR LESS SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_LESS2)
|
|
|
|
ELSE (SNUM2_VAR LESS SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_LESS2)
|
|
|
|
ENDIF (SNUM2_VAR LESS SNUM1_VAR)
|
|
|
|
|
|
|
|
IF (SNUM2_VAR GREATER SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER)
|
|
|
|
ELSE (SNUM2_VAR GREATER SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER)
|
|
|
|
ENDIF (SNUM2_VAR GREATER SNUM1_VAR)
|
|
|
|
|
2004-04-28 18:09:50 +04:00
|
|
|
IF (SNUM2_VAR EQUAL SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL)
|
|
|
|
ELSE (SNUM2_VAR EQUAL SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL)
|
|
|
|
ENDIF (SNUM2_VAR EQUAL SNUM1_VAR)
|
|
|
|
|
|
|
|
IF (SNUM3_VAR EQUAL SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_EQUAL)
|
|
|
|
ELSE (SNUM3_VAR EQUAL SNUM1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_EQUAL)
|
|
|
|
ENDIF (SNUM3_VAR EQUAL SNUM1_VAR)
|
|
|
|
|
2002-05-27 18:29:04 +04:00
|
|
|
IF (SNUM1_VAR GREATER SNUM2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_GREATER2)
|
|
|
|
ELSE (SNUM1_VAR GREATER SNUM2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_GREATER2)
|
|
|
|
ENDIF (SNUM1_VAR GREATER SNUM2_VAR)
|
|
|
|
|
|
|
|
SET (SSTR1_VAR "abc")
|
|
|
|
SET (SSTR2_VAR "bcd")
|
|
|
|
|
|
|
|
IF (SSTR1_VAR STRLESS SSTR2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS)
|
|
|
|
ELSE (SSTR1_VAR STRLESS SSTR2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS)
|
|
|
|
ENDIF (SSTR1_VAR STRLESS SSTR2_VAR)
|
|
|
|
|
|
|
|
IF (SSTR2_VAR STRLESS SSTR1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRLESS2)
|
|
|
|
ELSE (SSTR2_VAR STRLESS SSTR1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRLESS2)
|
|
|
|
ENDIF (SSTR2_VAR STRLESS SSTR1_VAR)
|
|
|
|
|
|
|
|
IF (SSTR2_VAR STRGREATER SSTR1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER)
|
|
|
|
ELSE (SSTR2_VAR STRGREATER SSTR1_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER)
|
|
|
|
ENDIF (SSTR2_VAR STRGREATER SSTR1_VAR)
|
|
|
|
|
|
|
|
IF (SSTR1_VAR STRGREATER SSTR2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_STRGREATER2)
|
|
|
|
ELSE (SSTR1_VAR STRGREATER SSTR2_VAR)
|
|
|
|
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_STRGREATER2)
|
|
|
|
ENDIF (SSTR1_VAR STRGREATER SSTR2_VAR)
|
|
|
|
|
2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test FOREACH
|
|
|
|
#
|
2002-01-18 20:03:32 +03:00
|
|
|
FOREACH (INDEX 1 2)
|
|
|
|
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
|
|
|
|
ENDFOREACH(INDEX)
|
|
|
|
|
2002-03-27 21:54:31 +03:00
|
|
|
SET(FOREACH_CONCAT "")
|
2002-12-12 18:10:34 +03:00
|
|
|
FOREACH (INDEX a;b;c;d;e;f;g)
|
2002-03-27 21:54:31 +03:00
|
|
|
SET(FOREACH_CONCAT "${FOREACH_CONCAT}${INDEX}")
|
|
|
|
ENDFOREACH(INDEX)
|
|
|
|
|
2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
|
|
|
|
#
|
2002-01-19 04:32:06 +03:00
|
|
|
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
|
2002-01-18 20:03:32 +03:00
|
|
|
|
|
|
|
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)
|
2002-01-20 05:24:55 +03:00
|
|
|
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
|
2002-01-18 20:03:32 +03:00
|
|
|
|
2002-01-20 08:12:27 +03:00
|
|
|
FIND_PATH(PATH_VAR "cmTestConfigure.h.in" ${Complex_SOURCE_DIR})
|
2002-01-18 20:03:32 +03:00
|
|
|
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
|