741 Commits

Author SHA1 Message Date
Vitaly Stakhovsky
99337d345b cmSystemTools::Error(): new overload accepting std::string 2019-01-23 10:19:30 -05:00
Vitaly Stakhovsky
9e5c13738b cmSystemTools::RenameFile: Accepts std::string args 2019-01-22 20:37:59 -05:00
Brad King
cb7fbf1dbb Merge topic 'stdout-string'
3132ea801c cmSystemTools: Stdout(),Stderr() accept std::string argument

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2829
2019-01-22 09:32:58 -05:00
Brad King
4dba5d6ce2 Merge topic 'use-emplace'
ef61997b1b clang-tidy: Use emplace
2e5307a2a4 CTestSVN: Accept std::string in SVNInfo constructor

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2811
2019-01-21 07:51:54 -05:00
Vitaly Stakhovsky
3132ea801c cmSystemTools: Stdout(),Stderr() accept std::string argument 2019-01-20 00:03:35 -05:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -05:00
Tushar Maheshwari
0f08ed8936 cmSystemTools: Silence CreateLink and CreateSymlink errors
If provided, report errors to a std::string.
This allows "silent" fallback to another flow, like COPY_ON_ERROR.
2019-01-16 10:03:35 -05:00
Tushar Maheshwari
81650e488c cmFileCommand: Add CREATE_LINK subcommand
This brings the functionality of `cmake -E create_symlink` and more to scripts.

The default behavior is to create hard links.
The `SYMBOLIC` argument can be used to create symlinks instead.

The `COPY_ON_ERROR` argument enables a fallback to copying the file in case the link fails.

The `RESULT <var>` retrieves the error message generated by the system.
It is set to "0" on success.

Fixes: #16926
2019-01-16 10:03:35 -05:00
Bruno Manganelli
87e810f223 cmOutputConverter: Moved ForceToRelativePath to cmSystem 2018-12-07 19:29:30 +00:00
Brad King
652210e901 cmSystemTools: Add EncodeURL helper
Factor a URL encoding implementation out of CTest.
Add an option to not escape slashes.

Suggested-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2018-11-28 14:27:22 -05:00
Regina Pfeifer
a2648dda97 Mark operator bool explicit 2018-11-19 23:35:09 +01:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Brad King
1c31eae659 Merge topic 'tar-warnings'
95c8a03f00 cmake: Distinguish '-E tar' warnings from errors copying data

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2519
2018-10-25 07:25:45 -04:00
Brad King
95c8a03f00 cmake: Distinguish '-E tar' warnings from errors copying data
The logic added by commit v3.12.0-rc1~62^2 (cmake: Teach '-E tar' to
report errors copying data, 2018-05-16) incorrectly reports failure
in the case of ARCHIVE_WARN.  Convert this case to a warning.

Fixes: #18496
2018-10-24 10:51:11 -04:00
luz.paz
6b4c5a0365 Fix misc. typos
Found via `codespell -q 3 -I ../cmake-whitelist.txt --skip="./Utilities"`
where the whitelist consists of

```
aci
ans
behaviour
buil
convertor
dum
earch
ect
emmited
emmitted
helpfull
iff
isnt
ith
lowercased
mose
nd
nknown
nto
objext
ot
pathes
pevents
splitted
substract
superceded
supercedes
te
tim
todays
uint
upto
whitespaces
```
2018-10-03 15:32:46 -04:00
Jon Chronopoulos
afb7f6e4ff cmake: Add '-E create_symlink' support on Windows
The allows `-E create_symlink` to work on Windows.  It utilizes
`uv_fs_symlink`.  I am still unsure exactly which Windows platforms will
work without requiring Administrator privileges or needing a user/group
with the "Create Symbolic Links" User Rights.  It does work with my
Windows 10 Pro with Developer Mode turned on.  In the test suite check
that the symlink either worked or failed with a permissions error.

Use recent changes in cmSystemTools::FileExists to check that a symlink
is broken.
2018-09-18 11:24:08 -04:00
Brad King
1bfe6991ff cmSystemTools: Re-implement IsOn,IsOff with manual branching
Replace use of std::string allocation, std::set lookups, and toupper
conversions with explicit manual logic to do case-insensitive
recognition of a specific set of strings.
2018-08-31 14:58:03 -04:00
Vitaly Stakhovsky
1fa0f2bd03 cmSystemTools: Add IsOn(),IsOff() overloads accepting std::string 2018-08-31 14:58:03 -04:00
Brad King
985c78c7e1 Merge branch 'restore-windows-resources-through-link' into release-3.12
Merge-request: !2147
2018-06-13 10:52:01 -04:00
Brad King
38e4246f37 Merge topic 'restore-windows-resources-through-link'
4e6ff0ae24 Windows: Restore support for running CMake through a symlink

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2147
2018-06-13 10:44:45 -04:00
Brad King
4e6ff0ae24 Windows: Restore support for running CMake through a symlink
The change in commit v3.11.3~3^2 (cmSystemTools: Revert GetRealPath
implementation on Windows, 2018-05-29) broke the feature added by commit
v3.11.0-rc1~64^2 (Windows: Add support for running CMake tools through a
symlink, 2018-01-21).  Use `GetRealPathResolvingWindowsSubst` in the
latter code path to restore it.

Fixes: #17882
2018-06-12 11:15:50 -04:00
Brad King
6d8ae1e6e4 cmSystemTools: Restore compilation with libarchive versions below 3.3.1
In commit a203fcc63d (cmake: Teach '-E tar' to report errors copying
data, 2018-05-16) we introduced use of `la_ssize_t` but that was not
available until libarchive 3.3.1.  Switch to the `__LA_SSIZE_T` macro
we use elsewhere.
2018-06-01 13:27:08 -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
Brad King
61c4858c37 Merge topic 'revert-windows_symlinks'
83630d4918 cmSystemTools: Revert GetRealPath implementation on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2114
2018-05-31 08:48:36 -04:00
Brad King
83630d4918 cmSystemTools: Revert GetRealPath implementation on Windows
The use of `uv_fs_realpath` introduced by commit v3.11.0-rc1~445^2~1
(cmSystemTools: Implement GetRealPath on Windows, 2017-10-02) causes
`subst` drives to be expanded on Windows, breaking existing use cases.
Revert its use until an alternative implementation can be chosen.

Preserve the behavior introduced by commit v3.11.0-rc1~445^2
(cmTimestamp: For symlinks switch to timestamp of resolved path,
2017-10-02) by retaining use of `uv_fs_realpath` in a function of
a different name.

Fixes: #18033
Issue: #17206
2018-05-29 14:00:33 -04:00
Ruslan Baratov
a203fcc63d cmake: Teach '-E tar' to report errors copying data
The `copy_data` function checks for errors but the caller ignored
them.  Simplify its return type and add a check to the caller.
2018-05-18 10:04:18 -04:00
Brad King
eb80af9093 Drop Visual Studio 8 2005 generator
This generator has been deprecated since CMake 3.9.  Remove it.
2018-04-02 10:08:10 -04:00
Brad King
75e8af3354 cmSystemTools: Fix ParseArguments out-of-bounds read
When checking for a Windows-style leading path, do not read past the
null terminator.

Issue: #17854
2018-03-27 08:46:20 -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
Brad King
92cd3d0677 Merge topic 'reduce-temporaries'
c85bb007 Reduce allocation of temporary values on heap.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1698
2018-01-29 08:05:27 -05:00
Brad King
f343106b19 Merge topic 'ctest-chrono'
e6a80ccf Make use of std::chrono throughout every component
ff62b005 CTest: add safe conversion from cmDuration to integer types
695951bc CTest: introduce cmDuration

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1592
2018-01-26 08:27:37 -05:00
Pavel Solodovnikov
c85bb007df Reduce allocation of temporary values on heap.
- Use `std::move` while inserting temporary results into vectors.
- Change `push_back` to `emplace_back` where appropriate.
2018-01-26 13:24:45 +03:00
Pavel P
c3b80e8664 Windows: Add support for running CMake tools through a symlink
When `cmake.exe` is executed through a symlink, `GetModuleFileNameW`
will return location of the link instead of the real path of
`cmake.exe`.  This results in the following error output:

    CMake Error: Could not find CMAKE_ROOT !!!
    CMake has most likely not been installed correctly.

Use `cmSystemTools::GetRealPath` in `FindCMakeResources` on Windows
to resolve any symlink returned by `GetModuleFileNameW`.
2018-01-24 08:59:33 -05:00
Wouter Klouwen
e6a80ccfc4 Make use of std::chrono throughout every component
This commit continues the changes made in CTest to support std::chrono
by
applying it throughout every component where a duration was used.

No functional change intended.
2018-01-23 18:56:42 +00:00
Brad King
98628de812 Extend libuv file translate mode workaround to all executables
Since libuv commit v1.14.1~7 (win: add uv__once_init() calls,
2017-08-30) the libuv initialization of the file translate mode may take
place even if we do not use a uv loop.  This change was included in our
libuv update commit f4a26c748b (libuv 2018-01-19).  Therefore use of
libuv even through `cmSystemTools::GetRealPath` in any executable may
trigger its file translate mode setting.

Factor out the logic added to `cmake.exe` by commit v3.9.0-rc4~10^2
(cmake: Fix default file translate mode when using libuv, 2017-06-13)
and re-use to initialize all executables.

Issue: #16962
2018-01-23 09:29:07 -05:00
Robert Maynard
81868e6bad CUDA: Add cu as default source file extension 2018-01-08 16:16:52 -05:00
Manuel Núñez
640709e7db cmSystemTools: Implement GetRealPath on Windows
Override the KWSys GetRealPath on Windows and use uv_fs_realpath first
to resolve symbolic links.

Fixes: #17206
2017-10-24 11:04:23 -04:00
Matthias Maennich
b5d7f5b0e8 Fix occurrences of readability-non-const-parameter
Fix issues diagnosed by clang-tidy [readability-non-const-parameter]

The patch separates the definitions of the function headers for the two
variants (CMAKE_USE_ELF_PARSER or not) and comments out the parameter names
to not consider them for any const-ness in the case they are actually not
even looked at.

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-28 07:23:42 -04:00
Matthias Maennich
79b8c3802a Improve several occurrences of vector::push_back in loops
Fix issues diagnosed by clang-tidy by pre-allocating the vector capacity
before the loop [performance-inefficient-vector-operation].

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-28 07:23:41 -04:00
Matthias Maennich
b128f8c5bc Clean up some C-Style casts
Fix issues diagnosed by clang-tidy [google-readability-casting]

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-28 07:23:41 -04:00
Brad King
7c2979a5c5 Merge topic 'rc-missing-better-error'
0a8e23ad Windows: Improve link-time error messages when rc or mt fail
c2d6835c cmSystemTools: Teach RunSingleCommand another way to report exceptions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1260
2017-09-25 09:00:16 -04:00
Pavel Solodovnikov
37d9387be3 Replace empty-string comparisons with checking against empty(). 2017-09-21 11:23:19 +03:00
Jonathan Marler
c2d6835c17 cmSystemTools: Teach RunSingleCommand another way to report exceptions
If the caller captures stdout but not stderr then report exceptions
through stdout instead of dropping them.
2017-09-20 14:17:13 -04:00
Pavel Solodovnikov
5db3aac111 Meta: replace empty-string assignments with clear(). 2017-09-16 02:26:49 +03:00
Brad King
01b9d039e7 Merge topic 'get_filename_component-fix-program-split'
31f73eb1 get_filename_component: Revise PROGRAM/PROGRAM_ARGS split semantics

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1251
2017-09-14 07:39:24 -04:00
Brad King
31f73eb12d get_filename_component: Revise PROGRAM/PROGRAM_ARGS split semantics
The KWSys `SystemTools::SplitProgramFromArgs` implementation goes into
an infinite loop when the value is just " " (a space).  Since the
"program path with unquoted spaces plus command-line arguments"
operation it is trying to provide is poorly defined (string parsing
should not depend on filesystem content), just stop using it.

Instead consider the main two use cases the old approach tried to handle:

* The value is the name or absolute path of a program with no quoting
  or escaping, but also no command-line arguments.  In this case we
  can use the value as given with no parsing, and assume no arguments.

* The value is a command-line string containing the program name/path
  plus arguments.  In this case we now assume that the command line
  is properly quoted or escaped.

Fixes: #17262
2017-09-13 10:47:04 -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
Daniel Pfeifer
190e3825d4 Replace C-style casts 2017-08-27 09:58:46 +02:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
André Klitzing
c4647d8432 Change ComputeFileMD5 to ComputeFileHash
* Use a parameter to select hash algorithm
* Return a std::string as result or an empty
  string if it fails
* Avoids unnecessary copy of hash value
2017-07-14 08:57:17 +02:00