summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-10 14:11:07 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-02-10 14:11:13 (GMT)
commitfe5b2e8beb17ef119e447df6073dca0dabafaa54 (patch)
tree2ef2040916edd1728ce67276d763294bf43b71ca /Tests
parent5b480172c369eaec81bbae8305b418b9a48558d4 (diff)
parent41adfc6b041474f6985ab72efcfb02b2b64a6b8d (diff)
downloadCMake-fe5b2e8beb17ef119e447df6073dca0dabafaa54.zip
CMake-fe5b2e8beb17ef119e447df6073dca0dabafaa54.tar.gz
CMake-fe5b2e8beb17ef119e447df6073dca0dabafaa54.tar.bz2
Merge topic 'doc-if-AND-OR' into release-3.23
41adfc6b04 Help: Clarify precedence of AND and OR in 'if' conditions Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6970
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/if/AndOr-stdout.txt1
-rw-r--r--Tests/RunCMake/if/AndOr.cmake6
-rw-r--r--Tests/RunCMake/if/RunCMakeTest.cmake2
3 files changed, 9 insertions, 0 deletions
diff --git a/Tests/RunCMake/if/AndOr-stdout.txt b/Tests/RunCMake/if/AndOr-stdout.txt
new file mode 100644
index 0000000..9fd395b
--- /dev/null
+++ b/Tests/RunCMake/if/AndOr-stdout.txt
@@ -0,0 +1 @@
+-- OR and AND correctly evaluated left to right
diff --git a/Tests/RunCMake/if/AndOr.cmake b/Tests/RunCMake/if/AndOr.cmake
new file mode 100644
index 0000000..847d6f2
--- /dev/null
+++ b/Tests/RunCMake/if/AndOr.cmake
@@ -0,0 +1,6 @@
+# AND and OR are the same precedence
+if(1 OR 0 AND 0) # equivalent to ((1 OR 0) AND 0)
+ message(FATAL_ERROR "AND incorrectly evaluated before OR")
+else()
+ message(STATUS "OR and AND correctly evaluated left to right")
+endif()
diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake
index 6baa840..de9cb57 100644
--- a/Tests/RunCMake/if/RunCMakeTest.cmake
+++ b/Tests/RunCMake/if/RunCMakeTest.cmake
@@ -17,3 +17,5 @@ run_cmake(IncompleteMatchesFail)
run_cmake(TestNameThatExists)
run_cmake(TestNameThatDoesNotExist)
+
+run_cmake_script(AndOr)