1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-15 16:39:26 +08:00

129 Commits

Author SHA1 Message Date
Marc Chevrier
45ed175f08 list(INSERT): restore old behavior
Fixes: #25191
2023-08-17 12:07:41 +02:00
Marc Chevrier
87fe031a07 cmList class: various enhancements 2023-04-29 09:54:22 +02:00
Marc Chevrier
e8c581606d list(): rely on cmList class
Fixes: #24549
2023-04-08 12:55:42 +02:00
Ben Boeckel
aa3649eb04 clang-tidy: fix performance-unnecessary-copy-initialization lints 2022-05-24 09:09:44 -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
Nick Muggio
7dd3e99270 cmListCommand: Handle invalid FOR selector ranges
Fixes crashes involving invalid ranges specified in list(TRANSFORM ...
FOR ...) calls.
* Report error when step is not positive
* Report error when start is after stop

Fixes: #22985
2021-12-08 20:54:04 -05:00
Sean McBride
5ba6e8ac59 Source: Replace most calls to sprintf with snprintf 2021-10-25 18:23:13 -04:00
Sean McBride
37859e3244 Source: Fix clang -Wimplicit-fallthrough warnings 2021-09-28 10:53:54 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
vvs31415
12624ebd7e Source: Reduce c_str() usage 2021-03-13 07:36:07 -05:00
Ben Boeckel
79eaa908dc cmListCommand: add a policy for failing on invalid indicies 2021-02-18 08:30:55 -05:00
Ben Boeckel
1f1fdff7fa cmListCommand: prefer strtol to atoi
This allows for detecting errors.
2021-02-18 08:30:55 -05:00
Ben Boeckel
9934a97642 cmListCommand: refactor out index argument parsing
This is in preparation for detecting errors in index argument syntax.
2021-02-16 10:43:43 -05:00
Asit Dhal
38e2299fc8 list(REMOVE_ITEM): Make removal of an empty item a no-op.
Fixes: #21663
2021-01-12 08:27:40 +01:00
Oleksandr Koval
209daa20b2 Code style: add missed explicit 'this->'
CMake uses explicit 'this->' style. Using custom clang-tidy check we can
detect and fix places where 'this->' was missed.
2021-01-05 14:32:36 +02:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Marc Chevrier
8d4a9ee398 Refactoring: rename "cm_static_string_view.hxx" as <cmext/string_view> 2020-04-30 09:53:27 +02:00
Marc Chevrier
aacd4e4a90 Refactoring: add cm::contains to <cmext/algorithm> 2020-04-17 10:00:03 +02:00
Johnny Jazeix
da99eca1e7 list: add NATURAL sorting on SORT sub-command
Fixes: #20563
2020-04-13 18:26:28 +02:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Marc Chevrier
c688b401d3 cmstd: Modernize CMake system headers
Provide a standardized way to handle the C++ "standard" headers
customized to be used with current CMake C++ standard constraints.
Offer under directory `cm` headers which can be used as direct
replacements of the standard ones.  For example:

    #include <cm/string_view>

can be used safely for CMake development in place of the `<string_view>`
standard header.

Fixes: #19491
2019-09-20 10:01:37 -04:00
Asit Dhal
9dba84cfa5 Refactor: Use cmStrCat to construct error strings
Replace string construction using std::stringstream with cmStrCat and
cmWrap.
2019-09-18 14:18:46 -04:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Regina Pfeifer
d25a5a7ec9 clang-tidy: modernize-use-auto
Set the MinTypeNameLength option to an impossibly high value in order
to limit the diagnostics to iterators.  Leave new expressions and cast
expressions for later.
2019-09-10 22:21:41 +02:00
Regina Pfeifer
62e5f72289 clang-tidy: Replace typedef with using 2019-09-03 13:21:26 -04:00
Brad King
de0a2354fc IWYU: Add missing cstddef includes for size_t and nullptr_t
The IWYU tool we use for CI now diagnoses these.
2019-09-03 11:46:52 -04:00
Brad King
37c671570c Merge topic 'source_sweep_ostringstream_single'
3b2b02825d Source sweep: Replace std::ostringstream when used with a single append

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3726
2019-08-26 10:49:10 -04:00
Brad King
bd3fb4c462 Merge topic 'list-subcommand-table'
b14bcd9123 cmListCommand: Use cmSubcommandTable

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3723
2019-08-26 10:43:06 -04:00
Sebastian Holtermann
3b2b02825d Source sweep: Replace std::ostringstream when used with a single append
This replaces `std::ostringstream`, when it is written to only once.
If the single written argument was numeric, `std::to_string` is used instead.
Otherwise, the single written argument is used directly instead of the
`std::ostringstream::str()` invocation.
2019-08-23 18:52:33 +02:00
Regina Pfeifer
b14bcd9123 cmListCommand: Use cmSubcommandTable 2019-08-22 22:55:58 +02:00
Sebastian Holtermann
9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00
Brad King
130dbe4a5d Merge topic 'cmCommand_refactor'
6ab28b9413 cmCommand refactor: cmStringCommand
36f32d3604 cmCommand refactor: cmSetPropertyCommand
7c83c19205 cmCommand refactor: cmSetDirectoryPropertiesCommand
9413952c42 cmCommand refactor: cmCMakePolicyCommand
07ea93de54 cmCommand refactor: cmWriteFileCommand
ca3b9186bb cmCommand refactor: cmVariableWatchCommand
b1acc711f4 cmCommand refactor: cmRemoveCommand
413a960391 cmCommand refactor: cmCMakeHostSystemInformationCommand
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3673
2019-08-22 10:25:09 -04:00
Brad King
337be1507d Merge topic 'isolate-declarations'
d331021255 clang-tidy: isolate declarations for readability

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3704
2019-08-22 10:23:34 -04:00
Regina Pfeifer
d331021255 clang-tidy: isolate declarations for readability 2019-08-21 00:20:49 +02:00
Gabor Bencze
e0b7ff4af2 cmCommand refactor: cmListCommand 2019-08-20 14:42:19 -04:00
Regina Pfeifer
2dfc52675c cmAlgorithms: Add cmContains
Also, use the new function where applicable.
2019-08-19 20:01:39 +02:00
Sebastian Holtermann
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Brad King
bbf4a5771f Merge topic 'tidy_inefficient_string'
18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3648
2019-08-07 11:54:53 -04:00
Sebastian Holtermann
18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation
Enables the clang-tidy test performance-inefficient-string-concatenation
and replaces all inefficient string concatenations with `cmStrCat`.

Closes: #19555
2019-08-05 17:21:00 +02:00
Sebastian Holtermann
7fbcc16dcd cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize
This adds the following functions to `cmStringAlgorithms`:

- `cmIsSpace`
- `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`)
- `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`)
- `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to
  accept `cm::string_view`)
2019-08-05 11:25:30 +02:00
Sebastian Holtermann
f71f7ce3f0 cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.h
This adds the `cmStringAlgorithms.h` header and moves all string functions
from `cmAlgorithms.h` to `cmStringAlgorithms.h`.
2019-07-29 21:13:56 +02:00
Sebastian Holtermann
e91bfe440c cmMakefile: Let AddDefinition accept a value as cm::string_view
This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value
argument instead of a `const char *`.

Benefits are:
- `std::string` can be passed to `cmMakefile::AddDefinition` directly without
  the `c_str()` plus string length recomputation fallback.
- Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at
  compile time.

In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid
`std::string::c_str` calls and the `std::string` is passed directly.
Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might
be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
2019-07-24 11:11:25 +02:00
Marc Chevrier
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx 2019-07-14 15:37:30 +02:00
Brad King
71fbebd1dc IWYU: Fix handling of <memory> standard header
An old workaround for `std::allocator_traits<>::value_type` lints from
IWYU on `std::vector<>` usage breaks IWYU's handling of `<memory>`.
Convert the workaround to use the same approach we already use for a
workaround of `std::__decay_and_strip<>::::__type` lints.  Then update
the `<memory>` inclusions to follow the now-correct IWYU lints.
2019-07-10 11:48:56 -04:00
Alex Turbov
822abf1265
list(POP_FRONT): Fix always assigning first item to output vars
Fixes: #19436
2019-06-30 13:15:29 +03:00
Brad King
a4d99e4dec Merge topic 'cmrange-improvements'
b8031308f3 cmRange: Add unit tests
a8d51ef8b7 cmRange: Add functions filter and transform
da4773e8b8 cmRange: Add functions all_of, any_of, none_of
17a367e77f cmRange: Stylistic cleanup
9eb0e73f46 cmRange: Move to dedicated header file

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Artur Ryt <artur.ryt@gmail.com>
Merge-request: !2972
2019-02-25 08:03:01 -05:00
Regina Pfeifer
9eb0e73f46 cmRange: Move to dedicated header file 2019-02-21 08:24:25 -05:00
Alex Turbov
a84e509844 list: add sub-commands PREPEND, POP_BACK, POP_FRONT 2019-02-19 09:42:36 -05:00
Brad King
d75fec5a88 Merge topic 'tidy-use-equals-default'
094f01d0f0 cleanup: Prefer compiler provided special member functions
55671b41d2 clang-tidy: Use `= default`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Brad King <brad.king@kitware.com>
Merge-request: !2841
2019-01-29 14:07:24 -05:00
Regina Pfeifer
55671b41d2 clang-tidy: Use = default
Suppress some cases in `Source/cmGeneratorExpressionNode.cxx` and
`Source/cmUVHandlePtr.h` where a few older compilers require a
user-defined default constructor (with `{}`).
2019-01-25 06:44:32 -05:00