Files
CMake/Help/generator/Unix Makefiles.rst
Daksh Mamodiya 503bdb9777 Makefile: Generate test_prep targets for CMAKE_TEST_BUILD_DEPENDS
Extend the test_prep/<test> and test_prep/all build targets, generated
from add_test(BUILD_DEPENDS) when CMAKE_TEST_BUILD_DEPENDS is enabled, to
the Makefile generators.  Previously only the Ninja and FASTBuild
generators provided them.

Resolve each test's dependencies in a shared layer so all command-line
generators consume one result.  cmTestGenerator now filters target
dependencies to build-system targets and records, for each file
dependency, the single target that produces it as a primary
custom-command output (cmGlobalGenerator::FindOutputOwningTarget).  The
Makefile generators emit phony rules in CMakeFiles/Makefile2 depending on
<target>.dir/all, with top-level forwarding rules.  Sharing the
resolution also stops Ninja and FASTBuild from emitting a dead test_prep
edge for a non-buildable (e.g. INTERFACE) BUILD_DEPENDS target.

On the Makefile generators a file dependency that no single target
produces, and a test whose name contains ':', cannot be expressed as a
recursive-make rule and are reported with a warning and skipped.

Fixes: #27879
2026-06-24 17:24:54 +02:00

52 lines
1.8 KiB
ReStructuredText

Unix Makefiles
--------------
Generates standard UNIX makefiles.
A hierarchy of UNIX makefiles is generated into the build tree. Use
any standard UNIX-style make program to build the project through
the ``all`` target and install the project through the ``install``
(or ``install/strip``) target.
For each subdirectory ``sub/dir`` of the project a UNIX makefile will
be created, containing the following targets:
``all``
Depends on all targets required by the subdirectory.
``install``
Runs the install step in the subdirectory, if any.
``install/strip``
Runs the install step in the subdirectory followed by a ``CMAKE_STRIP`` command,
if any.
The ``CMAKE_STRIP`` variable will contain the platform's ``strip`` utility, which
removes symbols information from generated binaries.
``test``
Runs the test step in the subdirectory, if any.
``package``
Runs the package step in the subdirectory, if any.
.. versionadded:: 4.5
When the :variable:`CMAKE_TEST_BUILD_DEPENDS` variable is enabled, the
top-level makefile additionally provides the following targets:
``test_prep/<test-name>``
Builds all known build dependencies for the test named ``<test-name>``
added by :command:`add_test`, including the executable target invoked by
the test, targets referenced by generator expressions in the test command,
and explicit ``BUILD_DEPENDS`` entries. A ``BUILD_DEPENDS`` file is built
by building the target whose build produces it.
Tests whose names are not valid target names, and tests whose names
contain a ``:`` character, are excluded. If multiple tests in different
directories share the same name, their dependencies are merged into one
``test_prep/<test-name>`` target.
``test_prep/all``
Depends on every generated ``test_prep/<test-name>`` target.