1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-05-10 07:10:32 +08:00

113 Commits

Author SHA1 Message Date
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* 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.

Issue: #26123
2025-01-23 13:09:50 -05:00
Brad King
6973f8304e CMP0050: Remove support for OLD behavior 2025-01-19 09:41:03 -05:00
Craig Scott
30f596f417 Merge topic 'cmp0175-restore-USES_TERMINAL-for-TARGET-form'
62586f236c CMP0175: Do not reject USES_TERMINAL for add_custom_command(TARGET)

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10005
2024-11-16 16:16:48 -05:00
Craig Scott
62586f236c
CMP0175: Do not reject USES_TERMINAL for add_custom_command(TARGET)
Fixes: #26449
2024-11-16 10:02:01 +11:00
Brad King
659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Craig Scott
ec519f3e97
add_custom_command: Validate arguments more rigorously
Add a new CMP0175 policy to preserve backward compatibility
for projects that were using unsupported keywords or arguments.

Fixes: #26096, #21089, #18976
2024-09-10 08:19:09 +10:00
Juan Ramos
197cb419d1 add_custom_command: Add CODEGEN support
By specifying CODEGEN as an argument to add_custom_command the
custom command will be added to a codegen build target.

The intent is to provide a convenient way for users to get
their generated files without having to build the whole project.

This can be helpful for code analysis tools which can be useful
for IDEs and CI.
2024-07-01 12:02:49 -04:00
Juan Ramos
f9028379f7 cmAddCustomCommandCommand: Move SOURCE signature error messages
Helps readability of the code. All the SOURCE signature code is
in the else statement.
2024-05-16 09:00:30 -07:00
Ben Boeckel
45eff9145e cmAddCustomCommandCommand: use cmStrCat 2023-11-01 12:53:56 -04:00
Chris Mahoney
3825d6ec98 add_custom_{command,target}: Teach JOB_SERVER_AWARE about WORKING_DIRECTORY
Issue: #16273
2023-07-25 11:34:22 -04:00
Chris Mahoney
95941fd990 add_custom_{target,command}: Add argument JOB_SERVER_AWARE
Issue: #16273
2023-07-19 10:45:33 -04:00
Abdelmaged Khalifa
ea2a05f402 Add variable CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY
Add CMake variable `CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY` to enable
option `DEPENDS_EXPLICIT_ONLY` on all uses of `add_custom_command`.

Fixes: #17097
2023-02-17 17:12:12 +02:00
Abdelmaged Khalifa
082ccd7530 add_custom_command: Add DEPENDS_EXPLICIT_ONLY option for Ninja
Add option `DEPENDS_EXPLICIT_ONLY` to `add_custom_command` to indicate
that implicit dependencies coming from users of the output are not
needed, and only consider dependencies explicitly specified in the
custom command.

Fixes: #17097
2023-02-14 08:56:59 -05:00
NAKAMURA Takumi
780341f360 cmCustomCommand: Track main dependency explicitly
Store the main dependency as the first entry in the dependency list plus
a boolean member indicating its existence.  Note that this slightly
changes existing behavior: the main dependency was previously the last
entry of the dependency list.
2021-12-14 10:48:43 -05:00
NAKAMURA Takumi
3bb2542535 cmMakefile: Simplify Add*Command and adopt to cmAddCustom*Command 2021-11-18 12:02:38 -05:00
NAKAMURA Takumi
d0158b765b cmMakefile: Move CMP0116 lookup into Add{Custom,Utility}Command
Avoid repeating it at every call site.
2021-11-18 12:02:37 -05:00
Kyle Edwards
f01f10e8fb cmCustomCommand: Record value of CMP0116 at time of creation 2021-02-23 09:14:31 -05:00
Marc Chevrier
cfd8a5ac1f Makefiles: Add support of DEPFILE for add_custom_command
Issue: #20286
Fixes: #21415
2020-12-23 15:47:46 +01:00
Brad King
c257c25419 add_custom_{command,target}: Add genex support to OUTPUT and BYPRODUCTS
Move rejection of `#`, `<`, and `>` characters in outputs and byproducts
to a generate-time check.  This removes the front-end check that
disallowed generator expressions.  The generators have already been
updated to handle them.

Fixes: #12877
2020-12-11 08:24:21 -05:00
Brad King
b285748f79 cmAddCustom{Command,Target}Command: Skip conversions on genex paths
If an output or byproduct path starts in a generator expression, do not
convert it to a full path yet.  That will have to be done at generate
time after evaluating the generator expressions.

Also update the `add_custom_target` byproduct path conversion added by
commit 445ff5ccdf (Byproducts: collapse full paths of custom target
byproducts, 2019-09-11, v3.16.0-rc1~103^2~1) to match the behavior of
`add_custom_command` when a path starts in a generator expression.
2020-12-10 07:06:20 -05:00
Brad King
fab772c3e1 cmAddCustomCommandCommand: Drop outdated comment 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
Brad King
26464da5d3 cmMakefile: Drop unnecessary custom command APPEND check
Since commit 777ceaea94 (cmMakefile: Delay custom command creation,
2019-10-17, v3.17.0-rc1~352^2) we process custom command declarations
at generate time.  This includes the append-to-non-existing-command
check, so we do not need it at configure time.
2020-10-08 12:20:33 -04:00
Kyle Edwards
67102d3252 Ninja Multi-Config: Add support for DEPFILE option in add_custom_command()
And give other generators a path forward to add support in the future.
2020-02-07 14:18:54 -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
a5f44ec925 cmAddCustomCommandCommand: remove unnecessary braces 2019-12-18 09:50:15 -05:00
Daniel Eiband
777ceaea94 cmMakefile: Delay custom command creation
Move custom command creation to cmLocalGenerator and dispatch custom
commands in cmMakefile to generate time.  Generators add custom commands
using the new methods provided by cmLocalGenerator.

Issue: #12877
2019-11-24 20:32:43 +01:00
Daniel Eiband
f151a57705 cmMakefile: Move enumerations into new header
The enumerations will also be used in cmLocalGenerator.
2019-09-26 10:02:06 -04:00
Daniel Eiband
fd3a394614 add_custom_command: Format files in error message in a single line 2019-09-23 23:39:07 +02:00
Daniel Eiband
a1cc6b4447 add_custom_target: Add output checks for custom target byproducts
Use the output checks for byproducts of add_custom_command also for byproducts
of add_custom_target.
2019-09-23 22:18:36 +02:00
Daniel Eiband
cbb861ade8 add_custom_command: Add tests for custom command output checks 2019-09-23 22:15:31 +02:00
Asit Dhal
9dba84cfa5 Refactor: Use cmStrCat to construct error strings
Replace string construction using std::stringstream with cmStrCat and
cmWrap.
2019-09-18 14:18:46 -04:00
Brad King
7c47894b45 Merge topic 'prepare-deferred-custom-command-creation'
5d28e361b7 add_custom_command: Move append functionality into class cmMakefile
4fb29850ad add_custom_command: Refactor setting implicit depends

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3810
2019-09-16 10:18:51 -04:00
Daniel Eiband
5d28e361b7 add_custom_command: Move append functionality into class cmMakefile 2019-09-13 11:00:21 -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
Daniel Eiband
4fb29850ad add_custom_command: Refactor setting implicit depends
Implicit dependencies are now passed as argument to AddCustomCommandToOutput.
This is necessary to be able to delay custom command creation.
2019-09-12 23:00:36 +02: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
Regina Pfeifer
d331021255 clang-tidy: isolate declarations for readability 2019-08-21 00:20:49 +02:00
Regina Pfeifer
9ba0bf60c6 cmA*Command: Turn into free functions
Ref: #19499
2019-08-07 10:16:32 +02:00
Sebastian Holtermann
f1bdfdf242 cmAddCustomCommand: Initialize static std::unordered_set on construction 2019-06-04 18:11:19 +02:00
Rosen Matev
9f76961de8 Support job pools in custom commands and targets
Provide a way for custom commands and targets to set the pool variable
of the ninja build statement. Setting `JOB_POOL` is not compatible with
`USES_TERMINAL`, which implies the `console` pool.

The option is silently ignored with other generators.

Closes: #18483
2019-05-14 15:58:00 +02: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
Brad King
98d59417b0 add_custom_{command,target}: Fix WORKING_DIRECTORY leading genex
Since commit v3.13.0-rc1~39^2 (add_custom_{command,target}:
WORKING_DIRECTORY generator expressions, 2018-09-22) the
`WORKING_DIRECTORY` option accepts generator expressions.
Fix support for the case of a leading generator expression
by deferring conversion to an absolute path until after
evaluation of the generator expression.

Fixes: #18543
2018-11-03 08:39:45 -04:00
Vitaly Stakhovsky
c8fd23ec6f cmMakefile: return directories as const std::string& 2018-08-27 14:07:43 -04:00
Brad King
f8ca0ab3ac Merge topic 'std-string-apis'
653b8946 Reduce raw string pointers usage.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1729
2018-02-01 08:05:33 -05:00
Ben Boeckel
f9235fd474 cmAddCustomCommandCommand: use std::string const& for FileIsFullPath 2018-01-31 11:04:35 -05:00
Ben Boeckel
c0e7a13702 cmAddCustomCommandCommand: store keywords in strings
Callgrind indicated that `strlen` was being called a lot of times here
due to the string comparisons. Since keywords are "sparse" in
`add_custom_command`, use a hash comparison to handle keywords and then
use strings for comparison since they have a built-in length parameter.
2018-01-31 11:03:51 -05: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
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 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