Commit Graph

222 Commits

Author SHA1 Message Date
Brad King
5faf145a5b Tests: Drop unused files from RunCMake.CommandLine
Remove files missed by commit 8d6f015d59 (Drop Visual Studio 10 2010
generator, 2022-09-26).
2022-09-27 11:45:29 -04:00
Brad King
8d6f015d59 Drop Visual Studio 10 2010 generator
This generator has been deprecated since CMake 3.22.  Remove it.
2022-09-26 15:43:04 -04:00
Brad King
20f9b6973b Merge topic 'modules-use-new-try_compile-signature'
2edf0fc6d7 Modules: Use new keyword-dispatched try_compile signature

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7656
2022-09-14 08:13:27 -04:00
Matthew Woehlke
2edf0fc6d7 Modules: Use new keyword-dispatched try_compile signature
Modify most of the modules that ship with CMake to use the new
try_compile / try_run signatures added by commit aa9220d3a0
(try_compile: Add keyword-dispatched signature, 2022-09-02). This
improves debugging by each invocation using its own directory so that
the results of multiple invocations can be retained.

This does not cover any invocations which provide an entire project, as
that flavor of try_compile has not yet been updated.
2022-09-14 07:52:16 -04:00
Matthew Woehlke
7b62e40a64 Tests: Fix RunCMake.CommandLine test in unusual environments
Modify `Tests/RunCMake/CommandLine/P_working-dir.cmake` to not spuriously
fail in environments when the build directory's nominal path is not
canonicalized (i.e. `realpath(BINDIR) != BINDIR`).
2022-09-12 09:45:50 -04:00
Kyle Edwards
d0bb3286f0 cmake -E capabilities: Tell whether TLS is enabled
Fixes: #20507
2022-09-01 11:20:14 -04:00
Alex Reinking
c9d70a7cc3 cmake -E env: Add --modify flag
When `cmake -E env` is given the `--modify` flag, try to parse the
following argument as an `ENVIRONMENT_MODIFICATION` operation and apply
it to the environment.

This generalizes `--unset=`:

1.  When implementing `ENVIRONMENT_MODIFICATION` features for other CMake
    commands, the `MYVAR=OP:VALUE` strings do not need to be translated
    to OP-specific flags.
2.  This provides a natural and consistent extension point to introduce
    new operations without introducing very many flags.
3.  Users need to learn only one syntax to access the same functionality.

There is one difference between the behavior here as compared to CTest's
interpretation of the `ENVIRONMENT_MODIFICATION` test property.
The `MYVAR=reset:` command when run in `cmake -E env` will reset `MYVAR`
to whatever its value was when `cmake -E env` launched, rather than try
to checkpoint after plain `MYVAR=VALUE` options.  This makes `MYVAR=VALUE`
and `--modify MYVAR=set:VALUE` semantically equivalent.
2022-08-17 12:54:39 -04:00
Brad King
4f8f577015 Merge topic 'cmake-help-flags-after-dashdash'
14a0e750cb cmake: In -P mode ignore flags like `--version` after `--`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7496
2022-07-25 12:00:39 -04:00
Brad King
cc663a8c1d Merge topic 'cmake-P-path-args'
febe3190f0 Merge branch 'backport-3.23-cmake-P-path-args'
846a650ff7 cmake: In -P mode ignore extra paths on the command line
c362cba566 cmake: simplify to a single source of truth of working mode
261fa5db39 cmake: In -P mode ignore extra paths on the command line
314135cdf1 cmake: simplify to a single source of truth of working mode

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7494
2022-07-25 11:57:48 -04:00
Robert Maynard
14a0e750cb cmake: In -P mode ignore flags like --version after --
Fixes: #21031
2022-07-22 14:30:21 -04:00
Robert Maynard
846a650ff7 cmake: In -P mode ignore extra paths on the command line
Fixes: #23748
2022-07-22 13:55:52 -04:00
Marc Chevrier
9480ced81a Makefiles generator: dependencies messages in verbose mode
Fixes: #23689
2022-07-06 17:40:08 +02:00
Niyas Sait
834422e075 Tests: Fix test failures for Windows Arm64 platforms 2022-05-11 18:13:25 +01:00
Kyle Edwards
313ea361b0 CMake: Use FindPython instead of FindPythonInterp to build CMake itself
Fixes: #23444
2022-04-21 14:23:36 -04:00
Braulio Valdivielso Martinez
fd46db1745 Trace: process else and elseif commands correctly
There have been two bugs reported about the `else` and `elseif`
commands in the context of the tracing functionality and the json-v1
format (#23191 #22315). In essence, the reported traces referred to
the layer of the stacktrace immediately on top of the expected ones.

This MR fixes both issues. My solution adds a new parameter to the
`PrintCommandTrace` function, `commandMissingFromStack`, that callers
can specify if the command they want to report a trace for is not a
regular part of the stack maintained in `cmMakefile`. This is only the
case for `else` and `elseif`. The other bug is fixed by having the
caller pass a `cmListFileBacktrace`, which helps in getting the right
lines, file names... for the reported command.

Fixes: #23191 #22315
2022-03-25 12:24:38 -04:00
Brad King
9f1471739d cmake: Add --fresh option to clear the cache and start from scratch
Simplify the workflow to re-run CMake from scratch as if a build tree
were never before processed, regardless of whether it has been.

Fixes: #23119
2022-03-22 09:27:47 -04:00
Brad King
5dbd068827 Merge topic 'cmake-P-args'
36056ff5a3 cmake: Improve acceptance of arbitrary arguments in -P script mode

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7083
2022-03-18 07:20:24 -04:00
Brad King
32e40f7f53 Merge topic 'always_prefer_last_source_dir'
b44ad7992a cmake: Always prefer the last source directory provided

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7084
2022-03-18 07:16:24 -04:00
Robert Maynard
b44ad7992a cmake: Always prefer the last source directory provided
Fixes: #23334
2022-03-17 15:23:01 -04:00
Brad King
36056ff5a3 cmake: Improve acceptance of arbitrary arguments in -P script mode
The fix in commit e4f1b301fe (cmake: Allow arbitrary args passed to
CMake script, 2020-05-04, v3.18.0-rc1~211^2) only applied to "cache"
arguments like `-DFOO`.  Extend the fix to allow arbitrary arguments
that collide with other CMake arguments like `-S` and `-B`.
2022-03-17 13:50:12 -04:00
Brad King
51e81d1f73 Merge topic 'color-diagnostics'
6ab9fbd43b color: Add tests for CMAKE_COLOR_DIAGNOSTICS
78adb1b952 color: Add CMAKE_COLOR_DIAGNOSTICS environment variable
884d9de8b7 color: Introduce CMAKE_COLOR_DIAGNOSTICS variable

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Frank Dana <ferdnyc@gmail.com>
Merge-request: !6990
2022-03-09 12:15:53 -05:00
Brad King
6ab9fbd43b color: Add tests for CMAKE_COLOR_DIAGNOSTICS 2022-03-08 17:29:12 -05:00
Brad King
c5ab0ea1fa Merge topic 'cmake-dir-args'
d2e9478321 Tests: Add RunCMake.CommandLine ExplicitiDirs explicit work directory
78e8f11456 cmake: Correct regression in `-B <dir> <src_dir>`
4091d5c58c Tests: Verify RunCMake.CommandLine ExplicitDirs source/build dirs
1b97f8f35c Tests: Clarify RunCMake.CommandLine ExplicitDirs case names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7030
2022-03-03 11:46:29 -05:00
Brad King
d2e9478321 Tests: Add RunCMake.CommandLine ExplicitiDirs explicit work directory
Verify that the work directory is not selected as the source or build
tree.

Issue: #23285
2022-03-02 12:21:34 -05:00
Robert Maynard
78e8f11456 cmake: Correct regression in -B <dir> <src_dir>
Fixes: #23285
2022-03-02 12:21:16 -05:00
Brad King
4091d5c58c Tests: Verify RunCMake.CommandLine ExplicitDirs source/build dirs 2022-03-02 12:21:03 -05:00
Brad King
1b97f8f35c Tests: Clarify RunCMake.CommandLine ExplicitDirs case names 2022-03-02 10:53:41 -05:00
Brad King
ee8cd65c76 Merge topic 'correct_multiple_source_warnings'
7083b19498 cmake: When given multiple source paths use last instead of first

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7001
2022-02-18 09:01:22 -05:00
Robert Maynard
7083b19498 cmake: When given multiple source paths use last instead of first
When given two source paths via `-S` or just directory paths prefer
the last one. When the paths are mixed always prefer the last `-S`
entry.

Fixes: #23238
2022-02-17 16:54:30 -05:00
Brad King
9f1f443e83 Merge topic 'cmake-empty-cmd-line-arg'
f73457ca2e cmake: Ignore any empty "" command line arguments
67f97f5478 Tests: Add RunCMake helper to run cmake with raw execute_process args

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6980
2022-02-17 08:45:53 -05:00
Robert Maynard
f73457ca2e cmake: Ignore any empty "" command line arguments
Don't treat empty quote arguments("") as the current working
directory but instead ignore them.

Fixes #23217
2022-02-16 12:11:33 -05:00
Braulio Valdivielso Martinez
8e1e97ccca Trace: include line_end field in json-v1 format
After !6954 got merged, it has become easier for tools to get
full stack-traces for runtime traces of a CMake program. The trace
information already included in the JSON objects (line number, source
file path) allows tools that display these stack traces to print the
CMake source code associated to them. However, CMake commands may
spawn multiple lines, and the JSON information associated to a trace
only contains the line in which the command started, but not the one
in which it ended. If tools want to print stack traces along the
relevant source code, and they want to print the whole command
associated to the stack frame, they will have to implement their own
CMake language parser to know where the command ends.

In order to simplify the life of those who want to write tooling for
CMake, this commit adds a `line_end` field to the json-v1 trace
format. If a given command spans multiple lines, the `line_end` field
will contain the line of the last line spanned by the command (that of
the closing parenthesis associated to the command).
2022-02-09 13:30:11 -05:00
Brad King
3d5466d5e9 Merge topic 'trace-global-frame'
a41d6e4d7a Trace: add global_frame field to json-v1 format

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6954
2022-02-09 09:04:43 -05:00
Braulio Valdivielso Martinez
a41d6e4d7a Trace: add global_frame field to json-v1 format
Tools using the json-v1 format might want to trace stack frames across
different `CMakeLists.txt` files, in order to, for example, provide
stacktraces that span from the top-level `CMakeLists.txt` in a
project. One would think that `frame` lets you do that, but it
doesn't, because it tells you the depth of the stack within the
current `CMakeLists.txt`, so it gets reset across calls to
`add_subdirectory`.

The solution involves adding a field with a "global frame". This value
gets incremented on calls to `add_subdirectory`, which makes it easier
for tools to reconstruct "global stacktraces".

I considered changing the current "frame" value, but I didn't because
it would be a breaking change. I cannot think of any use-case where
"frame" is more useful to "global-frame", but maybe I'm missing
something.
2022-02-07 16:03:22 -05:00
Peter Würth
b10930040d cmcmd: add end of options delimiter to cmake -E commands
Implements a -- delimiter, that indicates the end of options (starting
with a dash -) of a command and separates them from the subsequent
operands (positional arguments).

The following commands are affected:
- env: Implemented the -- delimiter.
- cat: The -- delimiter was already kind of considered, but its
  occurence did not stop the options parsing.
- rm: Here the command already implemented the -- delimiter as
  specified, but it was not documented.

Fixes #22970
2022-02-03 21:54:17 +01:00
Brad King
63154cbf45 Merge topic 'vs-package-restore'
9aa7831f05 Presets: add resolve packages setting to build presets.
b2f8f0bb87 cmGlobalVisualStudio10Generator: Auto restore NuGet packages.
193b8fca52 cmBuildOptions: Split build arguments into separate object.
6a10103493 Help: Update preset schema description for version 3 entries.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6761
2022-01-24 11:46:29 -05:00
Carsten Rudolph
b2f8f0bb87 cmGlobalVisualStudio10Generator: Auto restore NuGet packages. 2022-01-22 06:35:41 -05:00
Robert Maynard
eacf1f879b cmake: Warn about unnecessary paths on command line
We can't make it an error as that would break existing behavior.

Fixes: #23110
2022-01-20 14:38:12 -05:00
Brad King
a4f076110d Tests: Fix RunCMake.CommandLine toolchain case command line 2022-01-20 14:36:48 -05:00
Robert Maynard
2e1b7e5b9a Add tests that showcase cmake -S limitations 2022-01-18 11:53:21 -05:00
Kyle Edwards
3c3698b0e4 FileAPI: Add information on file set installers 2021-10-27 15:17:23 -04:00
makise-homura
ea55ac9a51 Tests/RunCMake/CommandLine: Deal with locales that are different from English
RunCMake/CommandLine has problems
when ran using language setting differeng from English. This is due to
test outputs being compared to English strings, which comparison
obviously fails if this language is set to, e.g. Russian. This commit
sets locale as "C" prior to running these tests, so messages while
testing are generated in correct language and do not fail checks
anymore.
2021-10-15 05:04:24 +03:00
Johnny Jazeix
0b4a56e64b cmake: -E cat stops when an empty file is encountered
Fixes: #22652
2021-09-18 18:54:53 +02:00
Brad King
22dab6eb96 Deprecate Visual Studio 10 2010 generator
Update documentation to mark the generator deprecated.  Add a warning at
the end of generation plus an option to turn off the warning.
2021-07-29 14:15:01 -04:00
Brad King
bf8bf11fe5 Merge topic 'doc-cmake-build-signature'
161f1f42d6 Help: Clarify 'cmake --build' signature alternatives

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6343
2021-07-14 09:22:27 -04:00
Brad King
161f1f42d6 Help: Clarify 'cmake --build' signature alternatives
Documentation added by

* commit 4f4f2028b8 (Help: Add documentation for buildPresets and
                     testPresets, 2021-01-13, v3.20.0-rc1~51^2~7)
* commit 676ecf0d37 (cmake-presets: Add build and test presets,
                     2020-12-14, v3.20.0-rc1~51^2~6)

used square brackets in the `cmake --build` signature to indicate
non-optional alternatives, which is not a typical convention.
A common convention is to use parentheses instead, but in this
case it is probably clearer to list the two signatures separately.

Fixes: #22413
2021-07-13 09:41:26 -04:00
Brad King
ef56eefc9b cmake: Allow CMAKE_CONFIGURATION_TYPES to be set by environment variable
When no `CMAKE_CONFIGURATION_TYPES` is explicitly specified while
creating a new build tree, check for an environment variable of the same
name.

Issue: #20983
2021-06-30 10:55:40 -04:00
Brad King
e216b9bbd3 cmake: Allow CMAKE_BUILD_TYPE to be set by environment variable
When no `CMAKE_BUILD_TYPE` is explicitly specified while creating a new
build tree, check for an environment variable of the same name.

Issue: #20983
2021-06-30 10:55:40 -04:00
Brad King
c46b265839 VS: Add Visual Studio 17 2022 generator
Fixes: #22339
2021-06-25 12:45:44 -04:00
Brad King
6c34ed9b87 cmake: Allow CMAKE_TOOLCHAIN_FILE to be set by environment variable
When no `CMAKE_TOOLCHAIN_FILE` is explicitly specified while creating
a new build tree, check for an environment variable of the same name.
2021-06-03 08:32:44 -04:00