Commit Graph

101 Commits

Author SHA1 Message Date
Brad King
13ece67a58 Add genex support to TEST_LAUNCHER and CROSSCOMPILING_EMULATOR
Evaluate generator expressions in these properties, as they apply to
`add_test`, `add_custom_command`, and `add_custom_target`.

The `CMAKE_CROSSCOMPILING_EMULATOR` variable's `try_run` behavior occurs
at configure time and so cannot support generator expressions.
2024-01-29 10:30:24 -05:00
Orkun Tokdemir
972cfd1bc3 cmCustomCommandGenerator: Fix GetInternalDepfile on moved instance
Previously the constructor captured `this` in a lambda used by the
`GetInternalDepfile` method, but the pointer is invalidated when the
instance moves.
2023-09-13 15:58:47 +02:00
Brad King
bd4ec7a71e clang-tidy: Fix modernize-loop-convert warnings 2023-05-22 17:15:45 -04:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Peter Würth
26d813092b add_custom_{command,target}: add genex support for COMMENT
Evaluate and expand generator expressions in the `COMMENT` argument of
the `add_custom_command()` and `add_custom_target()` commands.
This allows to include generator expressions, e.g. a targets location
$<TARGET_...> or the current configuration $<CONFIG>, in the build-time
messages.

Fixes #22507
2022-11-19 13:32:56 +01:00
Peter Würth
60a5a39022 cmCustomCommandGenerator: refactor GetComment to return std::string
Refactoring was done because EvaluateComment leaked memory.
2022-11-19 13:32:56 +01:00
Kyle Edwards
09d7f947d6 cmGeneratorExpression: Require cmake instance 2022-11-11 12:29:41 -05:00
Brad King
e479650b41 Merge topic 'nmc-cross-config-target-deps'
95f44e00cd Ninja Multi-Config: Fix custom command target dependencies in cross-configs
a883363935 Ninja Multi-Config: Fix internal cross-config target dependency ordering
16e24748c5 Ninja Multi-Config: Fix cross-config custom command dependency tracing

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !6702
2021-11-05 10:09:28 -04:00
Brad King
95f44e00cd Ninja Multi-Config: Fix custom command target dependencies in cross-configs
Generator expressions in a non-cross custom command's `COMMAND`
arguments are evaluated in the command config.  Target-level
dependencies implied by `TARGET_FILE` must therefore be cross
dependencies.  This is important to generate proper target-level
dependencies on the cross-config build statements for the target to
which the custom command is attached.

Fixes: #22855
2021-11-04 13:41:16 -04:00
Sean McBride
1cf14f8c03 Source: fix many -Wmissing-prototypes warnings by marking functions static 2021-10-25 12:27:09 -04:00
Marc Chevrier
cc56dc7468 Rename cmProp in cmValue 2021-09-21 17:14:04 +02:00
Brad King
7291f31254 cmTransformDepfile: Add support for MSBuild AdditionalInputs format 2021-06-09 10:09:58 -04:00
Brad King
f0e9d74a2d cmake_transform_depfile: Remove unused incomplete vstlog support
In commit b2c14bc774 (cmake -E: Add cmake_transform_depfile internal
command, 2020-10-02, v3.20.0-rc1~684^2~2) a partial implementation for
converting MSBuild "TLog" format files was added.  However, it is
unused and incomplete:

* Does not enforce absolute paths as TLog docs require.
* Does not upper-case paths as TLog docs recommend.
* The TLog format semantics are not equivalent to `out: in`.

Remove the unused TLog transform infrastructure to avoid confusion.

Issue: #20286
2021-06-02 07:41:05 -04:00
Raul Tambre
1cb4f592a0 add_custom_command: Target-dependent generator expression support
OUTPUT variant with a TARGET given to allow resolving target-based generator
expressions wouldn't work because OUTPUT is resolved before generator targets
are created, i.e. FindGeneratorTargetToUse() returns nullptr.
This is a known limitation, see #21364.

Implements #21336.
2021-05-31 10:39:58 +03:00
Marc Chevrier
253aff6c94 Xcode: Add support of DEPFILE for add_custom_command, part 2
This MR extend the support of 'DEPFILE' to buildsystem version 1.

Issue: #20286
2021-04-17 11:05:26 +02:00
Marc Chevrier
d67cc4882d Xcode: Add support of DEPFILE for add_custom_command
Issue: #20286
2021-04-15 12:17:31 -04:00
Marc Chevrier
0c47b91fcc Genex: add_custom_command: DEPFILE supports genex
This facility is very useful for 'Ninja Multi-Config' and required
as well for future support of DEPFILE in 'Xcode' and 'Visual Studio'
generators (#20286).
2021-04-12 13:06:49 +02:00
Marc Chevrier
b5c2163293 Ninja: add_custom_command(DEPFILE): Ensure dependencies consistency
Fixes: #21694
2021-01-19 13:17:14 +01:00
Kyle Edwards
dcf9f4d2f7 Ninja Multi-Config: Add support for cross-config custom commands
Co-Author: Brad King <brad.king@kitware.com>
2020-12-15 07:01:21 -05:00
Brad King
947ba01bf9 cmLocalGenerator: Factor out helper to expand custom command output paths 2020-12-10 07:06:21 -05:00
Brad King
706c48301d cmCustomCommandGenerator: Treat relative outputs w.r.t. build dir
The `add_custom_command` and `add_custom_target` commands already do
this for plain output and byproduct paths.  Perform the same conversion
for such paths discovered after generator expression evaluation too.
2020-12-10 07:06:20 -05:00
Brad King
5d23c5446e cmCustomCommandGenerator: Refactor OUTPUT and DEPENDS path evaluation
* Use value semantics.
* Normalize paths in a separate loop.
* If CollapseFullPath is used, ConvertToUnixSlashes is unnecessary.
2020-12-10 07:06:20 -05:00
Brad King
24156c0269 cmCustomCommandGenerator: Evaluate generator expressions in outputs
This was already done for byproducts by commit a583b7bc17 (Genex:
Evaluate byproduct generator expressions in cmCustomCommandGenerator,
2019-09-11, v3.16.0-rc1~86^2).  Like that commit, this does not actually
expose the feature to projects because the front-end commands still
reject generator expressions.

Issue: #12877
2020-12-10 07:06:20 -05:00
Brad King
c404f64289 cmCustomCommandGenerator: Collect genex target references in commands
These will become target-level dependencies.
2020-10-29 09:37:14 -04:00
Brad King
2a640d4199 cmCustomCommandGenerator: Add move operations 2020-10-27 14:58:15 -04:00
Brad King
9e5e2d704a Remove unnecessary arbitrary CollapseFullPath second arguments
Some calls to CollapseFullPath that already have an absolute path were
updated by commit 22f38c0d6b (cmake: avoid getcwd in `CollapseFullPath`,
2020-01-14, v3.17.0-rc1~171^2) to pass an arbitrary second argument to
prevent unnecessary `getcwd` calls.  Since then, the KWSys
implementation of CollapseFullPath has learned to avoid unnecessary
`getcwd` calls on its own, so we can drop the arbitrary second arguments
to our CollapseFullPath calls.
2020-10-27 14:36:16 -04:00
Kyle Edwards
596439b1bb cmCustomCommandGenerator: Add option to transform depfile 2020-10-13 10:18:02 -04:00
Vitaly Stakhovsky
b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Vitaly Stakhovsky
36aba01223 cmGeneratorTarget::GetProperty: return cmProp 2020-04-29 10:59:39 -04:00
Vitaly Stakhovsky
bbc07e4561 Source: use std::string in place of const char* 2020-01-29 14:31:01 -05:00
Ben Boeckel
fd0ba705ce add_custom_command: check if a relative path should be an in-source path
This still is broken for dependencies on generated paths where they get
generated to the source directory rather than the build directory
however, but there's no way to determine that is the case.

Fixes: #20194
2020-01-16 13:54:26 -05:00
Tim Blechmann
22f38c0d6b cmake: avoid getcwd in CollapseFullPath
`CollapseFullPath` calls getcwd, which is a rather expensive system
call. we can replace it with `GetHomeOutputDirectory()` to save us from
the calling overhead
2020-01-14 18:20:39 +08:00
Ben Boeckel
f5126badd8 add_custom_command: convert DEPENDS path arguments to absolute paths
This is only done if they are "obviously" paths in that they contain a
directory separator.

Fixes: #17111
2019-12-18 13:57:07 -05:00
Marc Chevrier
f7d12609f0 Refactoring: use append functions from cmext/algorithm 2019-12-17 10:44:02 +01:00
Kyle Edwards
5a8a9f7229 Ninja: Add multi-config variant
Co-Authored-by: vector-of-bool <vectorofbool@gmail.com>
2019-12-13 10:51:46 -05: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
Daniel Eiband
c7c59dae82 cmCustomCommandGenerator: Replace generator expression member
Replace generator expression member variable by stack variable in the
constructor.
2019-09-22 09:51:20 +02:00
Daniel Eiband
a583b7bc17 Genex: Evaluate byproduct generator expressions in cmCustomCommandGenerator
Evaluate and expand generator expressions in byproducts of custom commands.

Note that it is still not possible to use generator expressions in byproducts
of the commands `add_custom_command` and `add_custom_target`.  These commands
still reject the input.  This is a preparation step for OUTPUT generator
expression support.

Issue: #12877
2019-09-17 22:58:31 +02:00
Daniel Eiband
ccc9685cc1 Genex: Move genex expansion of paths into AppendPaths utility
Refactored internals of cmCustomCommandGenerator to make processing of path
lists (evaluation of generator expressions and expansion into a list) available
as AppendPaths utility function to be used for byproduct generator expression
support.
2019-09-17 22:58:31 +02:00
Brad King
1ac4e0ef1b Merge topic 'tidy-deprecated-headers'
f30523d090 clang-tidy: modernize-deprecated-headers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3792
2019-09-16 10:25:53 -04:00
Regina Pfeifer
f30523d090 clang-tidy: modernize-deprecated-headers 2019-09-16 10:11:13 -04:00
Sebastian Lipponer
c16641607f add_custom_command: Delay slash conversion until after genex evaluation
Generator expressions may contain or produce backslashes.

Fixes: #19553
2019-09-13 10:56:26 -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
Sebastian Holtermann
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Brad King
3a3e59617a Merge topic 'fix-emulator-arguments'
bf6f5467a0 Fix allocation in CROSSCOMPILING_EMULATOR evaluation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3591
2019-07-24 08:16:10 -04:00
Marek Antoniak
bf6f5467a0 Fix allocation in CROSSCOMPILING_EMULATOR evaluation
In commit fec441ec17 (Teach CROSSCOMPILING_EMULATOR to support
arguments, 2019-05-30, v3.15.0-rc1~6^2) the new member
`cmCustomCommandGenerator::EmulatorsWithArguments` was not initialized
to the proper size.  Fix this and add a test case covering the crash
that could occur with multiple commands where an emulator appears only
in a later command.

Fixes: #19500
Co-Author: Brad King <brad.king@kitware.com>
2019-07-23 08:33:31 -04:00
Brad King
71fbebd1dc IWYU: Fix handling of <memory> standard header
An old workaround for `std::allocator_traits<>::value_type` lints from
IWYU on `std::vector<>` usage breaks IWYU's handling of `<memory>`.
Convert the workaround to use the same approach we already use for a
workaround of `std::__decay_and_strip<>::::__type` lints.  Then update
the `<memory>` inclusions to follow the now-correct IWYU lints.
2019-07-10 11:48:56 -04:00
Marek Antoniak
fec441ec17 Teach CROSSCOMPILING_EMULATOR to support arguments
Fixes: #19321
2019-06-03 10:17:17 -04:00
Sebastian Holtermann
006229278b Use cmAppend to append ranges to std::vector instances 2019-05-23 16:19:49 +02:00
Regina Pfeifer
5a0784ddea clang-tidy: Pass by value 2019-01-22 13:03:04 -05:00