summaryrefslogtreecommitdiffstats
path: root/Tests/GeneratorExpression
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-08-13 13:49:53 (GMT)
committerBrad King <brad.king@kitware.com>2012-08-15 15:44:49 (GMT)
commitebf05abda15967f8f50dcf132f7bf84472ca6337 (patch)
tree8f519862ee05d0f2b7d2ef34cfb281841a673461 /Tests/GeneratorExpression
parentcd3bd23266a4a6c00595134a17a8bdaea9e28af5 (diff)
downloadCMake-ebf05abda15967f8f50dcf132f7bf84472ca6337.zip
CMake-ebf05abda15967f8f50dcf132f7bf84472ca6337.tar.gz
CMake-ebf05abda15967f8f50dcf132f7bf84472ca6337.tar.bz2
Add boolean generator expressions
Add generator expressions that combine and use boolean test results: $<0:...> = empty string (ignores "...") $<1:...> = content of "..." $<AND:?[,?]...> = '1' if all '?' are '1', else '0' $<OR:?[,?]...> = '0' if all '?' are '0', else '1' $<NOT:?> = '0' if '?' is '1', else '1' These will be useful to evaluate (future) boolean query expressions and condition content on the results. Include tests and documentation.
Diffstat (limited to 'Tests/GeneratorExpression')
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt26
-rw-r--r--Tests/GeneratorExpression/check.cmake23
2 files changed, 49 insertions, 0 deletions
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
new file mode 100644
index 0000000..8d7d87d
--- /dev/null
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required (VERSION 2.8.8)
+project(GeneratorExpression NONE)
+
+add_custom_target(check ALL
+ COMMAND ${CMAKE_COMMAND}
+ -Dtest_0=$<0:nothing>
+ -Dtest_1=$<1:content>
+ -Dconfig=$<CONFIGURATION>
+ -Dtest_and_0=$<AND:0>
+ -Dtest_and_0_0=$<AND:0,0>
+ -Dtest_and_0_1=$<AND:0,1>
+ -Dtest_and_1=$<AND:1>
+ -Dtest_and_1_0=$<AND:1,0>
+ -Dtest_and_1_1=$<AND:1,1>
+ -Dtest_not_0=$<NOT:0>
+ -Dtest_not_1=$<NOT:1>
+ -Dtest_or_0=$<OR:0>
+ -Dtest_or_0_0=$<OR:0,0>
+ -Dtest_or_0_1=$<OR:0,1>
+ -Dtest_or_1=$<OR:1>
+ -Dtest_or_1_0=$<OR:1,0>
+ -Dtest_or_1_1=$<OR:1,1>
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
+ COMMAND ${CMAKE_COMMAND} -E echo "check done"
+ VERBATIM
+ )
diff --git a/Tests/GeneratorExpression/check.cmake b/Tests/GeneratorExpression/check.cmake
new file mode 100644
index 0000000..c40b847
--- /dev/null
+++ b/Tests/GeneratorExpression/check.cmake
@@ -0,0 +1,23 @@
+macro(check var val)
+ if(NOT "${${var}}" STREQUAL "${val}")
+ message(SEND_ERROR "${var} is \"${${var}}\", not \"${val}\"")
+ endif()
+endmacro()
+
+message(STATUS "config=[${config}]")
+check(test_0 "")
+check(test_1 "content")
+check(test_and_0 "0")
+check(test_and_0_0 "0")
+check(test_and_0_1 "0")
+check(test_and_1 "1")
+check(test_and_1_0 "0")
+check(test_and_1_1 "1")
+check(test_not_0 "1")
+check(test_not_1 "0")
+check(test_or_0 "0")
+check(test_or_0_0 "0")
+check(test_or_0_1 "1")
+check(test_or_1 "1")
+check(test_or_1_0 "1")
+check(test_or_1_1 "1")