From d6bda72981974888049fb2441e96f578d2d3deae Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 10 May 2024 09:50:02 -0400 Subject: Help: Document TARGET_PROPERTY genex behavior on unset property Also add an explicit test for the case. Fixes: #25968 --- Help/manual/cmake-generator-expressions.7.rst | 10 ++++++---- Tests/RunCMake/GenEx-TARGET_PROPERTY/RunCMakeTest.cmake | 1 + Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset-check.cmake | 4 ++++ Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset.cmake | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset-check.cmake create mode 100644 Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset.cmake diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index f8c722b..49d94ef 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1751,7 +1751,8 @@ These expressions look up the values of .. genex:: $ - 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: diff --git a/Tests/RunCMake/GenEx-TARGET_PROPERTY/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-TARGET_PROPERTY/RunCMakeTest.cmake index 07052eb..c278831 100644 --- a/Tests/RunCMake/GenEx-TARGET_PROPERTY/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-TARGET_PROPERTY/RunCMakeTest.cmake @@ -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) diff --git a/Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset-check.cmake b/Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset-check.cmake new file mode 100644 index 0000000..59910f1 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset-check.cmake @@ -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() diff --git a/Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset.cmake b/Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset.cmake new file mode 100644 index 0000000..dfe24a2 --- /dev/null +++ b/Tests/RunCMake/GenEx-TARGET_PROPERTY/Unset.cmake @@ -0,0 +1,3 @@ +add_library(iface INTERFACE) +file(GENERATE OUTPUT out.txt CONTENT + "'$' '$'" TARGET iface) -- cgit v0.12