Commit Graph

668 Commits

Author SHA1 Message Date
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
Pavel Solodovnikov
db2d46e2dd Remove second arg: npos in substr usages 2017-06-01 14:19:52 -04:00
Pavel Solodovnikov
8b6f439ef2 Access string npos without instance 2017-06-01 14:19:51 -04:00
Pavel Solodovnikov
1e4e2f993c Remove unused variables 2017-05-26 19:52:31 +03:00
Pavel Solodovnikov
76bdb40762 Change std::basic_string<char> to std::string 2017-05-24 23:30:57 +03:00
Brad King
74672e2ffa Merge topic 'ninja-dyndep-response-file'
594d3d6f Ninja: support response file for cmake_ninja_depends on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !722
2017-04-25 09:41:18 -04:00
Bernhard Burgermeister
594d3d6fff Ninja: support response file for cmake_ninja_depends on Windows
The internal tool "cmake_ninja_depends" now supports reading the list of ddi
files from a reponse file to circumvent Windows command line length limits.

Use this response file for dyndep rule on Windows.
2017-04-25 09:32:50 +02:00
Brad King
fa338c97d7 Merge topic 'clang-tidy'
73020305 clang-tidy: avoid copy
b432e933 clang-tidy: use .empty() to check emptyness
012972a9 clang-tidy: remove reduntant .data() calls
b26577c9 clang-tidy: remove else after break and continue

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !734
2017-04-24 09:27:48 -04:00
Brad King
718daeb4e6 Merge topic 'unified-commandline-length'
bbb5c3ef Ninja,Makefile: Unify command line limit logic

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !705
2017-04-21 08:51:49 -04:00
Daniel Pfeifer
b26577c92a clang-tidy: remove else after break and continue 2017-04-21 10:44:07 +02:00
Brad King
c94f1bcf92 Drop Visual Studio 7 .NET 2003 generator
This generator has been deprecated since CMake 3.6.  Remove it.
2017-04-19 15:28:05 -04:00
Christian Pfeiffer
bbb5c3efe2 Ninja,Makefile: Unify command line limit logic
Move the logic to cmSystemTools to be shared among the generators.
Revise the implementation and add comments justifying each possible
source for a limit.
2017-04-19 11:02:24 -04: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
e9fc7ff505 Add self-sufficient wrapper for <sys/stat.h> 2017-03-24 22:58:25 +01:00
Daniel Pfeifer
41ec352832 IWYU: use pragma export 2017-03-23 23:38:46 +01:00
Brad King
3c0de6db2d Merge topic 'iwyu'
d58d28a9 ParserHelper: Move macros to bottom of files
07953c18 remove file cmStandardIncludes.h
f918b053 cmFortranParser: include what you use
b74314c6 cmDependsJavaParser: include what you use
74404df4 cmCommandArgumentParser: include what you use
e7168c08 cmExprParser: include what you use
ee72803e fix some include-what-you-use diagnostics
2017-02-20 10:43:07 -05:00
Daniel Pfeifer
ee72803e9f fix some include-what-you-use diagnostics 2017-02-17 22:12:21 +01:00
Brad King
3287ba0254 Make CMAKE_ROOT independent of case of path used to invoke cmake
We compute the location of `CMAKE_ROOT` and other resources relative to
the location of our own executable.  On some platforms this path is
computed in a way that depends on the case of the path used to invoke
the executable.  Convert the result to the actual case preserved by the
filesystem on disk in order to make it consistent regardless of how the
executable is launched.

This approach generalizes the fix made by commit v3.8.0-rc1~71^2
(cmSystemTools: use the actual case for root detection, 2017-01-18).

Issue: #16648
2017-02-17 11:09:12 -05:00
Brad King
0f891007a9 Merge topic 'case-insensitive-bindir-detection'
7f0a21a5 cmSystemTools: use the actual case for root detection
2017-01-20 11:54:37 -05:00
Ben Boeckel
7f0a21a51e cmSystemTools: use the actual case for root detection
On Windows, calling a binary installed with the default `bin` binary
directory will fail to be detected when called as `BIN\cmake.exe` due to
the string compare. Get the actual case of the path before checking that
the path ends with `CMAKE_BIN_DIR`.

Fixes #16574.
2017-01-18 10:08:40 -05:00
Daniel Pfeifer
2988abd939 clang-tidy: apply modernize-use-bool-literals fixes 2016-12-12 14:04:14 -05:00
Dāvis Mosāns
40bd42dfbc Add Encoding option for RunChild, RunMakeCommand and RunProcess 2016-11-15 01:00:46 +02:00
Dāvis Mosāns
595feb3234 Windows: Encode child process output to internally-used encoding
Typically Windows applications (eg. MSVC compiler) use current console's
codepage for output to pipes so we need to encode that to our
internally-used encoding (`KWSYS_ENCODING_DEFAULT_CODEPAGE`).
2016-11-14 21:21:20 +02:00
Brad King
5420278dc8 Port hash computation to cmCryptoHash
Avoid using KWSys MD5 or `cm_sha2` and use the `cmCryptoHash`
abstraction instead.
2016-11-10 08:29:38 -05:00