Commit Graph

72 Commits

Author SHA1 Message Date
Ben Boeckel
b0177003e1 cmGlobalNinjaGenerator: tell ninja to actually read the depfile
But only do so if the depfile is not specified as an output of the
command. Otherwise the command will out-of-date itself as `ninja`
deletes depfiles that it incorporates into the database and a missing
output will cause the command to run again.
2023-11-01 14:08:18 -04:00
Martin Duffy
ec2ba29ac5 Ninja: Allow compilation before generation of dependencies' private sources
This requires knowing when a generated header is public, which we can
model using file sets.  Add policy CMP0154 to treat generated sources
as private by default in targets with file sets.  Generated public
headers can be specified in public file sets.

Fixes: #24959
Issue: #15555
2023-09-20 10:25:24 -04:00
Craig Scott
feca1d51ff Merge topic 'doc-fixups-release-3.27'
78e7ea598d cmLocalGenerator: Fix trivial spelling error in code comment
1285fe27ff Help: Improve formatting and fix wording for ENABLE_EXPORTS
91336d061c Help: Improve formatting and cross-references for DEPENDS_EXPLICIT_ONLY
03208d9e18 Help: Fix indenting within TARGET_RUNTIME_DLLS genex docs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8688
2023-08-07 18:10:56 -04:00
Craig Scott
91336d061c
Help: Improve formatting and cross-references for DEPENDS_EXPLICIT_ONLY 2023-08-04 19:16:28 +10:00
Brad King
88c6dc75ba Merge topic 'command-job-server-aware'
95941fd990 add_custom_{target,command}: Add argument JOB_SERVER_AWARE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8547
2023-07-20 10:23:31 -04:00
Chris Mahoney
95941fd990 add_custom_{target,command}: Add argument JOB_SERVER_AWARE
Issue: #16273
2023-07-19 10:45:33 -04:00
Brad King
d1538805b5 Merge topic 'doc-add_custom_command'
e588d29eaf Help: add_custom_command(TARGET) does not support USES_TERMINAL

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: William Jones <william.luke.jones@gmail.com>
Merge-request: !8602
2023-06-29 11:49:35 -04:00
Brad King
e588d29eaf Help: add_custom_command(TARGET) does not support USES_TERMINAL
Build events are attached to existing build statements so we cannot
independently control the job pool.

Issue: #25040
2023-06-29 10:57:38 -04:00
Brad King
536c1de1d4 Drop Visual Studio 11 2012 generator
This generator has been deprecated since CMake 3.25.  Remove it.
2023-06-13 14:20:48 -04:00
Craig Scott
949dcdb3bc
Help: Clarify PRE_BUILD option for add_custom_command()
Fixes: #24889
2023-05-19 12:40:36 +10: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
Brad King
abddcd370f Help: Clarify add_custom_command OUTPUT relative path behavior
Issue: #24372
2023-01-30 13:50:01 -05:00
Brad King
303c48fbd4 Help: Add add_custom_command example with output consumed by multiple targets
This is a common use case, so add an example demonstrating it.
2022-12-08 15:12:32 -05:00
Brad King
5f2bf6ecc6 Help: Drop misleading add_custom_command "makefile terms" explanation
The "In makefile terms" explanation is left from very early days of
CMake to help developers migrating from hand-written makefiles.
These days it is often misinterpreted, particularly in the context
of multiple `add_custom_command` calls, to mean that we generate a
single Makefile containing rules for all custom commands.  This
leads to an incorrect mental model of the expressed build system.
The actual generated build system may spread the rules across multiple
targets that do not see the each other's file-level rules, which makes
target-level dependencies important too.
2022-12-07 18:39:37 -05: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
Alex Turbov
65457e4fae
Help: Add _See Also_ sections to related CMake commands 2022-11-09 23:52:30 +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
Hinell
00b788e85e Help:custom_command: link policy on BYPRODUCTS
Link policy explaining BYPRODUCTS.

Fixes: #23786
2022-09-16 10:50:46 -04:00
Craig Scott
8cf8f4d13b Help: State behavior for add_custom_command(TARGET) without event type
Projects should always have specified one of PRE_BUILD, PRE_LINK or
POST_BUILD, and the documentation has always shown that one must
be given. But the argument parsing logic was such that if none was given,
POST_BUILD would be used and no error or warning would be raised.
Projects may be relying on this behavior, so document it as formally
supported, but not recommended.

Fixes: #23488
2022-06-04 18:35:37 +10:00
Marc Chevrier
8d7e80cf3d find_* commands: add control over Windows registry views
Fixes: #22775
2022-04-29 22:00:02 +02:00
Marc Chevrier
e04a352cca Depfile parsing: enhance compatibility with GNU Make 2022-01-16 14:05:59 +01:00
Marc Chevrier
8a3aac990e Help: add_custom_command: describes depfile format 2022-01-11 12:51:11 +01:00
Craig Scott
f6e5743d0e Help: Clarify and correct wording around DEPFILE option
The previous wording contradicted itself regarding whether
Visual Studio generators were supported, and about when
generator expressions could be used. Restructure the paragraphs
and max it clearer what support was added in which CMake
versions.
2021-07-24 15:08:21 +10:00
Brad King
526e2ef71c VS: Add support for add_custom_command DEPFILE
Transform the depfile into MSBuild `AdditionalInputs` content.  Add
MSBuild Targets to update `AdditionalInputs` and the `.tlog` files for
future builds without actually modifying the `.vcxproj` file.

Fixes: #20286
2021-06-09 10:09:58 -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
Craig Scott
2f59b683d3 Help: Custom OUTPUT and BYPRODUCTS genexes cannot refer to targets
Relates: #21364
2021-03-25 18:04:17 +11:00
Brad King
5dd356cefc Help: Convert some genex names to explicit cross-references
Since commit c2dc7e0f53 (Help: Convert genex documentation to sphinx
domain objects, 2021-01-15) we can use `:genex:` cross-references to
link to named generator expressions.  Update some places to do this.

This is meant to demonstrate the capability, not as a comprehensive
sweep.
2021-02-05 16:05:25 -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
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
2b1cc175ee Help: Clarify version adding add_custom_{command,target} OUTPUT genex support
Update the documentation added by commit c257c25419
(add_custom_{command,target}: Add genex support to OUTPUT and
BYPRODUCTS, 2020-10-19) to use sphinx markup instead of prose to specify
the version in which the feature was added.
2020-12-15 07:00:20 -05: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
c523d1cc32 Help: Add examples to add_custom_command reference documentation 2020-12-10 07:06:19 -05:00
Nikita Nemkin
c705279bae Help: Add .. versionadded directives to commands documentation
This change ony concerns directives that appear in the document body.

The guidelines for inserting version directives:

 * Baseline version is CMake 3.0, i.e. directives start at 3.1.
 * Always use `.. versionadded::` directive, avoid ad-hoc version
   references. Exception: policy pages.
 * For new command signatures, put `versionadded` on a separate line
   after the signature.
 * For a group of new signatures in a new document section,
   a single version note at the beginning of the section is sufficient.
 * For new options, put `versionadded` on a separate line before
   option description.
 * If all the option descriptions in the list are short one-liners,
   it's fine to put `versionadded` on the same line as the description.
 * If multiple option descriptions in close proximity would have
   the same ..versionadded directive, consider adding a single
   directive after the list, mentioning all added options.
 * For compact value lists and sub-option lists, put a single
  `versionadded` directive after the list mentioning all additions.
 * When a change is described in a single paragraph, put
   `versionadded` into that paragraph.
 * When only part of the paragraph has changed, separate the changed
   part if it doesn't break the flow. Otherwise, write a follow-up
   clarification paragraph and apply version directive to that.
 * When multiple version directives are close by, order earlier
   additions before later additions.
 * Indent related lists and code blocks to include them in the scope
   of `versionadded` directive.

Issue: #19715
2020-11-09 20:51:57 +05:00
Kyle Edwards
146e1e6ba1 Ninja: Transform DEPFILEs with policy CMP0116
Fixes: #21267
2020-10-13 10:19:46 -04:00
Robert Maynard
f14b390198 GenEx: Remove unneeded dependencies from target info queries
Only generate a graph dependency between a custom command and
a target when the custom command queries for the file path
of an artifact of the target.

This makes generator expressions such as `TARGET_FILE_DIR`
behave the same way as `TARGET_PROPERTY` which never generated
a graph dependency.
2020-09-01 09:25:19 -04:00
FeRD (Frank Dana)
3eb2b62d21 Help: Expand discussion of GENERATED / BYPRODUCTS
- Mention the Makefile Generators' `make clean` removal in the
  BYPRODUCTS section of add_custom_command and add_custom_target
- Expand the GENERATED property docs' description of which files will
  be marked with the property, and of what it implies (including
  `make clean` removal)
2020-03-12 11:55:10 -04:00
Brad King
785f2b2df1 Help: Clarify add_custom_command DEPENDS conversion to file paths
In commit f5126badd8 (add_custom_command: convert DEPENDS path arguments
to absolute paths, 2019-12-18, v3.17.0-rc1~263^2) we updated the
documentation to describe the behavior introduced by that commit.
However, the behavior was removed again by commit fd0ba705ce
(add_custom_command: check if a relative path should be an in-source
path, 2020-01-09, v3.17.0-rc1~141^2~4) without updating the
documentation.

Update the documentation again to describe the behavior as of the latter
commit.  Spell out the steps that `cmLocalGenerator::GetRealDependency`
and `cmTargetTraceDependencies::IsUtility` use to add file-level and
target-level dependencies.
2020-03-06 08:44:46 -05: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 Aldorasi
64f40c5d09 Help: Both add_custom_command signatures support COMMAND_EXPAND_LISTS 2019-11-11 13:07:11 -05:00
Craig Scott
c6f08a2125 Help: Clarify how target names are handled in custom commands/targets
Fixes: #19771
2019-10-05 23:11:14 +10:00
Daniel Eiband
f6574c9a81 Depend: Hook up automatic target-level dependencies via byproducts
Target-level dependencies to utility targets are added from another target if
the other target requires a byproduct of the utility target or if it requires a
byproduct of PRE_BUILD, PRE_LINK, or POST_BUILD build events of a target.

Issue: #19005
2019-09-12 16:03:12 +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
Joachim Wuttke (o)
adbaadf0ee Help: Apply syntax highlighting to project commands
* Replace most "::" by ".. code-block:: cmake"
  * Header sentence in imperative voice,
    detailed command description in present tense.
2018-10-25 13:47:31 +02:00
Jon Chronopoulos
f158ac19e1 add_custom_{command,target}: WORKING_DIRECTORY generator expressions
This teaches add_custom_command and add_custom_target WORKING_DIRECTORY
about generator expressions

Fixes: #14089
2018-09-28 11:15:33 -04:00
Brad King
6dd11ffbde Help: Clarify add_custom_command build event execution order
Fixes: #17949
2018-05-02 13:19:00 -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