Files
cmake/Help/variable/CMAKE_TEST_BUILD_DEPENDS.rst
T
Martin Duffy ba6b6fbc24 Ninja: Add Build Dependencies for Tests
Add `test_prep/<test_name>` convenience targets to the ninja generator
to build dependencies of tests, and `test_prep/all` to build the dependencies
of all tests.

Build dependencies of a test include:
- Executables directly invoked by test `COMMAND`.
- Targets mentioned in generator expressionf os test `COMMAND`.
- Anything explicitly listed with the new `BUILD_DEPENDS` argument of `add_test`.

Issue: #27613
2026-05-26 15:16:19 -04:00

18 lines
761 B
ReStructuredText

CMAKE_TEST_BUILD_DEPENDS
------------------------
.. versionadded:: 4.4
Enable ``test_prep/<name>`` build targets for tests added by
:command:`add_test` when using the :ref:`Ninja Generators`.
When this variable is set to a true value, CMake generates a
``test_prep/<name>`` target for each eligible test and a ``test_prep/all``
target for all such tests. Building these targets ensures the test executable,
targets referenced by test command generator expressions, and explicit
``BUILD_DEPENDS`` entries are up-to-date before the test runs.
Tests whose names are not valid target names are excluded from this behavior.
If multiple tests in different directories share the same name, their
dependencies are merged into a single ``test_prep/<name>`` target.