Files
cmake/Tests/RunCMake/add_test/TestDependency-ON-invalid-test-name.cmake
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

21 lines
497 B
CMake

cmake_minimum_required(VERSION 4.3)
set(CMAKE_TEST_BUILD_DEPENDS ON)
project(TestDependencyInvalidTestName C)
enable_testing()
add_custom_target(TestDependencyPrereq
COMMAND
"${CMAKE_COMMAND}" -E touch
"${CMAKE_CURRENT_BINARY_DIR}/TestDependencyPrereq-built.txt"
BYPRODUCTS
"${CMAKE_CURRENT_BINARY_DIR}/TestDependencyPrereq-built.txt"
VERBATIM)
add_test(NAME "Target Build Test Invalid Name"
COMMAND
"${CMAKE_COMMAND}" -E true
BUILD_DEPENDS
TestDependencyPrereq)