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.
ExternalProject: Add options to specify BYPRODUCTS (#14963)

The external project's build process may generate byproducts on which
other rules in the driving project's build later depend.  Provide a way
for the driving project to specify what byproducts it expects to be made
available by the custom commands that drive the external project.
Merge branch 'doc-target_include_directories-fixup' into release
Merge branch 'doc-sphinx-cmake-fixup' into release
Merge branch 'vs-check-phone-store-tools' into release
CPackRPM: Unset temporary component variables before re-use

Improve the fix from commit v2.8.9~136^2 (CPackRPM: avoid leakage of RPM
directive from one component to another, 2012-06-05) to clean up more
temporary variables.

Reviewed-by: Domen Vrankar <domen.vrankar@gmail.com>
ccmake: Remove incomplete support for cur_colr on old HP-UX

Enable support for the more modern Xcurses.
ccmake: Use standard getmaxyx instead of non-standard getmax[xy]

Swap out getmax[xy]() calls for single call to getmaxyx(), to support
strict X/Open conformant curses implementations, e.g. HP-UX Xcurses.
ccmake: Cleanup and simplify conditional blocks for HP-UX
QtAutogen: Don't take a reference to temporary.

While a const reference to a temporary is standard conformant,
it doesn't seem to be necessary or advantageous here.
QtAutogen: Use cmHasLiteral{Prefix,Suffix} where possible.
file(GENERATE): Re-run cmake when appropriate.

Re-run if the input file changes or if the output file is removed.

This only works with the Makefile generators currently.  The limitation
of the Ninja generator is tracked as issue #15256.  The IDE
generators will need larger refactoring as they currently rely on
being able to determine the depends and output files at the start of
generate-time, which is too early for the file(GENERATE) case.
Build CMake with most-recent available language dialect.

When CMake is built with CMake 3.1 or later, appropriate -std=
options will be added for GNU and Clang compilers while building
C and CXX code.

This allows taking advantage of 'hidden' language features such
as move-constructors, and allows the standard library to enable
the use of more-advanced features too, where available.

This does not change CMake host compiler requirements.
Features: Test the CXX compiler only if it has features.

If using different C and CXX compilers, we might not have a
feature-full CXX compiler at this point.
Features: Fix references to CXX compiler version in Clang-C.cmake.
CMake Nightly Date Stamp
Features: Record C++11 dialect switch only for GNU 4.7 and later.

Previous versions of GNU are not currently supported by this
CMake feature.
FindJava: Do not accept OS X stub 'java' as Java

OS X provides a stub 'java' to inform callers that Java is not present.
When checking the 'java -version' output, look for such a message and if
found pretend 'java' was not found.

Suggested-by: Sean McBride <sean@rogue-research.com>
Merge branch 'FindJava-no-osx-stub' into release
Avoid if() quoted auto-dereference when checking for "MSVC"

When testing CMAKE_<LANG>_COMPILER_ID values against "MSVC", do not
allow the definition of the "MSVC" variable to be expanded.