1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-16 00:49:26 +08:00

65 Commits

Author SHA1 Message Date
Alex Neundorf
d85238a2f2 source_group: Fix TREE without FILES
According to the documentation of `source_group()` the `FILES`
parameter is optional, but that was actually not the case.
When using `source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR})`
cmake did not previously create the source tree, but recognized
it as the old syntax.  With this patch, cmake recognizes it as
`TREE` syntax if the first argument is TREE followed by a directory.
Then, if no files are given, it defaults to all files in the
directory. PREFIX works too.

Fixes: #24590
2023-07-05 07:54:50 -04:00
Marc Chevrier
aacd4e4a90 Refactoring: add cm::contains to <cmext/algorithm> 2020-04-17 10:00:03 +02:00
Brad King
25f48761fa Simplify absolute path conversions using CollapseFullPath full signature 2020-03-24 10:10:06 -04:00
Mateusz Janek
3c0ca5a9d9 source_group: ensure that passed file is not a directory
Fixes: #19769
2019-11-04 13:37:41 -05:00
Regina Pfeifer
d5c63f073f cmSourceGroupCommand: Port away from cmCommand 2019-09-21 05:14:42 +02:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -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
Sebastian Holtermann
9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00
Regina Pfeifer
2dfc52675c cmAlgorithms: Add cmContains
Also, use the new function where applicable.
2019-08-19 20:01:39 +02:00
Brad King
bbf4a5771f Merge topic 'tidy_inefficient_string'
18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3648
2019-08-07 11:54:53 -04:00
Sebastian Holtermann
18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation
Enables the clang-tidy test performance-inefficient-string-concatenation
and replaces all inefficient string concatenations with `cmStrCat`.

Closes: #19555
2019-08-05 17:21:00 +02:00
Sebastian Holtermann
7fbcc16dcd cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize
This adds the following functions to `cmStringAlgorithms`:

- `cmIsSpace`
- `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`)
- `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`)
- `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to
  accept `cm::string_view`)
2019-08-05 11:25:30 +02:00
Sebastian Holtermann
a693e875db Cleanups: Use cmHas{Prefix,Suffix} instead of String{Starts,Ends}With 2019-08-01 13:33:00 +02:00
Brad King
93af8a2583 source_group: Fix regression in relative FILES
Fix the check added in commit 8d93815d20 (source_group command ensures
that FILES arguments are actually files, 2019-04-25, v3.15.0-rc1~195^2)
to convert to an absolute path before checking for existence.

Also simplify the conversion to an absolute path.

Fixes: #19454
2019-07-30 11:29:58 -04:00
Mateusz Janek
8d93815d20 source_group command ensures that FILES arguments are actually files 2019-04-25 20:51:40 +02:00
Jakub Kalinski
c1d1027ac1 Enabled performance-inefficient-vector-operation check in clang-tidy 2019-04-02 22:17:24 +02:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
Regina Pfeifer
414aa6c81e clang-tidy: Simplify boolean expressions 2019-01-15 11:40:25 -05:00
Yohann Benedic
b3baa97e80 Source_Group: Allow an empty prefix with the TREE syntax.
When calling

    source_group(TREE <root> PREFIX "" FILES ...)

the files located at the root directory were not assigned
to the correct source group: they were put in a default
group (e.g. "Source Files" in Visual Studio).

Fixes: #17608
2018-04-30 16:44:08 +02:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00
Mateusz Janek
365e02e73e source_group: Fix TREE argument parsing
Fixes: #17581
2018-01-30 12:49:26 -05:00
Brad King
67810849b9 Merge topic 'ranged-for'
7d509579 Meta: modernize old-fashioned loops to range-based `for`.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1249
2017-09-13 08:35:05 -04:00
Pavel Solodovnikov
7d5095796a Meta: modernize old-fashioned loops to range-based for.
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
2017-09-12 16:22:47 +03:00
Sebastian Holtermann
a451995fc6 Use cmMakefile::GetOrCreateSourceGroup in cmSourceGroupCommand 2017-09-09 09:44:55 +02:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Brad King
10371cd6dc Merge topic 'source_group-TREE-relative-path'
4716f2be source_group: Restore TREE support for relative paths

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !852
2017-05-18 08:53:51 -04:00
Mateusz Janek
4716f2be83 source_group: Restore TREE support for relative paths
The fix in commit v3.8.1~4^2 (source_group: Fix TREE with root that is
not current source dir, 2017-04-20) accidentally broke support for
specifying paths relative to the source directory.  Fix it and add a
test covering the case.

While at it, fix a typo in a variable name.

Fixes: #16876
2017-05-17 09:04:02 -04:00
Brad King
d286d24af3 Merge branch 'backport-source_group-TREE-alt-root' into source_group-TREE-alt-root 2017-04-21 15:36:17 -04:00
Mateusz Janek
1b4d2c741a source_group: Fix TREE with root that is not current source dir
Also raise an error if files are given that are not below the root.

Fixes: #16807
2017-04-21 15:31:02 -04:00
Daniel Pfeifer
ee72803e9f fix some include-what-you-use diagnostics 2017-02-17 22:12:21 +01:00
Mateusz Janek
b42330be21 source_group: Add options create groups matching directory tree
Add `TREE` and `PREFIX` arguments to enable this behavior.
2017-01-16 10:52:48 -05:00
Daniel Pfeifer
602b78aa79 Remove redundant c_str() calls 2016-10-30 18:34:06 +01:00
Daniel Pfeifer
f69e768d94 Separate compilation for commands included in cmCommands 2016-10-21 18:14:50 +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
73f648f167 use empty method to check for emptyness 2016-09-15 23:59:29 +02:00
Daniel Pfeifer
1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -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
55d80d0a85 cmMakefile: Rename GetCurrent{,Source}Directory.
Match the names used in cmake code.
2015-04-21 00:12:52 +02:00
Stephen Kelly
931e055d8c Port all cmOStringStream to std::ostringstream.
All compilers hosting CMake support the std class.
2015-01-11 17:06:03 +01:00
Stephen Kelly
af8a1643c1 Remove c_str calls when using stream APIs.
Use an ad-hoc clang tool for matching the calls which should be
ported.
2014-03-11 15:03:50 +01:00
Stephen Kelly
21c573f682 Remove some c_str() calls.
Use the clang RemoveCStrCalls tool to automatically migrate the
code. This was only run on linux, so does not have any positive or
negative effect on other platforms.
2014-03-11 15:03:50 +01:00
Kitware Robot
7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04:00
Brad King
f09ba0f1a2 Fix style errors added by parent and grandparent 2011-06-08 07:54:33 -04:00
Johan Björk
d0a403fd99 CMake: Move tokenize to cmSystemTools 2011-06-07 10:18:54 -04:00
Brad King
96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Ken Martin
0e69d38004 ENH: add return and break support to cmake, also change basic command invocation signature to be able to return extra informaiton via the cmExecutionStatus class 2008-01-23 10:28:26 -05:00
Alexander Neundorf
f55dd81190 COMP: parent is not used anymore with this patch, since now the name is
given as a vector of components

Alex
2007-08-26 03:17:11 -04:00
Alexander Neundorf
9220e97401 BUG: fix #4057 (which had several duplicates): handle recursivew source groups better, i.e. multiple sourcegroups with the same end component work now
Alex
2007-08-24 14:21:49 -04:00
Alexander Neundorf
6d508a3094 BUG: handle source_group names which consist only of the delimiter the same was as empty source group names
Alex
2007-08-24 10:58:53 -04:00
Ken Martin
3d96e52261 STYLE: some m_ to this-> cleanup 2006-03-15 11:02:08 -05:00