Commit Graph

122 Commits

Author SHA1 Message Date
Kitware Robot 1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Kitware Robot 0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Brad King d9dd38cccf CMP0064: Remove support for OLD behavior 2025-01-22 10:40:55 -05:00
Brad King c283aafe62 CMP0057: Remove support for OLD behavior 2025-01-22 10:40:53 -05:00
Brad King 90d814f024 CMP0054: Remove support for OLD behavior 2025-01-20 09:46:55 -05:00
Brad King 98a59ba8ad CMP0012: Remove support for OLD behavior 2025-01-17 09:28:36 -05:00
Brad King 659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Vitaly Stakhovsky 1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Marc Chevrier 337bc5662c if(): add operators IS_READABLE, IS_WRITABLE and IS_EXECUTABLE.
Offers possibility to check for file or directory permissions.
2023-11-01 14:53:31 +01:00
Brad King 93ee2b369c Source: Fix -Wdangling-reference warnings exposed by gcc 13 2023-05-22 17:14:54 -04:00
Marc Chevrier e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Marc Chevrier be4b9e10af if command: Add PATH_EQUAL operator 2022-06-03 19:31:36 +02:00
Brad King 5ceed2bb28 Merge topic 'reduce-policy-eval-scope'
cb19a63499 cmConditionEvaluator: Reduce the scope of the CMP0064 evaluation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7287
2022-05-24 10:08:52 -04:00
Ben Boeckel 6ff03d463f clang-tidy: address google-readability-casting lints
At least those involving `static_cast`.
2022-05-24 09:09:43 -04:00
Alex Turbov cb19a63499 cmConditionEvaluator: Reduce the scope of the CMP0064 evaluation
When evaluatig conditions, avoid testing CMP0064 unless it's really needed
(Cuz most of the time it doesn't)
2022-05-23 09:08:51 -04:00
Sean McBride 37859e3244 Source: Fix clang -Wimplicit-fallthrough warnings 2021-09-28 10:53:54 -04:00
Sean McBride 907d098838 Source: Fix clang -Wextra-semi warnings 2021-09-28 09:59:24 -04:00
Marc Chevrier cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Marc Chevrier 7e154ebd59 cmSystemTools::VersionCompare: use std::string for arguments 2021-09-17 11:58:46 +02:00
Alex Turbov 61b33c3f4e Fix: Regression in the cmConditionEvaluator::HandleLevel0
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.
2021-08-09 21:05:09 +03:00
Marc Chevrier e5cd39ca80 cmProp: refactoring: transform alias in class
To handle safely the values used by CMake variables and properties,
introduce the class cmProp as a replacement from the simple pointer
to std::string instance.
2021-08-08 16:19:08 +02:00
Alex Turbov 54a70b3988 Refactor: Move version compare op table out of the function
It's static data and never changed.
2021-08-03 10:55:47 -04:00
Alex Turbov f37d6a3170 Refactor: Remove redundant checks for 0 and 1 literals
They are gonna be checked by `cmIsOn()` anyway.
2021-08-03 10:55:47 -04:00
Alex Turbov 00961a4782 Refactor: Copy exactly required count of args and avoid pop_back() 2021-08-03 10:55:47 -04:00
Alex Turbov 2a72cad9be Style: Better names of local vars for IN_LIST handler 2021-08-03 10:55:47 -04:00
Alex Turbov 0dd7795706 Refactor: Extract the logic of testing for special variable to func
Introduce `looksLikeSpecialVariable`. It makes `if()` blocks readable.
2021-08-03 10:55:47 -04:00
Alex Turbov 866b0595f6 Refactor: Introduce cmArgumentList container class
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.
2021-08-03 10:55:47 -04:00
Alex Turbov 51d9194a96 Refactor: Reduce one more condition checking on handling math compare 2021-08-03 10:55:46 -04:00
Alex Turbov 46810235e3 Refactor: Avoid ifelse if → … for compare operators
When trying to match one of compare operator key inside `if()` condition,
remember the index of matched operator. Later this index used to
select the operation to perform instead of strings compare again.
2021-08-03 10:55:46 -04:00
Alex Turbov 17af3baddd Refactor: Set const to cmConditionEvaluator::IsKeyword parameters 2021-08-03 10:55:46 -04:00
Alex Turbov 2b916606c5 Refactor: No need to move iterators after match
A handler's loop of all levels gonna restart after calls to
`HandlePredcate` or `HandleBinaryOp`... And the first action in the
loop is to setup iterators. So, no need to move 'em inside the
functions. Also, no need to pass iterators by reference.

Also, reorder parameters of both functions so iterators
followed after a reference to the newArgs container.
2021-08-03 10:55:46 -04:00
Alex Turbov 97d6bbcc01 Refactor: Replace std::to_string w/ more specialized bool2string 2021-08-03 10:55:46 -04:00
Alex Turbov 9721ab416f Refactor: Reorder MATCHES handler from top below to the fail-fast 2021-08-03 10:55:46 -04:00
Alex Turbov d4d44e86f6 Refactor: Reduce variables scope in HandleLevel2 2021-08-03 10:55:46 -04:00
Alex Turbov cc6cdacc18 Refactor: Simplify boolean to string result assignments 2021-08-03 10:55:46 -04:00
Alex Turbov e3c1dbe18b Refactor: Replace if block w/ boolean expression
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-08-03 10:55:45 -04:00
Alex Turbov 047f8321a0 Refactor: Avoid redundant operator<< on printing messages
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-08-03 10:55:45 -04:00
Alex Turbov 4de2a4a46d Refactor: Opt-out do+while loops and reduce nesting level in handlers
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-08-03 10:55:45 -04:00
Alex Turbov 78fcbb20cd Refactor: Remove reducible flag from handleLevelN() functions
The indicator that smth has been done is the `newArgs` size get
differ after an iteration.

Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-08-03 10:55:45 -04:00
Alex Turbov b0d6596399 Refactor: Make cmConditionEvaluator::IsTrue a bit more compact
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-08-03 10:55:30 -04:00
Alex Turbov 18bd6c98ea Refactor: Generalize policy checking in HandleLevel1
Also, move OLD policy checking out of the loop to evaluate it once.
2021-07-26 23:40:18 +03:00
Alex Turbov 8bc4a740d6 Refactor: When handle predicates, there is no need to check 2nd arg
Introduce an overload for `IncrementArguments()` w/ one iterator
and use it in the handler level 1.
2021-07-26 23:40:18 +03:00
Alex Turbov 9946ff6848 Refactor: Initialize args vector from iterators instead of copy
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-07-26 23:40:18 +03:00
Alex Turbov bf2fe90372 Refactor: Speedup predicates and binary operation
Before predicates and binary ops reducers use series of `if ()` blocks
to match the keywords. However, if matched the currect `arg` get replaced
with evaluation result, so further `if (<match-another-keyword>)`
is just wasting time/resources.

This patch introduce a chain of `if` → `else if` → ..., so after
first match the loop restarts w/ the next argument.
2021-07-26 23:40:18 +03:00
Alex Turbov 7bec39dc10 Style: Add empty lines to increase readability
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-07-26 23:40:18 +03:00
Alex Turbov 314538703a Refactor: Deduplicate code for AND and OR handling in if() command
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-07-26 23:40:18 +03:00
Alex Turbov 95fc27cedd Refactor: Rewrite parenthesis scanner to avoid ifs
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-07-26 23:40:18 +03:00
Alex Turbov 135c37bdd7 Refactor: Make HandleBinaryOp and HandlePredicate free functions 2021-07-26 23:40:18 +03:00
Alex Turbov 498c8c7773 Refactor: More auto and constness
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-07-26 23:40:18 +03:00
Alex Turbov 961df6cde6 Refactor: Make IncrementArguments() the free function
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2021-07-26 23:40:18 +03:00