Commit Graph

262 Commits

Author SHA1 Message Date
Robert Maynard
75ac6dfbce cmake: --build now uses cmCommandLineArgument
This makes `--build` use the same parsing rules as the rest of the
the cmake executable
2021-01-06 09:11:18 -05:00
Robert Maynard
0fb78576b0 cmake: Use shared parsing code for all cmake argv parsing 2021-01-06 09:11:14 -05:00
Kyle Edwards
c619be2784 ccmake: Don't list --preset in --help
And show available options in cmake-gui.

Fixes: #21313
2020-10-27 10:29:24 -04:00
Kyle Edwards
b7d7eca66d CMakePresets.json: Rework how --preset argument is handled
If a path argument with no -S or -B leads to a cache directory,
use that directory as the binary directory. Otherwise, use the
binary directory from the preset.

Fixes: #21311
2020-10-26 22:32:45 +11:00
Brad King
b1d9a25f35 Merge topic 'cmake-E-cat-binary' into release-3.19
f7a5f28318 cmake: Fix '-E cat' command for binary files on Windows
90b39a5209 cmConsoleBuf: Factor out cout/cerr console buffer management
f1fdd15863 clang-format: Fix include block order in ctest.cxx and cpack.cxx

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5364
2020-10-15 08:10:50 -04:00
Johnny Jazeix
f7a5f28318 cmake: Fix '-E cat' command for binary files on Windows
Reset `std::cout` to write in binary mode with no encoding conversions.

Co-Author: Brad King <brad.king@kitware.com>
Fixes: #21295
2020-10-14 12:08:07 -04:00
Brad King
90b39a5209 cmConsoleBuf: Factor out cout/cerr console buffer management 2020-10-14 12:08:06 -04:00
Kyle Edwards
8617479061 CMake: Add presets functionality 2020-10-05 09:49:59 -04:00
Brad King
c0e4a0bd82 cmake: Update --help output to discourage use of --find-package mode
Fixes: #21056
2020-08-04 12:02:54 -04:00
Brad King
5899e849d0 Merge topic 'supported-profiling-formats'
9c3beb532f cmake: Show supported formats in --help output for --profiling-format

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: dublet <github@dublet.org>
Merge-request: !5001
2020-07-13 07:49:47 -04:00
Craig Scott
9c3beb532f cmake: Show supported formats in --help output for --profiling-format
Fixes: #20943
2020-07-11 23:14:03 +10:00
Brad King
4eb2e50730 Merge topic 'uv-check-return'
0fddcc1e5b cmake: Tolerate nullptr from uv_default_loop

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kyle Edwards <kyle.edwards@kitware.com>
Merge-request: !4962
2020-07-02 08:31:31 -04:00
Brad King
0fddcc1e5b cmake: Tolerate nullptr from uv_default_loop
`uv_default_loop()` can return `nullptr` when running on a Linux kernel
configured without `CONFIG_EVENTFD`.

Fixes: #20899
2020-07-01 16:26:44 -04:00
Brad King
df6b077625 cmake: Remove broken '--warn-unused-vars' option
This option has been broken since commit b9f9915516 (cmMakefile: Remove
VarUsageStack., 2015-05-17, v3.3.0-rc1~52^2).  That commit removed the
check that an initialized variable has actually been used and caused the
option to warn on every variable ever set.  This was not caught by the
test suite because the test for the feature only checked that warnings
appear when needed and not that they do not appear when not needed.

The option was never very practical to use.  Remove it to avoid the
runtime cost of usage tracking and checks for every variable (which we
were doing even when the option was not used).
2020-06-29 17:23:27 -04:00
Asit Dhal
d4812a955b cmake-install: implement default directory permissions
provide an argument for default directory permissions in cmake --install

Fixes: #20700
2020-06-25 14:43:30 -04:00
Vitaly Stakhovsky
b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Marc Chevrier
2faa3f6c55 Refactoring: Third-parties public headers are under cm3p prefix
Fixes: #20666
2020-05-07 12:06:08 +02:00
Wouter Klouwen
1b4ab323fd Fix build warnings for unused functions
This commit addresses two sources of build errors when using the warning
flag -Werror=unused-function for GCC in the default compiler flags.

The affected functions are not used when building in bootstrap
mode and therefore should be ifdefed out.

No functional changes.
2020-05-01 12:54:21 +01:00
Vitaly Stakhovsky
a7f2ff16a4 cmState::GetCacheEntryProperty: return cmProp 2020-03-25 14:46:52 -04:00
Vitaly Stakhovsky
bd89133543 cmState::GetCacheEntryValue: return cmProp 2020-03-17 12:09:20 -04:00
Wouter Klouwen
9aa4640792 cmake: add command line options to output script profiling data
For users of CMake who want to optimize their scripts if they take a
while to run, this commit adds the ability to output profiling data.

To enable this output, it adds the two command line parameters
to select the output path and format.

This commit adds the first profiling format of type ``google-trace``,
which is the output is a JSON file containing Duration events as per the
Google Trace Format specification:

https://docs.google.com/document/d/1CvAClvFfyA5R-
PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#
2020-03-07 13:36:27 +00:00
Kyle Edwards
2ac835b9f9 Refactor: Allow generators to decide default configuration for build
And allow them to read any cache values they need.
2020-02-04 14:13:07 -05:00
Kyle Edwards
bb811568cc Merge topic 'traceJSON'
e113ab1168 trace: Add test for the JSON-v1 trace
482497e0de trace: Add JSON output format

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4102
2019-12-27 10:53:13 -05:00
Daniel Mensinger
482497e0de
trace: Add JSON output format
Add a new `--trace-format=` flag, to enable the new JSON trace
output format. This new format is easier to parse by machines
than the existing format. This new format also removes the
ambiguity of the whitespace in the "old" format (e.g. is that
whitespace part of a file path, or does it seperate arguments)
2019-12-23 14:05:36 +01:00
Kyle Edwards
61960fa466 Merge topic 'add_find_call_debugging'
f3c9396260 Help: Document CMAKE_FIND_DEBUG_MODE
204b8d9f4e find_*: Use debug logging infrastructure
a7ea20649d find_*: Add debug logging infrastructure

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3935
2019-12-20 12:59:50 -05:00
Robert Maynard
a7ea20649d find_*: Add debug logging infrastructure
Enable debug messages a new `--find-debug` command-line option or via
the `CMAKE_FIND_DEBUG_MODE` variable.

This work was started by Chris Wilson, continued by Ray Donnelly, and
then refactored by Robert Maynard to collect information into a single
message per find query.

Co-Author: Ray Donnelly <mingw.android@gmail.com>
Co-Author: Chris Wilson <chris+github@qwirx.com>
2019-12-19 08:09:49 -05:00
Marc Chevrier
f7d12609f0 Refactoring: use append functions from cmext/algorithm 2019-12-17 10:44:02 +01:00
Brad King
a4c19cb895 Windows: Restore suppression of error report popups in CI builds
On Windows, libuv uses `_CrtSetReportHook` to install a handler it uses
to suppress assertions on invalid file descriptors in `_get_osfhandle`.
This removes the handler we install in CI environments to suppress
interactive popups.  Move installation of our handler to after libuv is
initialized so that our handler is actually used.

Unfortunately this also removes libuv's handler and so may cause Debug
builds under CI to abort on invalid file descriptors instead of simply
converting them to `INVALID_HANDLE_VALUE`.  If this becomes a problem
we may need to modify libuv to make its hook more configurable.
2019-11-15 09:23:47 -05:00
Alex Turbov
7cf79f4419 message: Support logging a context with each message 2019-10-12 18:21:36 +11:00
Craig Scott
7bbddeb78d CLI: Rename --loglevel to --log-level for naming consistency
Other multi-word command line options use hyphens to separate
the words, so the --loglevel option introduced in CMake 3.15 was
inconsistent in this regard. Rename it to --log-level but still support
the original --loglevel name to preserve backward compatibility.
2019-10-10 09:20:50 -04:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -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
Brad King
a0c8405d68 Merge topic 'trace-redirect'
3c94069660 Add --trace-redirect parameter to redirect trace output to a file

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3645
2019-08-20 09:20:49 -04:00
Kyle Edwards
dcf2beb7de Merge topic 'cmStringAlgorithms_ulong'
935fbe0b04 cmStringAlgorithms: Add cmStrToLong and cmStrToULong

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3681
2019-08-16 14:49:28 -04:00
Sebastian Holtermann
935fbe0b04 cmStringAlgorithms: Add cmStrToLong and cmStrToULong
This adds the following functions to cmStringAlgorithms:
- `cmStrToLong`: moved from `cmSystemTools::StringToLong`
- `cmStrToULong`: moved from `cmSystemTools::StringToULong`

Overloads of the given functions for `std::string` are added as well.
2019-08-10 14:39:03 +02:00
Igor Ivanov
3c94069660 Add --trace-redirect parameter to redirect trace output to a file 2019-08-10 11:41:53 +03:00
Kitware Robot
54e9d38c28 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP 2019-08-09 10:41:44 -04:00
Sebastian Holtermann
f71f7ce3f0 cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.h
This adds the `cmStringAlgorithms.h` header and moves all string functions
from `cmAlgorithms.h` to `cmStringAlgorithms.h`.
2019-07-29 21:13:56 +02:00
Alex Turbov
0db458a0ce Refactor: Use anonymous namespace instead of statics
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2019-07-10 01:06:58 +03:00
Alex Turbov
0328b64efd Refactor: Remove one-time used macros
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2019-07-10 01:06:26 +03:00
Alex Turbov
b821f9ad62 Refactor: Optimize some stream output operations
- remove redundant `std::flush` right after `std::endl`
- join some string literals

Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2019-07-10 01:06:14 +03:00
Craig Scott
14ed40d670 Help: Use consistent levels for cmake --loglevel and message()
The message() command requires uppercase log levels. Even
though the cmake --loglevel option is not case sensitive, show
the supported values as uppercase to match the message()
docs as closely as possible, since they are related to the same
feature.

Also fixes the wrong string being shown for the warning level
by cmake --help.
2019-07-08 20:11:33 +10:00
Sebastian Holtermann
006229278b Use cmAppend to append ranges to std::vector instances 2019-05-23 16:19:49 +02:00
Brad King
186ca170da Merge topic 'std-pipes-always'
c85524a94a Ensure stdin, stdout, and stderr pipes are always open

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Kyle Edwards <kyle.edwards@kitware.com>
Merge-request: !3282
2019-05-03 11:48:46 -04:00
Brad King
9713154cf6 Merge topic 'jobs-positive-value'
6ad699358b cmake: --build -j <jobs> should not accept 0.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3255
2019-05-03 11:45:32 -04:00
Brad King
c85524a94a Ensure stdin, stdout, and stderr pipes are always open
On non-Windows platforms libuv assumes that file descriptors 0-2 are
always used for standard pipes and never for anything else.  Otherwise,
libuv may re-use one of these descriptors and then fail an assertion
when closing it.  Similarly, On Windows platforms our ConsoleBuf
implementation assumes that the standard handles are always open.

If CMake is run with any standard pipes closed, open them with
`/dev/null` or `NUL` to satisfy these assumptions.

Fixes: #19219
2019-05-02 14:34:58 -04:00
Fred Baksik
6ad699358b cmake: --build -j <jobs> should not accept 0.
Fixes #19059
2019-05-01 09:15:51 -04:00
Alex Turbov
6cc93b370e message(): Add support for log levels
Relates: #18943
Co-Authored-By: Craig Scott <craig.scott@crascit.com>
2019-04-28 22:45:44 +10:00
Kyle Edwards
8c0b7aa17d Merge topic 'cmake--install'
73f23d1e00 cmake: add '--install <dir>' option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex Turbov <i.zaufi@gmail.com>
Acked-by: Bartosz <gang65@poczta.onet.pl>
Acked-by: Cristian Adam <cristian.adam@gmail.com>
Rejected-by: Alex Turbov <i.zaufi@gmail.com>
Merge-request: !3069
2019-03-19 13:39:18 -04:00