mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
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
20 lines
525 B
CMake
20 lines
525 B
CMake
cmake_minimum_required(VERSION 4.3)
|
|
set(CMAKE_TEST_BUILD_DEPENDS ON)
|
|
|
|
project(TestDependencyInterface C)
|
|
|
|
enable_testing()
|
|
|
|
add_executable(TestDependencyInterfaceExe main.c)
|
|
|
|
# Header-only INTERFACE library is not part of the build system and must be
|
|
# filtered out of the test_prep dependencies so that no dead
|
|
# "TestDependencyIface.dir/all" prerequisite is generated.
|
|
add_library(TestDependencyIface INTERFACE)
|
|
|
|
add_test(NAME InterfaceTest
|
|
COMMAND
|
|
TestDependencyInterfaceExe
|
|
BUILD_DEPENDS
|
|
TestDependencyIface)
|