Commit Graph

154 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
Alex Turbov
e947e7b6e2 cmListFileCache: use cmStrCat instead of string stream 2024-07-23 10:11:27 -04:00
Alex Turbov
55a4a585fa cmListFileParser: use unique_ptr to own cmListFileLexer instance 2024-07-23 10:10:13 -04:00
Alex Turbov
63f8134744 cmListFileCache: convert cmListFileParser from struct to class 2024-07-23 10:09:21 -04:00
Alex Turbov
1bf4900df7 cmListFileCache: avoid redundant operator<< calls
Also, remove unneeded `clang-format off` comments.
2024-07-23 10:02:20 -04:00
Alex Turbov
459c01d520 cmListFileCache: move cmListFileParser into an anonymous namespace
Avoid the `cmListFileParser` methods intermixed with the `cmListFile`
methods.
2024-07-23 10:01:25 -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
44a2f3f332 Add new flow-control commands for variables and policies scopes management
Add block() and endblock() commands offering the capability to create
new scopes for variables and/or policies.

Fixes: #20171
2022-08-22 16:25:53 +02:00
FeRD (Frank Dana)
98a10290a8 cmSystemTools: Fix 'ErrorOccurred' spelling
Rename the booleans 's_ErrorOccured' and 's_FatalErrorOccured' to
's_ErrorOccurred' and 's_FatalErrorOccurred', respectively.

Rename the getters and setters to 'Get[Fatal]ErrorOccurred' and
'Set[Fatal]ErrorOccurred', and fix all uses across the codebase.
2022-06-13 09:05:24 -04:00
Ben Boeckel
a5f8cbe8b1 clang-tidy: address modernize-use-default-member-init lints 2022-05-24 09:09:43 -04:00
Brad King
11cc728e75 cmConstStack: Factor out of cmListFileBacktrace
This presents value semantics for a stack of constant values.
Internally it shares ownership to avoid copies.  Previously
this was implemented by `cmListFileBacktrace` explicitly,
but the approach can be re-used for other kinds of stacks.
2022-04-02 05:55:31 -04:00
Brad King
9123193758 cmListFileBacktrace: Clarify call sites that only push a file path
This removes the last part of the `cmListFileBacktrace` interface
that needs to know the type of data in its stack.
2022-04-01 10:18:46 -04:00
Braulio Valdivielso Martinez
8e1e97ccca Trace: include line_end field in json-v1 format
After !6954 got merged, it has become easier for tools to get
full stack-traces for runtime traces of a CMake program. The trace
information already included in the JSON objects (line number, source
file path) allows tools that display these stack traces to print the
CMake source code associated to them. However, CMake commands may
spawn multiple lines, and the JSON information associated to a trace
only contains the line in which the command started, but not the one
in which it ended. If tools want to print stack traces along the
relevant source code, and they want to print the whole command
associated to the stack frame, they will have to implement their own
CMake language parser to know where the command ends.

In order to simplify the life of those who want to write tooling for
CMake, this commit adds a `line_end` field to the json-v1 trace
format. If a given command spans multiple lines, the `line_end` field
will contain the line of the last line spanned by the command (that of
the closing parenthesis associated to the command).
2022-02-09 13:30:11 -05:00
Marc Chevrier
4b55828a9f cmExpandListWithBacktrace: add handling of empty elements. 2022-02-06 14:32:24 +01:00
Brad King
0386641142 cmListFileCache: Rename FromCommandContext to FromListFileFunction
Accept a `cmListFileFunction` instead of a `cmCommandContext`.
2022-01-25 08:39:52 -05:00
Brad King
d0ceb409ff cmListFileBacktrace: Remove unused "Depth" method 2021-12-08 10:31:48 -05:00
Brad King
7b677dbb92 cmListFileBacktrace: Remove unused "bottom" entry
All uses of `GetBottom` by clients have been removed, so drop the
method and its supporting infrastructure.
2021-12-08 10:03:48 -05:00
Brad King
3d378541bb cmMessenger: Adopt backtrace printing functions
Move backtrace printing functions from `cmListFileBacktrace` over to
`cmMessenger`, their primary caller.  Thread `cmMessenger` instances
through APIs needed to update other call sites.
2021-12-08 10:03:48 -05:00
Brad King
6c440ea3ce cmake: Model normal and try-compile project kinds explicitly
Construct with the project kind instead of mutating state after
construction.
2021-07-12 12:21:52 -04:00
Brad King
4cb6a53bf5 cmListFileCache: Simplify relative path conversion in backtraces
Printing paths to CMake input files does not need to use the
generator-wide relative path conversion rules because we are not
actually generating a relative path for the build system that needs to
be consistent with anything else.  Instead, simply print a relative path
if it does not need to start in `../`, and otherwise an absolute path.
2021-05-17 10:03:33 -04:00
Brad King
ba7b939831 cmStateDirectory: Rename ConvertToRelPathIf{Not => }Contained
The "Not" in the method name is backward from its logic.
2021-05-12 15:53:37 -04:00
Matt Jaeger
2fe39dc306 cmake: Fix loading CMake sources from long paths on Windows
Pass a Windows extended path to the lexer so it can open long paths.
2021-03-25 15:49:48 -04:00
Ben Boeckel
808b17b120 clang-tidy: fix readability-make-member-function-const warnings 2021-01-27 08:45:45 -05: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
Kyle Edwards
12f6e37eb7 cmListFileCache: Enforce proper nesting of flow control statements
Fixes: #19153
2020-10-22 11:40:48 -04:00
Oleksandr Koval
e614528ad1 cmListFileCache: Make cmListFileFunction a shared pointer
Passing cmListFileFunction everywhere by-value involves big overhead.
Now cmListFileFunction stores std::shared_ptr to the underlying data.
2020-10-01 14:28:03 +03:00
Brad King
e8b0359a43 cmake_language: Add signature to DEFER calls to later times
Fixes: #19575
2020-09-29 17:12:33 -04:00
Cristian Adam
598b676b5e cmake_command: Add command to EVAL a CMake script as a string 2020-03-03 08:42:13 -05: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
Brad King
175d8c4bf6 clang-tidy: Resolve performance-unnecessary-value-param diagnostics
Fix diagnostics that appear on macOS with clang-tidy-8.  Suppress cases
where we intentionally take an argument by value to let the caller
choose whether to copy or move.
2019-09-09 13:51:23 -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
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Bartosz Kosiorek
3475e2728b cmListFileCache: When missing ending ) print starting line instead of last one
Fixes: #19301
2019-06-03 10:03:53 -04:00
Albert Astals Cid
ae5e97a005 Delete some default constructors and assignment operators
They are unused, but if someone used them they would lead to
problems since they would copy the internal raw pointers
and the destructor would cause double delete
2019-02-15 07:25:47 -05:00
Brad King
60c06620a6 Merge topic 'cmoutputconverter-simplify'
b6a957c969 cmOutputConverter: move ConvertToRelativePath to cmStateDirectory.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2831
2019-01-29 09:18:42 -05:00
Bruno Manganelli
b6a957c969 cmOutputConverter: move ConvertToRelativePath to cmStateDirectory. 2019-01-27 15:48:57 +00:00
Brad King
c3203bf316 Silence -Wcomma warning
We use a comma-in-paren expression to evaluate multiple statements
in a condition.  Clang warns that this may be incorrect.  Follow
its suggestion to cast all but the last expression to `void` to
silence the warning.
2019-01-23 13:20:14 -05:00
Regina Pfeifer
5a0784ddea clang-tidy: Pass by value 2019-01-22 13:03:04 -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
Vitaly Stakhovsky
b2c85cb698 cmLocalGenerator::AppendDefines: Remove const char* overloads
Accept const std::string& arguments only
2018-10-26 06:54:32 -04:00
Brad King
e022e2d873 cmListFileCache: Add ExpandListWithBacktrace helper 2018-10-17 14:20:34 -04:00
Brad King
f1dd0eeaaf cmListFileCache: Add wrapper template for values with a backtrace 2018-10-17 14:20:34 -04:00
Brad King
6c2af9d302 cmListFileCache: Add missing assertion in backtrace Top method
We can only get the top of a stack that has at least one call.
Update the method's comment accordingly.
2018-09-26 06:32:21 -04:00
Brad King
22aa6b67b4 cmListFileCache: Refactor cmListFileBacktrace internals
Replace use of raw pointers and explicit reference counting with
`std::shared_ptr<>`.  Use a discriminated union to store either the
bottom level or a call/file context in each heap-allocated entry.
This avoids storing a copy of the bottom in every `cmListFileBacktrace`
instance and shrinks the structure to a single `shared_ptr`.
2018-09-24 17:29:15 -04:00
Florian Jacomme
b1a05d6c76 Revise implementation of case-insensitive command names
Store both the as-written and lower-case command names and use
the latter to avoid case-insensitive string comparisons.

With this I obtain 2-6% speed increase (on Windows) for the configure
step with no significant changes in memory usage.  A case-insensitive
comparison is a lot slower than just calling `==` because the operator
will use things like memcmp, so prefer the latter.

The `cmSystemTools::LowerCase` function allocates a new string each time
it is called, so before this change we were allocating in:

* cmMakefile::Configure two times for each function
  (to look for `cmake_minimum_required` and `project`)
* cmMakefile::ExecuteCommand twice by function by calling
  cmState::GetCommand and copying the name

Now we are only allocating once by function instead of four.
2018-05-22 10:56:24 -04:00
Pavel Solodovnikov
c85bb007df Reduce allocation of temporary values on heap.
- Use `std::move` while inserting temporary results into vectors.
- Change `push_back` to `emplace_back` where appropriate.
2018-01-26 13:24:45 +03:00
Justin Berger
39c2feaf8c misc: Added utility method to allow working with stacks 2017-11-01 11:32:11 -06:00
Daniel Pfeifer
ca2233e31f IWYU: Mark cmConfigure.h with pragma: keep
Also remove `#include "cmConfigure.h"` from most source files.
2017-08-26 07:41:04 +02:00