summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/if/RunCMakeTest.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Help: Document behavior of if(EXISTS,IS_DIRECTORY) for empty pathsscivision2023-01-241-0/+1
| | | | | | | | | | Document and add explicit tests for empty string input: `if(EXISTS "")` and `if(IS_DIRECTORY "")` are always false. This avoids need for users to do extra checks due to CMake non-short-circuit logic as below: if("${p}") if(EXISTS "${p}")
* Help: Clarify precedence of AND and OR in 'if' conditionsBrad King2022-02-091-0/+2
| | | | | | | | | | | | The wording update in commit b74819e4fe (Help: Format 'if' command documentation, 2013-12-18, v3.0.0-rc1~227^2~1) incorrectly implied that `AND` has higher precedence than `OR`. Although this is common in many languages, it has never been true in CMake's implementation. Revise the wording to clarify the precedence. Add a test case demonstrating the order. Fixes: #23207
* Fix: Regression in the `cmConditionEvaluator::HandleLevel0`Alex Turbov2021-08-091-0/+2
| | | | | | | | As reported in the BUG #22524, mismatched parenthesis reported differently for `while()` and `if()`. The problem was in the double loop (over "handlers" and the arguments), where the outer loop didn't check the result of the running handler.
* Refactor: Introduce `cmArgumentList` container classAlex Turbov2021-08-031-0/+2
| | | | | | | | | | | | | | | | | The `cmArgumentList` has been turned into a class (forward declared in the header). It inherits from the `std::list` (yeah, but we don't intend to store polymorphic classes in it). In addition to the standard methods, now it's possible to move `HandlePredicate` (renamed to `ReduceOneArg`) and `HandleBinaryOp` (renamed to `ReduceTwoArgs`) as its members. Additionally, iterators managements (`IncrementArguments`) have been refactored into two separate classes mimicking iterators. This also allows having a uniform `for` loop and concentrates the logic of iterators advancing in it instead of the loop's body. The arguments processing algorithms operate with "windows" over a collection of arguments. Hence there are two kinds of "iteration windows" -- allowing to observe 2 or 3 elements per loop iteration. These iteration "windows" also passed to reducers.
* cmIfCommand: Reject duplicate else() and misplaced elseif()Gregor Jasny2017-03-221-0/+4
| | | | Closes: #14335
* cmConditionEvaluator: Fix matching of `CMAKE_MATCH_*` values (#15944)Brad King2016-02-011-0/+2
| | | | | | | | | | | While evaluating `if(MATCHES)` we get a `const char*` pointer to the string to be matched. On code like if(CMAKE_MATCH_COUNT MATCHES "Y") the string to be matched may be owned by our own result variables. We must move the value to our own buffer before clearing them. Otherwise we risk reading freed storage.
* if: Add "TEST <test>" conditionMatt McCormick2015-08-031-0/+3
| | | | | | | | if(TEST TestNameThatExists) will return true if a test with the name TestNameThatExists has been added with add_test. The syntax is similar to if(TARGET TargetName). Since use of "TEST" as an argument to if() could previously be interpreted as a non-keyword argument, add policy CMP0064 to treat it as a keyword as NEW behavior.
* Tests: Move command failure cases into RunCMake infrastructureBrad King2015-07-141-0/+1
| | | | | | | Move failure cases from the CMake.{If,List,While,GetProperty} tests over to the RunCMake.{if,list,while,get_property} tests to use the more modern infrastructure. This also avoids using REGEX_ESCAPE_STRING to try to regex-match full paths.
* if(): Test the effect of cmMakefileCall use in elseif() handling.Stephen Kelly2015-05-181-0/+1
|
* if: Add test for IS_DIRECTORYBrad King2013-05-281-0/+4
Add a RunCMake.if test to cover if() command behavior. Start with a test for IS_DIRECTORY cases with an existing directory and a long path, both with a trailing slash.