Help: Document TARGET_PROPERTY genex behavior on unset property

Also add an explicit test for the case.

Fixes: #25968
This commit is contained in:
Brad King
2024-05-10 09:50:02 -04:00
parent 2e5b40f581
commit d6bda72981
4 changed files with 14 additions and 4 deletions

View File

@@ -1751,7 +1751,8 @@ These expressions look up the values of
.. genex:: $<TARGET_PROPERTY:tgt,prop>
Value of the property ``prop`` on the target ``tgt``.
Value of the property ``prop`` on the target ``tgt``, or empty if
the property is not set.
Note that ``tgt`` is not added as a dependency of the target this
expression is evaluated on.
@@ -1767,9 +1768,10 @@ These expressions look up the values of
:target: TARGET_PROPERTY:prop
Value of the property ``prop`` on the target for which the expression
is being evaluated. Note that for generator expressions in
:ref:`Target Usage Requirements` this is the consuming target rather
than the target specifying the requirement.
is being evaluated, or empty if the property is not set.
Note that for generator expressions in :ref:`Target Usage Requirements`
this is the consuming target rather than the target specifying the
requirement.
The expressions have special evaluation rules for some properties:

View File

@@ -16,6 +16,7 @@ run_cmake(SOURCES)
run_cmake(TransitiveBuild)
run_cmake(TransitiveLink-CMP0166-OLD)
run_cmake(TransitiveLink-CMP0166-NEW)
run_cmake(Unset)
block()
run_cmake(Scope)

View File

@@ -0,0 +1,4 @@
file(READ ${RunCMake_TEST_BINARY_DIR}/out.txt out)
if(NOT out STREQUAL "'' ''")
set(RunCMake_TEST_FAILED "PROPERTY_THAT_IS_NOT_SET did not evaluate as empty:\n ${out}")
endif()

View File

@@ -0,0 +1,3 @@
add_library(iface INTERFACE)
file(GENERATE OUTPUT out.txt CONTENT
"'$<TARGET_PROPERTY:iface,PROPERTY_THAT_IS_NOT_SET>' '$<TARGET_PROPERTY:PROPERTY_THAT_IS_NOT_SET>'" TARGET iface)