CMake/Help
Brad King e15a7075b5 Add an option for explicit BYPRODUCTS of custom commands (#14963)
A common idiom in CMake-based build systems is to have custom commands
that generate files not listed explicitly as outputs so that these
files do not have to be newer than the inputs.  The file modification
times of such "byproducts" are updated only when their content changes.
Then other build rules can depend on the byproducts explicitly so that
their dependents rebuild when the content of the original byproducts
really does change.

This "undeclared byproduct" approach is necessary for Makefile, VS, and
Xcode build tools because if a byproduct were listed as an output of a
rule then the rule would always rerun when the input is newer than the
byproduct but the byproduct may never be updated.

Ninja solves this problem by offering a 'restat' feature to check
whether an output was really modified after running a rule and tracking
the fact that it is up to date separately from its timestamp.  However,
Ninja also stats all dependencies up front and will only restat files
that are listed as outputs of rules with the 'restat' option enabled.
Therefore an undeclared byproduct that does not exist at the start of
the build will be considered missing and the build will fail even if
other dependencies would cause the byproduct to be available before its
dependents build.

CMake works around this limitation by adding 'phony' build rules for
custom command dependencies in the build tree that do not have any
explicit specification of what produces them.  This is not optimal
because it prevents Ninja from reporting an error when an input to a
rule really is missing.  A better approach is to allow projects to
explicitly specify the byproducts of their custom commands so that no
phony rules are needed for them.  In order to work with the non-Ninja
generators, the byproducts must be known separately from the outputs.

Add a new "BYPRODUCTS" option to the add_custom_command and
add_custom_target commands to specify byproducts explicitly.  Teach the
Ninja generator to specify byproducts as outputs of the custom commands.
In the case of POST_BUILD, PRE_LINK, and PRE_BUILD events on targets
that link, the byproducts must be specified as outputs of the link rule
that runs the commands.  Activate 'restat' for such rules so that Ninja
knows it needs to check the byproducts, but not for link rules that have
no byproducts.
2014-11-14 16:16:00 -05:00
..
command Add an option for explicit BYPRODUCTS of custom commands (#14963) 2014-11-14 16:16:00 -05:00
generator VS: Implement CMAKE_GENERATOR_PLATFORM for VS >= 8 2014-09-05 15:03:56 -04:00
include Help: Factor out COMPILE_DEFINITIONS disclaimer duplication 2013-10-16 09:22:38 -04:00
manual FindIntl: New module to find Gettext libintl 2014-11-11 13:02:16 -05:00
module FindIntl: New module to find Gettext libintl 2014-11-11 13:02:16 -05:00
policy If: Introduce policy CMP0054 - don't dereference quoted variables in if() 2014-09-11 21:23:17 +02:00
prop_cache
prop_dir Help: Clarify add_compile_options documentation (#15225) 2014-10-29 09:18:56 -04:00
prop_gbl Help: Add missing external link marker. 2014-06-05 11:57:25 +02:00
prop_inst Help: Clarify formatting of CPACK_WIX_ACL documentation 2014-10-22 16:41:22 -04:00
prop_sf Help: Fix broken cross-references reported by 'nitpicky' option 2014-11-07 11:41:21 -05:00
prop_test allow to mark a test as "Not Run" with a specific return code (#8466) 2014-01-14 23:57:40 +01:00
prop_tgt Help: Document CMAKE_XCODE_ATTRIBUTE_<an-attribute> variable (#15215) 2014-10-22 08:52:12 -04:00
release Help: Add notes for topic 'console-pool' 2014-11-14 11:56:34 -05:00
variable Merge topic 'doc-CMAKE_INSTALL_PREFIX-link-GNUInstallDirs' 2014-11-12 09:35:43 -05:00
index.rst Help: Add a manual for compiler feature control. 2014-05-27 09:35:00 -04:00