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

94 Commits

Author SHA1 Message Date
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Ben Boeckel
c8c9d7de03 clang-tidy: fix bugprone-exception-escape lints 2022-05-24 09:09:44 -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
4959276c02 cmListFileCache: Remove cmCommandContext
Subsume it inside `cmListFileFunction`.
2022-01-25 08:40:41 -05: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
3c4fa4c892 cmListFileCache: Move cmListFileFunction earlier 2022-01-25 08:36:06 -05:00
Brad King
61c46c95ae cmListFileContext: Simplify explicit rule-of-five members 2021-12-08 10:31:55 -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
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
Brad King
0e59b45dfc cmListFileCache: Add explicit constructors
In order to construct with an initializer list in pure C++11, add
the explicit constructors.
2020-09-28 09:46:34 -04:00
Kitware Robot
bdca8b01d2 Modernize: Use #pragma once in all header files
#pragma once is a widely supported compiler pragma, even though it is
not part of the C++ standard. Many of the issues keeping #pragma once
from being standardized (distributed filesystems, build farms, hard
links, etc.) do not apply to CMake - it is easy to build CMake on a
single machine. CMake also does not install any header files which can
be consumed by other projects (though cmCPluginAPI.h has been
deliberately omitted from this conversion in case anyone is still using
it.) Finally, #pragma once has been required to build CMake since at
least August 2017 (7f29bbe6 enabled server mode unconditionally, which
had been using #pragma once since September 2016 (b13d3e0d)). The fact
that we now require C++11 filters out old compilers, and it is unlikely
that there is a compiler which supports C++11 but does not support
#pragma once.
2020-09-03 09:30:21 -04:00
Justin Goshi
cc96fb617b Add BTs helper to support multiple backtraces 2020-07-06 11:31:09 -07:00
Cristian Adam
598b676b5e cmake_command: Add command to EVAL a CMake script as a string 2020-03-03 08:42:13 -05:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04: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
Regina Pfeifer
094f01d0f0 cleanup: Prefer compiler provided special member functions 2019-01-25 06:45:00 -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
Regina Pfeifer
5a0784ddea clang-tidy: Pass by value 2019-01-22 13:03:04 -05:00
Regina Pfeifer
b2aa3aedea clang-tidy: Use default member initialization 2018-12-15 10:52:37 +01:00
Regina Pfeifer
32cb564bea clang-tidy: Remove redundant member initializations 2018-12-15 10:51:47 +01: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
3c8187f687 clang-tidy: restore 'misc-noexcept-move-constructor'
We disabled this in commit 1fe0d72eb6 (clang-tidy: exclude
'misc-noexcept-move-constructor', 2018-09-24) due to false positives.
Restore it and use a NOLINT comment to suppress them instead.
2018-09-26 06:38:52 -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
Justin Berger
39c2feaf8c misc: Added utility method to allow working with stacks 2017-11-01 11:32:11 -06:00
Daniel Pfeifer
b1ec5deaf1 Pass large types by const&, small types by value 2017-06-04 00:48:21 +02:00
Daniel Pfeifer
0d0995b7f8 cmListFileArgument: remove custom copy ctor 2017-04-21 21:50:45 +02:00
Daniel Pfeifer
1d829c862c Use quotes for non-system includes
Automate with:

git grep -l '#include <cm_' -- Source \
  | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g'

git grep -l '#include <cmsys/' -- Source \
  | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g'

git grep -l '#include <cm[A-Z]' -- Source \
  | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
2017-04-11 22:35:21 +02:00
Stephen Kelly
e6eecec761 cmListFileCache: Remove cmState header include
Include it in dependents which have previously relied on it
transitively.
2016-10-19 15:41:00 +02:00
Stephen Kelly
e0a84904eb cmState: Split auxiliary classes into separate files
Port dependents to the new locations as needed.

Leave behind a cmState.h include in cmListFileCache to reduce noise. It
is removed in a following commit.
2016-10-19 15:40:59 +02:00
Stephen Kelly
cde6eb6249 cmState: Port dependent code to new cmStateSnapshot name 2016-10-19 15:40:59 +02:00
Stephen Kelly
e32a6bdd99 cmListFileBacktrace: Add a method to retrieve the Bottom of a snapshot 2016-10-15 11:14:21 +02:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Daniel Pfeifer
efed6468ed fix a load of include-what-you-use violations 2016-09-03 08:04:56 -04:00
Daniel Pfeifer
3838a0d5fb make sure to include cmConfigure.h before cmStandardIncludes.h 2016-09-03 08:04:22 -04:00
Stephen Kelly
1462576bcb Parser: Port away from cmMakefile
It is an unneeded dependency.
2016-08-25 09:47:27 -04:00
Stephen Kelly
905e738ffe Parser: Out-of-line conditional code to cmMakefile
Simplify parser API.
2016-06-13 20:19:16 +02:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* 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.
2016-05-16 16:05:19 -04:00
Brad King
7c36d2067b cmListFileBacktrace: Refactor storage to provide efficient value semantics
Since commit v3.4.0-rc1~321^2~2 (Genex: Store a backtrace, not a pointer
to one, 2015-07-08) we treat cmListFileBacktrace instances as
lightweight values.  This was true at the time only because the
backtrace information was kept in the cmState snapshot hierarchy.
However, that forced us to accumulate a lot of otherwise short-lived
snapshots just to have the backtrace fields available for reference by
cmListFileBacktrace instances.  Recent refactoring made backtrace
instances independent of the snapshot hierarchy to avoid accumulating
short-lived snapshots.  This came at the cost of making backtrace values
heavy again, leading to lots of string coying and slower execution.

Fix this by refactoring cmListFileBacktrace to provide value semantics
with efficient shared storage underneath.  Teach cmMakefile to maintain
its call stack using an instance of cmListFileBacktrace.  This approach
allows the current backtrace to be efficiently saved whenever it is
needed.

Also teach cmListFileBacktrace the notion of a file-level scope.  This
is useful for messages about the whole file (e.g. during parsing) that
are not specific to any line within it.  Push the CMakeLists.txt scope
for each directory and never pop it.  This ensures that we always have
some context information and simplifies cmMakefile::IssueMessage.
Push/pop a file-level scope as each included file is processed.  This
supersedes cmParseFileScope and improves diagnostic message context
information in a few places.  Fix the corresponding test cases to expect
the improved output.
2016-04-18 09:21:19 -04:00