2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test SET
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
set (ZERO_VAR 0)
|
|
|
|
set (ZERO_VAR2 0)
|
2002-01-18 20:03:32 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(ZERO_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2001-08-23 21:57:45 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(ONE_VAR 1)
|
|
|
|
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
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
variable_requires(ONE_VAR
|
2002-01-18 20:03:32 +03:00
|
|
|
ONE_VAR_IS_DEFINED ONE_VAR)
|
|
|
|
|
2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test various IF/ELSE combinations
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT ZERO_VAR)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_NOT)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_NOT)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(NOT ONE_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_NOT2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_NOT2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(ONE_VAR AND ONE_VAR2)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_AND)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_AND)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(ONE_VAR AND ZERO_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_AND2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_AND2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(ZERO_VAR OR ONE_VAR2)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_OR)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_OR)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(ZERO_VAR OR ZERO_VAR2)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_OR2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_OR2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(STRING_VAR MATCHES "^CMake")
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_MATCHES)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_MATCHES)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(STRING_VAR MATCHES "^foo")
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_MATCHES2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_MATCHES2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(COMMAND "IF")
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_COMMAND)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_COMMAND)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if(COMMAND "ROQUEFORT")
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_COMMAND2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_COMMAND2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_EXISTS)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_EXISTS)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (EXISTS ${Complex_SOURCE_DIR}/roquefort.txt)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_EXISTS2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_EXISTS2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (IS_DIRECTORY ${Complex_SOURCE_DIR})
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_IS_DIRECTORY)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (NOT IS_DIRECTORY ${Complex_SOURCE_DIR}/VarTests.cmake)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_IS_DIRECTORY2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
set (SNUM1_VAR "1")
|
|
|
|
set (SNUM2_VAR "2")
|
|
|
|
set (SNUM3_VAR "1")
|
|
|
|
|
|
|
|
|
|
|
|
if (SNUM1_VAR LESS SNUM2_VAR)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_LESS)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SNUM2_VAR LESS SNUM1_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_LESS2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_LESS2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SNUM2_VAR GREATER SNUM1_VAR)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_GREATER)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SNUM2_VAR EQUAL SNUM1_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_EQUAL)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SNUM3_VAR EQUAL SNUM1_VAR)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_EQUAL)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_EQUAL)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SNUM1_VAR GREATER SNUM2_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_GREATER2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_GREATER2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
set (SSTR1_VAR "abc")
|
|
|
|
set (SSTR2_VAR "bcd")
|
|
|
|
|
|
|
|
if (SSTR1_VAR STRLESS SSTR2_VAR)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_STRLESS)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SSTR2_VAR STRLESS SSTR1_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRLESS2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_STRLESS2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SSTR2_VAR STRGREATER SSTR1_VAR)
|
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2012-08-13 21:47:32 +04:00
|
|
|
|
|
|
|
if (SSTR1_VAR STRGREATER SSTR2_VAR)
|
|
|
|
add_definitions(-DSHOULD_NOT_BE_DEFINED_STRGREATER2)
|
2012-08-13 21:50:14 +04:00
|
|
|
else ()
|
2012-08-13 21:47:32 +04:00
|
|
|
add_definitions(-DSHOULD_BE_DEFINED_STRGREATER2)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif ()
|
2002-05-27 18:29:04 +04:00
|
|
|
|
2002-01-20 05:24:55 +03:00
|
|
|
#
|
|
|
|
# Test FOREACH
|
|
|
|
#
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach (INDEX 1 2)
|
|
|
|
set(FOREACH_VAR${INDEX} "VALUE${INDEX}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2002-01-18 20:03:32 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(FOREACH_CONCAT "")
|
|
|
|
foreach (INDEX a;b;c;d;e;f;g)
|
2016-07-28 01:43:04 +03:00
|
|
|
string(APPEND FOREACH_CONCAT "${INDEX}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|