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

62 Commits

Author SHA1 Message Date
Brad King
241ee252ce IWYU: Update for Debian 12 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 12.
2023-07-28 09:14:08 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02: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
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
Brad King
df6b077625 cmake: Remove broken '--warn-unused-vars' option
This option has been broken since commit b9f9915516 (cmMakefile: Remove
VarUsageStack., 2015-05-17, v3.3.0-rc1~52^2).  That commit removed the
check that an initialized variable has actually been used and caused the
option to warn on every variable ever set.  This was not caught by the
test suite because the test for the feature only checked that warnings
appear when needed and not that they do not appear when not needed.

The option was never very practical to use.  Remove it to avoid the
runtime cost of usage tracking and checks for every variable (which we
were doing even when the option was not used).
2020-06-29 17:23:27 -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
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
Regina Pfeifer
62e5f72289 clang-tidy: Replace typedef with using 2019-09-03 13:21:26 -04:00
Brad King
be7807478c cmDefinitions: Reduce allocation of keys and values in MakeClosure
Use `cm::String` to store keys and values so that `MakeClosure` does
not need to allocate new copies of all of them.

Issue: #19581
2019-08-20 09:36:45 -04:00
Sebastian Holtermann
1a47d368d8 cmDefinitions: Cleanups and optimizations
In cmDefinitions:
- sort methods in source code by static or not static
- use `std::unordered_set<cm::string_view>` instead of `std::set<std::string>`
  for duplications tests.
2019-08-08 14:12:43 +02:00
Sebastian Holtermann
9b5cc42531 cmDefinitions: Remove const char* based Set method
- Removes `cmDefinitions::Set` method overload that takes a `const char*`
  value argument.
- Updates calls to `cmDefinitions::Set` to use the `cm::string_view` based
  version instead.
2019-07-24 11:11:25 +02:00
Sebastian Holtermann
e268840c0a cmDefinitions: Add Unset and cm::string_view based Set methods
- The `cmDefinitions::Def` struct is simplified by removing an unused
  constructor and the `std_string` type definition.  The std::string value
  becomes a member variable instead of being derived from.

- The `cmDefinitions::Unset` method is added that unsets a definition.
  It has the same functionality as calling `cmDefinitions::Set` with a
  `nullptr` value argument,

- The `cmDefinitions::Set` method gets an overloaded version that takes a
  `cm::string_view` as value argument.

- The originl `cmDefinitions::Set` method with `const char*` argument is
  refactored to either call the `cm::string_view` based `cmDefinitions::Set`
  overload or `cmDefinitions::Unset`, depending on whether the value
  `const char*` is a nullptr (`Unset`) or not (`Set`).
2019-07-24 11:11:25 +02: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
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
437d0c16c7 cmStateSnapshot::GetDefinition(): Return std::string const*
Expose std::string type used internally in cmDefinitions instead of const char*
2018-09-05 20:08:17 -04:00
Daniel Pfeifer
cbcfb79f9c Use C++11 unordered containers 2017-08-22 23:05:27 +02:00
Daniel Pfeifer
a5d85a31d9 cmDefinitions::Def: remove custom copy ctor 2017-04-22 00:48:18 +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
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05:00
Daniel Pfeifer
1a74e71906 Introduce CM_UNORDERED_MAP
Avoid duplicating switch among std::unordered_map, cmsys::hash_map, and
std::map.
2016-10-24 09:58:52 -04: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
Daniel Pfeifer
ea5477e43d Make C++ feature checks extensible
Turn the feature check for cxx11_unordered_map into a function such that
we can use it for other features as well.  Drop the 11 suffix, as we may
want to check features from other standards.
2016-06-27 10:37:40 -04: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
Stephen Kelly
25e04ddffe cmDefinitions: Implement in terms of cmLinkedTree.
Store the definitions in a cmLinkedTree in the cmMakefile.  This can
be moved to cmState and then the tree will provide snapshotting
possibilities.  It will also make the Closure copy created at
the start of each cmMakefile unnecesarry.
2015-08-23 17:08:53 +02:00
Stephen Kelly
b9f9915516 cmMakefile: Remove VarUsageStack.
Store usage information in the cmDefintions value instead.  We already
pay for the memory as padding in the Def struct, so we might as well
use it.
2015-05-19 22:36:53 +02:00
Stephen Kelly
2b09d9f346 cmMakefile: Remove VarInitStack.
In cmMakefile::PushScope, a copy of the closure of keys initialized
in the parent scope is made.  In PopScope, essentially the same copy
is inserted back into the parent.  That means a lot of duplication
of strings and a lot of string comparisons.  None of it is needed,
because the cmDefinitions keys already provide a canonical
representation of what is initialized.

The removal of the separate container also makes the variable handling
code more easy to reason about in general.

Before this patch, configuring llvm uses 200 KiB for the VarInitStack.
Overall peak memory consumption goes from 35.5 MiB to 35.1 MiB.
2015-05-19 22:36:53 +02:00
Stephen Kelly
f58c3774d1 cmMakefile: Mark definitions explicitly erased, even at top level.
Presumably the intention here is to attempt to optimize memory by not
storing what is not needed.  However, all keys need to be tracked
anyway to implement initialization tracking, and this special case
gets in the way of simplifying the implementation of that.

This doesn't change any observable effects because values set
to 0 are considered not to exist by the cmDefinitions API.
2015-05-19 22:36:52 +02:00
Stephen Kelly
ea7b962be2 cmMakefile: Raise variable in scope explicitly when needed.
The Get method implicitly pulls a copy of all variables into a local scope. This
is not necessary.
2015-05-19 22:36:51 +02:00
Brad King
594dd9b36a Merge topic 'use-std-unordered_map'
d7923b82 Use std::unordered_map instead of hash_map where available.
820777af Tests: Don't rely on ordering of targets in maps.
921d74d8 AutoGen: Don't iterate over a container while populating it.
2015-05-19 11:30:21 -04:00
Stephen Kelly
d7923b82ad Use std::unordered_map instead of hash_map where available. 2015-05-19 00:07:02 +02:00
Stephen Kelly
f170985e7a cmDefinitions: Make the ClosureKeys method static.
For consistency with all other closure-related methods.
2015-05-17 16:50:18 +02:00
Stephen Kelly
98c5c90361 cmDefinitions: Centralize knowledge of iterator type.
Currently we process a list of definitions, but that will change.
2015-05-17 16:50:18 +02:00
Stephen Kelly
7872201bf6 cmDefinitions: Remove internal MakeClosure method.
There is no need to have a separate method, or to pass an external
set to it.
2015-05-17 16:50:18 +02:00
Stephen Kelly
6c7dad41d9 cmDefinitions: Make Get method static. 2015-05-01 19:45:05 +02:00
Stephen Kelly
a7ce0c7bc0 cmDefinitions: Make GetInternal method static.
For some reason, using recursion here is faster to configure ParaView
than using a loop.  Probably some compiler optimization is inhibited
by using a loop.

Co-Author: Brad King <brad.king@kitware.com>
2015-05-01 19:44:35 +02:00
Stephen Kelly
191573f792 cmDefinitions: Remove Parent pointer.
All structural knowledge of the stack of scopes is now external.
2015-05-01 19:34:59 +02:00
Stephen Kelly
8b1745a1c5 cmDefinitions: Accept varStack iterators in Get API. 2015-05-01 19:34:59 +02:00
Stephen Kelly
5ccff6408c cmDefinitions: Externalize looping for ClosureKeys. 2015-04-30 00:32:18 +02:00
Stephen Kelly
f79cd99d6d cmDefinitions: Implement MakeClosure in terms of reverse iterators.
Iterate directly over the parent content provided by cmMakefile.
2015-04-29 23:54:20 +02:00
Stephen Kelly
aa4d1ee80f cmDefinitions: Convert MakeClosure into a static method.
Accept a range of cmDefinitions*.
2015-04-29 23:54:17 +02:00
Stephen Kelly
60becdc65c cmDefinitions: Implement MakeClosure in terms of a list of ancestors. 2015-04-29 23:54:02 +02:00
Stephen Kelly
24885d4efa cmDefinitions: Replace private constructor with MakeClosure. 2015-04-29 22:51:46 +02:00
Stephen Kelly
012a75a00f cmDefinitions: Make ClosureKeys API vector-based.
Construct the final list directly in a named return value.  Use
a single set to track bindings already found.

Co-Author: Brad King <brad.king@kitware.com>
2015-04-29 22:51:28 +02:00
Stephen Kelly
ca9fa77d5d cmDefinitions: Inline GetClosureKeys implementation. 2015-04-29 22:49:05 +02:00
Stephen Kelly
818bf727c1 cmDefinitions: Change LocalKeys to return a vector.
This is more efficient and we lose nothing.
2015-04-29 22:49:05 +02:00
Stephen Kelly
60200ca508 cmDefinitions: Add an Erase method. 2015-04-29 22:48:12 +02:00
Stephen Kelly
a3358faca1 cmDefinitions: Inline SetInternal method. 2015-04-29 00:18:13 +02:00