Commit Graph

356 Commits

Author SHA1 Message Date
Bryon Bean
e2e8f6b132 cmFileCommand: Factor out cmFileCopier and cmFileInstaller
Split these classes out into their own sources.
2019-03-13 14:06:32 -04:00
Artur Ryt
9636b03cca cmFileCommand: Refactor HandleCMakePathCommand
Make use of cmJoin and fresh cmRange::transform
to reduce function complexity.
Move conversion logic to named functions.
2019-02-26 21:39:10 +01:00
Regina Pfeifer
9eb0e73f46 cmRange: Move to dedicated header file 2019-02-21 08:24:25 -05:00
Brad King
03e10384ec Merge topic 'delete_copy_assign'
ae5e97a005 Delete some default constructors and assignment operators

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2968
2019-02-18 09:05:30 -05:00
Vitaly Stakhovsky
bd20cc29a2 cmSystemTools: Remove redundant cmCopyFile() and Split() 2019-02-15 09:52:29 -05:00
Albert Astals Cid
ae5e97a005 Delete some default constructors and assignment operators
They are unused, but if someone used them they would lead to
problems since they would copy the internal raw pointers
and the destructor would cause double delete
2019-02-15 07:25:47 -05:00
Brad King
8914d4317a Merge topic 'systools-stdstring2'
080a79ca4a cmSystemTools: More methods accept `std::string` params

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2952
2019-02-13 10:17:08 -05:00
Vitaly Stakhovsky
080a79ca4a cmSystemTools: More methods accept std::string params 2019-02-11 18:11:59 -05:00
Vitaly Stakhovsky
950c099d83 cmake: Progress functions use std::string param 2019-02-11 10:32:43 -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
Artur Ryt
f3534386b5 Prefer front/back/data over dereferencing begin/rbegin iter
Changed for sequenced containers: vector, list, string and array
2019-02-06 10:43:16 -05:00
Brad King
bcec7d0778 Merge topic 'copyfile-stdstring'
c31b6e616d cmSystemTools: copy file member functions accept std::string params

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2877
2019-01-30 08:08:59 -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
Vitaly Stakhovsky
c31b6e616d cmSystemTools: copy file member functions accept std::string params
Cleaned up `c_str()`s.
`cmSystemTools::CopyFileIfDifferent()` removed as redundant.
2019-01-29 10:34:18 -05:00
Brad King
40745ad35a Merge topic 'cmake-files-directory'
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h

Acked-by: Kitware Robot <kwrobot@kitware.com>
Rejected-by: vvs31415 <vstakhovsky@fastmail.com>
Merge-request: !2655
2019-01-25 08:01:26 -05:00
Brad King
c18fc30d1a Merge topic 'renamefile-string'
9e5c13738b cmSystemTools::RenameFile: Accepts std::string args

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2842
2019-01-25 08:00:14 -05:00
Brad King
a5f7652fb9 Merge topic 'revert-file-alt-httpauth'
646eedcfcb Revert "file: Allow DOWNLOAD/UPLOAD using alternate authentication methods"

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2858
2019-01-25 07:51:25 -05:00
Regina Pfeifer
094f01d0f0 cleanup: Prefer compiler provided special member functions 2019-01-25 06:45:00 -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
646eedcfcb Revert "file: Allow DOWNLOAD/UPLOAD using alternate authentication methods"
Revert commit 31301b46a7 (file: Allow DOWNLOAD/UPLOAD using alternate
authentication methods, 2018-08-28, v3.13.0-rc1~155^2).  It regressed
support for password-protected redirects.

Fixes: #18691
2019-01-24 14:14:40 -05:00
Vitaly Stakhovsky
9e5c13738b cmSystemTools::RenameFile: Accepts std::string args 2019-01-22 20:37:59 -05:00
Bruno Manganelli
3e867ed400 cmake: inlined files dir constant and removed it from cmake.h 2019-01-21 15:34:16 +00: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
Brad King
bd54cc774a Merge topic 'semi-warnings'
b056bc3425 Fix most clang -Wextra-semi-stmt warnings in C++ files

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2795
2019-01-16 09:52:45 -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
Sean McBride
b056bc3425 Fix most clang -Wextra-semi-stmt warnings in C++ files
Suppress one in code generated by flex.
2019-01-15 14:09:46 -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
Bruno Manganelli
5bcfe98bd5 Source: Fix various compiler warnings in Visual Studio 2017 2019-01-09 08:25:10 -05:00
Regina Pfeifer
b2aa3aedea clang-tidy: Use default member initialization 2018-12-15 10:52:37 +01:00
Kyle Edwards
31840e363f file: Fix formatting of error in SIZE sub-command 2018-12-06 10:28:16 -05:00
Kyle Edwards
98a39be6cf file: Add READ_SYMLINK sub-command 2018-12-06 10:11:51 -05:00
Brad King
5daf7d92f8 Merge topic 'file-size'
12b471e828 file: add SIZE option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2639
2018-11-28 09:05:16 -05:00
Wouter Klouwen
12b471e828 file: add SIZE option
This commit adds the SIZE option to file(). It returns the file size of
the given path if it exists and produces an error if not.
2018-11-27 08:50:36 +00:00
Regina Pfeifer
ce2570b207 clang-tidy: Enable checks from bugprone set 2018-11-21 07:47:40 -05:00
Regina Pfeifer
5731ec30f0 clang-tidy: fix warnings from version 7
Fix some warnings that are new since clang-tidy version 4, and update
`.clang-tidy` to suppress the rest.
2018-11-20 10:36:08 -05:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Kyle Edwards
5e61b79b82 install: Set permissions on directories created by install(DIRECTORY)
The directories that are implicitly created by install(DIRECTORY)
were not having their permissions being set by
CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS. This change refactors
cmFileCopier to take this into account for directory installation.
2018-10-01 16:28:43 -04:00
Vitaly Stakhovsky
6f16be6a62 Remove unnecessary c_str() calls
Use the new IsOn(),IsOff() overloads.
2018-09-05 15:12:57 -04:00
Brad King
e16568c293 Merge topic 'file-alt-httpauth'
31301b46a7 file: Allow DOWNLOAD/UPLOAD using alternate authentication methods

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2320
2018-08-31 14:45:11 -04:00
Clinton Stimpson
31301b46a7 file: Allow DOWNLOAD/UPLOAD using alternate authentication methods 2018-08-30 10:38:28 -04:00
Vitaly Stakhovsky
c8fd23ec6f cmMakefile: return directories as const std::string& 2018-08-27 14:07:43 -04:00
Vitaly Stakhovsky
69ca85cc7f Remove unnecessary c_str() in RegularExpression::find calls 2018-08-07 15:28:24 -04:00
David Faure
bdd0174df1 file(WRITE): Avoid toggling permissions between 644 and 664
On systems with umask 022, this function would set permissions
to 664 and restore them to 644 at the end, every single time it was
called (which is many times on e.g. install_manifest.txt).

The intent of the code was to make non-writable files temporarily
writable and to restore permissions in the end, but really, if it's
already user-writable there's no point in toggling this back and forth.
2018-08-01 09:05:33 -04:00
Devin Nakamura
b872f5b303 file(STRINGS): Use isprint() to test character type
Use the more portable `isprint()` function to test characters rather
than using hard-coded hex values.  The function is documented by the C++
standard to return non-zero for the exact range of hex values we
previously hard-coded, so this should not change behavior.
2018-07-10 13:57:07 -04:00
Brad King
e9ec0cc3bb Merge topic 'update-kwsys'
b41b30f16e Update use of KWSys SystemTools::SplitString for new signature
f2d97c1cdf Merge branch 'upstream-KWSys' into update-kwsys
6d7fdedde6 KWSys 2018-06-22 (49068d94)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2165
2018-06-25 09:57:35 -04:00
Brad King
b41b30f16e Update use of KWSys SystemTools::SplitString for new signature 2018-06-22 13:38:18 -04:00
Brad King
142a625729 file: Drop error cases added by CMake 3.12.0-rc1 to avoid regressions
Refactoring in commit v3.12.0-rc1~418^2~3 (Refactor HandleGlobCommand,
2018-02-13) introduced error diagnostics for argument combinations that
were previously accepted.  Restore acceptance to avoid regressing
projects that used those combinations even if they do not make sense.

Fixes: #18097
2018-06-22 09:39:05 -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
Ruslan Baratov
2db4945150 file(WRITE): Report errors during write operation
We already report an error if the file cannot be opened for writing.
Add another check to report an error if a write operation itself fails.
2018-05-16 10:34:28 -04:00