84 Commits

Author SHA1 Message Date
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
Alex Turbov
a84e509844 list: add sub-commands PREPEND, POP_BACK, POP_FRONT 2019-02-19 09:42:36 -05:00
Brad King
d75fec5a88 Merge topic 'tidy-use-equals-default'
094f01d0f0 cleanup: Prefer compiler provided special member functions
55671b41d2 clang-tidy: Use `= default`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Brad King <brad.king@kitware.com>
Merge-request: !2841
2019-01-29 14:07:24 -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
Brad King
8f56f22b84 cmListCommand: Avoid std::function move constructor on aarch64
Since commit 5a0784ddea (clang-tidy: Pass by value, 2019-01-21), some of
the `RunCMake.{list,PositionIndependentCode}` cases have crashed on an
aarch64 build with GCC 6.  Avoiding use of the `std::function` move
constructor avoids the crash.  Use a strict preprocessor condition to
use this workaround only where needed.
2019-01-24 14:07:05 -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
Brad King
cd0881be61 IWYU: Update CMake code for IWYU built with Clang 6
IWYU now correctly requires `<utility>` for `std::move`.  It also
requires a container header when used via a range-based for loop.
2019-01-15 10:00:50 -05:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Ben Boeckel
121a036f73 cmListCommand: handle empty lists for list(REMOVE_AT)
Treat an empty list as a list with no valid bounds and return an error
message indicating that any given indices are out-of-bounds.
2018-10-16 14:31:39 -04:00
Ben Boeckel
acfe53c588 cmListCommand: make list(ACTION not_a_list) succeed when idempotent
The operations changed here all are no-ops on empty lists anyways, so
just have them succeed when given non-extant lists.

  - `list(REMOVE_ITEM)`
  - `list(REMOVE_DUPLICATES)`
  - `list(SORT)`
  - `list(FILTER)`
  - `list(REVERSE)`
2018-10-16 14:31:39 -04:00
Ben Boeckel
bf572ac952 cmListCommand: check list(FILTER) operation before the list
A future commit will make the not-a-list case a success, but invalid
operations should still be diagnosed in that case.
2018-10-11 17:33:45 -04:00
Daniel Chabrowski
a08154d493 list: Allow inserting at the end of a list
Fixes: #18069
2018-07-05 13:53:49 -04:00
Daniel Franke
49a51a61d7 list: Add options to control the SORT comparison operation 2018-06-13 14:06:29 -04: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
Marc Chevrier
dca2347980 list: Add TRANSFORM sub-command
Issue: #17823
2018-04-16 17:11:53 +02:00
Marc Chevrier
768225837d list: Add SUBLIST sub-command
Issue: #17823
2018-03-21 12:54:53 -04:00
Marc Chevrier
a58158727b list(): add JOIN sub-command 2018-03-20 14:28:17 +01:00
Daniel Pfeifer
190e3825d4 Replace C-style casts 2017-08-27 09:58:46 +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
e81c323da9 Include necessary headers in commands 2016-10-26 09:02:44 +02:00
Daniel Pfeifer
608afd4f62 Separate compilation for commands included in cmBootstrapCommands2 2016-10-21 18:14:51 +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
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
0ac18d40c8 Remove //------... horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King
e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Brad King
180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Ashley Whetter
0205f882ae list: Add FILTER subcommand (#3986)
Create a `list(FILTER)` command to filter lists by regular expression.
2016-02-03 11:13:17 -05:00
Stephen Kelly
8ea0b81d20 cmAlgorithms: Rename cmRange to cmMakeRange. 2015-07-22 10:58:19 -04:00
Stephen Kelly
de21168612 Port to static cmPolicies API. 2015-05-04 22:32:20 +02:00
Stephen Kelly
7916d7bac6 Include cmAlgorithms where it is used. 2015-03-11 00:17:29 +01:00
Stephen Kelly
4afe6c26c6 cmAlgorithms: Add cmReverseRange adaptor.
Use it to implement list(REVERSE).
2015-02-20 21:36:58 +01:00
Stephen Kelly
75661fdfd9 cmListCommand: Move size variable out of loop.
Re-use it where possible in two instances.
2015-02-17 20:18:58 +01:00
Stephen Kelly
116459d34f cmListCommand: Avoid needlessly erasing from vectors.
The entire vector will be destroyed at once at the end of the scope,
and the remove algorithms already give us the end of the range of
interesting values, so just use those sentinals.
2015-02-15 20:47:51 +01:00
Stephen Kelly
1c7c35c372 cmListCommand: Replace remove duplicates loop with algorithm. 2015-02-15 20:47:51 +01:00
Stephen Kelly
3cfe7a4ca8 cmListCommand: Implement REMOVE_ITEM in terms of cmRemoveMatching. 2015-02-15 19:56:09 +01:00
Stephen Kelly
a77af8f130 cmListCommand: Replace joining loop with cmJoin algorithm. 2015-02-15 19:56:07 +01:00
Stephen Kelly
6a22e40147 cmListCommand: Use cmRemoveIndices for REMOVE_AT subcommand.
Avoid repeatedly looping over the indices to process elements (even
without breaking out of the loop when the element is found).
2015-02-15 19:55:28 +01:00
Stephen Kelly
069f2440c4 cmListCommand: Convert loop to find algorithm. 2015-02-15 19:04:30 +01:00
Stephen Kelly
67a26764b5 cmListCommand: Implement REVERSE subcommand with std::reverse. 2015-02-15 18:57:23 +01:00
Stephen Kelly
1cecd3a531 cmListCommand: Use std::find algorithm for FIND subcommand.
Use a ostringstream to account for the input being a variable of type
size_t as a result of using std::distance.  There is no single
format string which portably accepts a size_t.
2015-02-15 14:28:50 +01:00
Stephen Kelly
9380e85f86 Convert loops to cmJoin algorithm with cmRange. 2015-02-11 22:58:04 +01:00
Stephen Kelly
7b8725bf84 Convert loops populating maybe-empty content into the common pattern. 2015-02-11 22:57:53 +01:00
Brad King
9de2ab7fce Merge topic 'consistent-empty-method'
5f69314e Replace foo.length() pattern with !foo.empty().
fd0c036c Replace 'foo.length() >= 1' pattern with !foo.empty()
f09fde2d Replace 'foo.length() > 0' pattern with !foo.empty().
86b5bdfa Replace 'foo.length() == 0' pattern with foo.empty().
fd7b3712 Replace foo.size() pattern with !foo.empty().
aa773035 Replace !foo.size() pattern with foo.empty().
64592633 cmListCommand: Use empty() and expand whitespace.
607e1938 Replace 'foo.size() != 0' pattern with !foo.empty().
930bd478 Replace 'foo.size() == 0' pattern with foo.empty().
d92887ef Replace 'foo.size() > 0' pattern with !foo.empty().
2015-01-19 09:43:28 -05:00
Stephen Kelly
b54225732f cmListCommand: Replace loop with member algorithm. 2015-01-18 15:15:17 +01:00
Stephen Kelly
fd7b371293 Replace foo.size() pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly
6459263377 cmListCommand: Use empty() and expand whitespace. 2015-01-18 14:25:24 +01:00
Stephen Kelly
607e19384f Replace 'foo.size() != 0' pattern with !foo.empty(). 2015-01-18 14:25:24 +01:00
Stephen Kelly
930bd47816 Replace 'foo.size() == 0' pattern with foo.empty(). 2015-01-18 14:25:24 +01:00