Files
CMake/Tests/RunCMake/GenEx-TARGET_PROPERTY/RunCMakeTest.cmake
Brad King e0bbe79cea CMP0189: Restore support for linking $<TARGET_PROPERTY:tgt,LINK_LIBRARIES>
In general we disallow references to transitive target properties, such
as `COMPILE_DEFINITIONS`, in `[INTERFACE_]LINK_LIBRARIES` properties,
because the latter establish the transitivity itself.  Prior to CMP0189,
the `[INTERFACE_]LINK_LIBRARIES` properties were not themselves transitive
in `$<TARGET_PROPERTY>` expressions, so existing projects have code like

    target_link_libraries(foo PRIVATE "$<TARGET_PROPERTY:tgt,LINK_LIBRARIES>")

Policy CMP0189's NEW behavior, introduced by commit b3da9c6d60 (GenEx:
Evaluate LINK_LIBRARIES target properties transitively, 2025-02-24,
v4.1.0-rc1~731^2), makes `$<TARGET_PROPERTY:tgt,LINK_LIBRARIES>`
transitive, causing the above to be rejected.  Since evaluation of a
target's link libraries can already encounter and handle other targets'
link libraries, allow it in this case.

Fixes: #27265
2025-09-29 10:51:01 -04:00

35 lines
1.0 KiB
CMake

include(RunCMake)
run_cmake(ALIAS_GLOBAL)
run_cmake(BadInvalidName)
run_cmake(BadNonTarget)
run_cmake(BadSelfReference)
run_cmake(INCLUDE_DIRECTORIES)
run_cmake(LinkImplementationCycle1)
run_cmake(LinkImplementationCycle2)
run_cmake(LinkImplementationCycle3)
run_cmake(LinkImplementationCycle4)
run_cmake(LinkImplementationCycle5)
run_cmake(LinkImplementationCycle6)
run_cmake(SOURCES)
run_cmake(TransitiveBuild)
run_cmake(TransitiveLink-CMP0166-OLD)
run_cmake(TransitiveLink-CMP0166-NEW)
run_cmake(Unset)
function(run_LinkLikewise case)
run_cmake(LinkLikewise-${case})
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/LinkLikewise-${case}-build)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(LinkLikewise-${case}-build ${CMAKE_COMMAND} --build . --config Debug)
endfunction()
run_LinkLikewise(CMP0189-OLD)
run_LinkLikewise(CMP0189-NEW)
block()
run_cmake(Scope)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Scope-build)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(Scope-build ${CMAKE_COMMAND} --build . --config Debug)
endblock()