1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-09 14:57:08 +08:00

39 Commits

Author SHA1 Message Date
Rolf Eike Beer
8ca2504a4d use string_views to avoid memory allocations 2020-03-24 17:50:37 +01:00
Tim Blechmann
22f38c0d6b cmake: avoid getcwd in CollapseFullPath
`CollapseFullPath` calls getcwd, which is a rather expensive system
call. we can replace it with `GetHomeOutputDirectory()` to save us from
the calling overhead
2020-01-14 18:20:39 +08:00
Asit Dhal
9dba84cfa5 Refactor: Use cmStrCat to construct error strings
Replace string construction using std::stringstream with cmStrCat and
cmWrap.
2019-09-18 14:18:46 -04:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04: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
9ba0bf60c6 cmA*Command: Turn into free functions
Ref: #19499
2019-08-07 10:16:32 +02:00
Regina Pfeifer
9eb0e73f46 cmRange: Move to dedicated header file 2019-02-21 08:24:25 -05:00
Artur Ryt
01b2d6ab74 Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.

Fixes: #18858
2019-02-07 22:39:05 +01:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Vitaly Stakhovsky
c8fd23ec6f cmMakefile: return directories as const std::string& 2018-08-27 14:07:43 -04: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
Pavel Solodovnikov
86dc86dd6c Add const-reference qualifications 2017-05-26 19:50:11 +03:00
Daniel Pfeifer
b26577c92a clang-tidy: remove else after break and continue 2017-04-21 10:44:07 +02:00
Daniel Pfeifer
e81c323da9 Include necessary headers in commands 2016-10-26 09:02:44 +02:00
Daniel Pfeifer
64f9c282f3 Separate compilation for commands included in cmBootstrapCommands1 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
Daniel Pfeifer
73f648f167 use empty method to check for emptyness 2016-09-15 23:59:29 +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
Stephen Kelly
54d6a9187f cmMakefile: Rename GetCurrent{Output,Binary}Directory.
Match names used in CMake code.
2015-04-21 00:12:52 +02: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
f2e07a6d90 cmMakefile: Remove unused PreOrder member.
Remove references from dependendent API.
2015-04-01 20:32:48 +02:00
Stephen Kelly
aa773035b7 Replace !foo.size() pattern with foo.empty(). 2015-01-18 14:25:24 +01: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
Nils Gladitz
cc1139cc30 strings: Remove redundant calls to std::string::c_str()
Replacements were detected and performed by the clang tool
remove-cstr-calls on a linux build.
2014-10-15 14:54:05 +02: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
Brad King
1df49282a5 add_subdirectory: Compute output dir with consistent slashes (#10072)
When the command is invoked without an explicit build directory path we
compute it from the source directory path.  When either the source or
build tree is the root of a Windows drive letter it will have a trailing
slash.  Handle slashes consistently when substituting the current output
directory for the current source directory.

While at it, use cmSystemTools::IsSubDirectory instead of FindLastString
to verify that the source directory is a subdirectory.

Inspired-by: Graham Menhennitt <graham@menhennitt.com.au>
2013-03-12 11:52:52 -04: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
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
Ken Martin
b99129d2d8 ENH: some code cleanup 2007-03-12 10:26:59 -04:00
Brad King
e09dd5db09 BUG: Fix automatic computation of binary path to work for subdirectories of out of source directories. This addresses bug#3592. 2006-08-31 16:40:38 -04:00
Brad King
a7441ce80e COMP: Removed unused variable. 2006-06-05 15:28:33 -04:00
Brad King
df70e3de66 BUG: Always check whether a subdirectory is below the top of the source before computing the binary tree automatically. Even when the source is a relative path it may contain ../ which would allow it to be outside the source tree. 2006-06-05 14:38:16 -04:00
Ken Martin
b8483cf109 STYLE: fix line length 2006-05-11 10:40:28 -04:00
Ken Martin
aae0bcdacf STYLE: fix line length 2006-05-10 13:50:44 -04:00
Ken Martin
3d96e52261 STYLE: some m_ to this-> cleanup 2006-03-15 11:02:08 -05:00
Ken Martin
4cb9d2fd96 ENH: better format for ADD_SUBDIRECTORY command 2005-09-12 13:46:16 -04:00
Ken Martin
664a93121f ENH: removed the PREORDER option from the AddSubDirectory command 2005-05-31 15:10:04 -04:00
Ken Martin
1f9df24ba7 ENH: added immediate subdirectory command 2005-03-18 10:39:21 -05:00