Commit Graph

131 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
Alex Turbov
d34971f455 Refactor: Eliminate redundant std::to_string as arg of cmStrCat
Plus optimize some other string operations in the modified files.
2025-01-26 04:03:38 +04: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
Marc Chevrier
4fc322bab4 AddCacheEntry: Suppress raw pointer usage 2023-05-30 16:41:59 +02:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Brad King
0a48d8fe5c ConfigureLog: De-duplicate event backtrace and check key generation
All event kinds have these fields, so centralize their implementation.
2023-02-01 09:32:42 -05:00
Brad King
48292c8624 try_compile: Record stack of in-progess checks in configure log
Many `try_compile` and `try_run` calls occur inside check modules
between `message(CHECK_START)` and `message(CHECK_{PASS,FAIL})` pairs.
Add a field to configure log entries to report this context.

Issue: #23200
2023-01-16 17:18:07 -05:00
Brad King
d4bf7d80c6 try_compile: Add a NO_LOG option to skip recording in the configure log 2023-01-16 17:16:12 -05:00
Brad King
5cd5c8cac5 Merge branch 'backport-try_run-cross-compile' into try_run-cross-compile 2023-01-12 13:55:57 -05:00
Brad King
0191e8b512 try_run: Do not require unrequested stdout/stderr when cross-compiling
Since commit 048a02d5bb (ConfigureLog: Log try_compile and try_run
checks, 2022-11-23) we always capture the stdout/stderr for logging.
When cross-compiling, do not require `__TRYRUN_OUTPUT_STD{OUT,ERR}`
variables to be populated just for the logging.
2023-01-12 13:55:52 -05:00
Brad King
2f85ec0a37 try_run: Avoid crash in keyword-dispatched signature when cross-compiling
Since commit aa9220d3a0 (try_compile: Add keyword-dispatched signature,
2022-09-02, v3.25.0-rc1~178^2) the `DoNotRunExecutable` code path may be
reached with no single source-file argument.  Do not assume it exists.

Fixes: #24295
2023-01-12 11:04:16 -05:00
Brad King
d811d86fd7 FileAPI: Add "configureLog" object kind
Provide clients with a way to get a known set of configure log event
versions.

Issue: #23200
2022-12-17 08:52:04 -05:00
Brad King
6c40e0b25e ConfigureLog: Version individual events instead of the whole log
In order to support multiple log versions without buffering the
entire log, move versioning to the level of individual events.
Multiple versions of an event may then be logged consecutively.

Issue: #23200
2022-12-16 10:12:25 -05:00
Matthew Woehlke
048a02d5bb ConfigureLog: Log try_compile and try_run checks
Add configure log events for `try_compile` and `try_run` results.

Issue: #23200
2022-12-16 10:12:25 -05:00
Brad King
8d29a0bda6 cmTryRunCommand: Factor out stdout/stderr capture conditions 2022-12-14 11:42:29 -05:00
Brad King
fdda4095a3 cmCoreTryCompile: Return more semantic information from compile step
Update the `TryCompileCode` signature to allow callers to distinguish
between administrative failures and a compilation failure.  Return
results in a structure to which more information can be added later.
2022-12-14 11:42:29 -05:00
Matthew Woehlke
09b3051524 try_compile: Add NO_CACHE option (also try_run)
Add NO_CACHE option to try_compile and try_run, which places the results
in regular, rather than cache, variables.

Issue: #22799
2022-09-28 13:41:11 -04:00
Matthew Woehlke
f976800577 try_compile: More useful error if insufficient arguments
Tweak try_compile and try_run to give a more informative error (rather
than "unknown error") when given an insufficient number of arguments.
2022-09-15 13:34:30 -04:00
Brad King
6b427d8da9 cmCoreTryCompile: Port to cmArgumentParser 2022-08-02 12:54:56 -04:00
Brad King
067ba3a2bd cmCoreTryCompile: Move target type selection logic to try_compile
This is specific to `try_compile` since `try_run` always needs an
executable.  Move the logic out of the common code path.
2022-08-02 08:04:21 -04:00
Brad King
781e1b191a cmCoreTryCompile: Simplify TryCompileCode return type
The return value is only used as a boolean, so use `bool`.
2022-08-02 08:04:20 -04:00
Brad King
e73c8eaff2 cmTry{Compile,Run}Command: Port away from legacy cmCommand
Convert the command entry points to free functions.
2022-07-26 15:09:48 -04:00
Patrick Northon
a2cd0687db try_run: Add RUN_OUTPUT_STDOUT_VARIABLE and RUN_OUTPUT_STDERR_VARIABLE. 2022-07-08 15:49:02 -04:00
Ben Boeckel
64ea1a272c messages: remove screamake from comments and errors 2022-04-25 14:29:17 -04:00
Sean McBride
5ba6e8ac59 Source: Replace most calls to sprintf with snprintf 2021-10-25 18:23:13 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Asit Dhal
5af38a11ce try_run: Allow to set working directory
Fixes: #17634
2021-02-03 08:42:05 +01:00
Vitaly Stakhovsky
11425041f0 cmMakefile::GetDefinition: return cmProp 2020-09-02 07:27:32 -04:00
Vitaly Stakhovsky
b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Vitaly Stakhovsky
bd89133543 cmState::GetCacheEntryValue: return cmProp 2020-03-17 12:09:20 -04: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
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Sebastian Holtermann
aaf59120bf Source sweep: Replace cmExpandList with the shorter cmExpandedList
This replaces the code pattern
```
std::vector<std::string> args;
cmExpandList(valueStr, args, ...)
```
with
```
std::vector<std::string> args = cmExpandedList(valueStr, ...)
```
2019-08-23 17:07:49 +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
Rolf Eike Beer
da26b3be89 avoid adding multiple consecutive string literals to std::string
While at it change some single character additions to be of type char.
2019-08-18 14:22:11 +02:00
Sebastian Holtermann
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +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
Vitaly Stakhovsky
23e8364aed Source: std::string related cleanup 2019-05-15 10:20:05 -04: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
Vitaly Stakhovsky
4e315e9449 cmSystemTools: More functions accept std::string params 2019-02-20 14:53:39 -05:00
Brad King
4b37b4f1bb Merge topic 'modernize-for-loops'
01b2d6ab74 Modernize: Use ranged for-loops when possible
15bdbec017 cmAlgorithms: Make cmRange advance/retreat safe for rvalues

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Merge-request: !2901
2019-02-11 08:08:22 -05:00
Artur Ryt
01b2d6ab74 Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.

Fixes: #18858
2019-02-07 22:39:05 +01:00
Vitaly Stakhovsky
65baaa0e37 cmSystemTools::RunSingleCommand: Accept std::string argument 2019-02-06 11:02:10 -05:00
Brad King
40745ad35a Merge topic 'cmake-files-directory'
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h

Acked-by: Kitware Robot <kwrobot@kitware.com>
Rejected-by: vvs31415 <vstakhovsky@fastmail.com>
Merge-request: !2655
2019-01-25 08:01:26 -05:00
Vitaly Stakhovsky
99337d345b cmSystemTools::Error(): new overload accepting std::string 2019-01-23 10:19:30 -05:00
Bruno Manganelli
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h 2019-01-21 15:34:16 +00:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
Bruno Manganelli
cc2a5261f8 Factor out enum MessageType into dedicated header
Reduce the number of files relying on `cmake.h`.
2019-01-16 08:16:31 -05:00
Marc Chevrier
29f9db5c63 try_compile/try_run: Add support for LINK_OPTIONS option. 2018-12-01 17:56:23 +01:00