1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-10 07:10:32 +08:00

85 Commits

Author SHA1 Message Date
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
9f60f19ee9 cmList: CMake list implementation
Fixes: #24548
2023-04-05 17:54:55 +02:00
Brad King
ed9abd9977 Merge topic 'mocmacrosonce'
8ff0c2b1dd AutoMoc: Do not list moc macros multiple times
6e2f4029c0 cmAlgorithms: Preserve const-ness in cmRemoveDuplicates range signature

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6459
2021-09-09 14:02:52 -04:00
Kyle Edwards
ab94c369c9 Refactor: Convert parallel string/backtrace vectors to BT vectors 2021-09-03 09:52:14 -04:00
Brad King
6e2f4029c0 cmAlgorithms: Preserve const-ness in cmRemoveDuplicates range signature
The pattern `vec.erase(cmRemoveDuplicates(vec), vec.end())` fails to
compile with GCC 4.8's libstdc++ if `cmRemoveDuplicates` returns a
`const_iterator` because `end()` returns an `iterator`.  Overload
`cmRemoveDuplicates` to return an iterator type matching the const-ness
of its argument.
2021-09-03 09:40:57 -04: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
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
Marc Chevrier
2faa3f6c55 Refactoring: Third-parties public headers are under cm3p prefix
Fixes: #20666
2020-05-07 12:06:08 +02:00
Marc Chevrier
aacd4e4a90 Refactoring: add cm::contains to <cmext/algorithm> 2020-04-17 10:00:03 +02:00
Raul Tambre
a54d96b722 cmAlgorithms: Fix -Wnon-c-typedef-for-linkage warnings
In commit bf1e73305a (cmAlgorithms: Refactor cmRemoveDuplicates,
2019-03-03, v3.15.0-rc1~414^2) we added `union X = struct {}`.
C++ had a rule change whereby only C-compatible unnamed typedefs are
allowed. Clang 11 warns about this by default.  See
https://reviews.llvm.org/D74103.  The aliases don't seem to be
necessary, so simply define as structs.
2020-03-09 09:21:25 -04:00
Marc Chevrier
328f586be7 cmAlgorithms.h: remove obsolete helpers 2020-01-14 11:03:09 +01:00
Marc Chevrier
968477517e Refactoring: suppress cmEraseIf in favor of cm::erase_if 2020-01-09 11:19:20 +01:00
Marc Chevrier
f7d12609f0 Refactoring: use append functions from cmext/algorithm 2019-12-17 10:44:02 +01:00
Marc Chevrier
d74416a9cd cmGeneratorExpressionEvaluator: Modernize memory management 2019-12-05 17:20:56 +01:00
Marc Chevrier
101b5288ff cmAlgorithm: Extend cmAppend capabilities 2019-11-11 10:57:58 +01: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
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
Regina Pfeifer
2dfc52675c cmAlgorithms: Add cmContains
Also, use the new function where applicable.
2019-08-19 20:01:39 +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
65d3ea2c7f cmAlgorithms: Make cmHasLiteral{Prefix,Suffix} cm::string_view based 2019-07-24 19:31:14 +02:00
Sebastian Holtermann
301f5356fd cmAlgorithms: Make cmHasPrefix and cmHasSuffix cm::string_view based
Make `cmHasPrefix`, `cmHasSuffix` and `cmStripSuffixIfExists` accept
arguments as `cm::string_view` instead of `const std::string&`.
This lets them accept literal strings without having to allocate a temporary
`std::string`.
Add variants of `cmHasPrefix`, `cmHasSuffix` and `cmStripSuffixIfExists` that
accept a single character as second argument.
2019-07-22 16:04:22 +02:00
Marc Chevrier
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx 2019-07-14 15:37:30 +02:00
Sebastian Holtermann
999516478d cmAlgorithms: Add cmAppend function
The new `cmAppend` function simplifies appending ranges of values to a
`std::vector`.
2019-05-23 15:32:23 +02:00
Artur Ryt
bf1e73305a cmAlgorithms: Refactor cmRemoveDuplicates
Use an iterator-based implementation with range-based one simply
deferring to it.

Also optimize a little by storing iterators to unique values to prevent
creating value copies.
2019-03-06 08:57:47 -05:00
Regina Pfeifer
9eb0e73f46 cmRange: Move to dedicated header file 2019-02-21 08:24:25 -05:00
Brad King
50ba2f019b Merge topic 'fix-legacy-implicit-includes'
6fc3382944 Update logic for sysroot in detected implicit include directories
2ad14ef4ea cmAlgorithms: Add cmHasPrefix to match existing cmHasSuffix
557b2d6e65 Fix regression in -I/usr/include exclusion logic
017598a444 macOS: Fix addition of <sdk>/usr/include to default implicit include dirs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2957
2019-02-14 10:14:47 -05:00
Brad King
2ad14ef4ea cmAlgorithms: Add cmHasPrefix to match existing cmHasSuffix 2019-02-13 09:52:20 -05:00
Artur Ryt
15bdbec017 cmAlgorithms: Make cmRange advance/retreat safe for rvalues
In rvalue context these functions have to return cmRange
by copy instead of reference to temporary object

It allows to use ranged-for over cmMakeRange(xxx).advance(yyy)
2019-02-07 22:38:12 +01:00
Regina Pfeifer
5a0784ddea clang-tidy: Pass by value 2019-01-22 13:03:04 -05:00
Bruno Manganelli
70e245f19e cmAlgorithms: add utility functions to get signed size of containers 2018-12-27 22:29:06 +01:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* 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.
2018-06-01 09:53:42 -04:00
Le Minh Phuc
6d7c074055 cmAlgorithms: Speed up cmRemoveDuplicates method
Use a hash table instead of a sorted vector to track entries.

Co-authored-by: Chu Qinghao <me@qinghao1.com>
2018-05-25 12:49:01 -04:00
jrp2014
966dba5b68 cmAlgorithms: Remove unnecessary typename keyword 2018-04-05 13:42:48 -04:00
Matthias Maennich
57132765e0 Replace cmArray{Begin,End,Size} by their standard counterparts
std::{begin,end} are part of C++11, std::{cbegin,cend} are part of C++14
and an standard compliant implementation has been introduced within the
'cm' namespace: cm::{cbegin,cend}.

std::size is only part of C++17, hence exposing a compliant implementation
within namespace cm (cm::size).

where possible, the standard implementations are reused.
2017-10-23 17:51:35 +02:00
Brad King
44d3a76d4a Avoid using std::bind1st that is removed in C++17
Use a lambda instead now that we require C++11.
2017-09-23 06:49:48 -04:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Daniel Pfeifer
4614a3b287 server: backport to C++11 2017-08-26 07:46:57 +02:00
Daniel Pfeifer
b799ca42b8 cmAlgorithms: pass std::string by const ref 2017-04-21 21:40:54 +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
c3800e5458 cmAlgorithms: add cmEraseIf function 2017-02-10 23:04:32 +01:00
Daniel Pfeifer
7c9db8f813 clang-tidy: apply performance-unnecessary-value-param fixes 2016-12-12 14:04:12 -05:00
Daniel Pfeifer
2e620f0b38 Fix several include-what-you-use findings 2016-11-08 09:42:04 -05: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
3838a0d5fb make sure to include cmConfigure.h before cmStandardIncludes.h 2016-09-03 08:04:22 -04:00
Nicolas Despres
8a862a4d4b Ninja: Support embedding of CMake as subninja project
Add a `CMAKE_NINJA_OUTPUT_PATH_PREFIX` variable.  When it is set, CMake
generates a `build.ninja` file suitable for embedding into another ninja
project potentially generated by an alien generator.
2016-05-17 09:34:12 -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
Christoph Grüninger
ccb2d5c07f cmAlgorithms.h: remove superfluous semicolon after method 2016-02-01 10:47:25 -05:00
Milian Wolff
70788e9264 Remove temporary allocations when calling cmHasLiteral{Suf,Pre}fix.
When the first argument passed is a std::string, we need to take it
by const&, otherwise we copy the string and trigger a temporary
allocation. This patch removes a few 10k temporary allocations when
running the CMake daemon on the KDevelop build dir.

This hotspot was found with heaptrack.
2016-01-20 21:20:55 +01:00