From e993e2c52c989b80f02ca4bebfa338f399cf08c7 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sat, 19 Mar 2022 17:33:01 +1100 Subject: Help: Clean up INITIALIZE_FROM_VARIABLE define_property() option INITIALIZE_FROM_VARIABLE is new in CMake 3.23, but the versionadded note was missing in the original commit. The docs also failed to mention that the new option only applies to target properties. Amends fce24e4f10 (define_property(): Add INITIALIZE_FROM_VARIABLE argument, 2022-01-13) --- Help/command/define_property.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Help/command/define_property.rst b/Help/command/define_property.rst index cd75dea..82d6a0a 100644 --- a/Help/command/define_property.rst +++ b/Help/command/define_property.rst @@ -63,7 +63,9 @@ the documentation. The ``BRIEF_DOCS`` and ``FULL_DOCS`` options are optional. -The ``INITIALIZE_FROM_VARIABLE`` option is followed by the name of a variable -from which to initialize the property. The variable name must end with the -property name, must have a prefix before the property name, and must not begin -with ``CMAKE_`` or ``_CMAKE_``. +.. versionadded:: 3.23 + + The ``INITIALIZE_FROM_VARIABLE`` option specifies a variable from which the + property should be initialized. It can only be used with target properties. + The ```` name must end with the property name, must have a prefix + before the property name, and must not begin with ``CMAKE_`` or ``_CMAKE_``. -- cgit v0.12 From 9b50f221f6208a9dc3a993ddd4ceca21382bcf44 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sat, 19 Mar 2022 17:01:33 +1100 Subject: Help: Update the main purpose of define_property() The BRIEF_DOCS and FULL_DOCS are remnants from before the Sphinx-based documentation when CMake's internal structures for defining properties included fields for their documentation. They are no longer mandatory for define_property() and haven't been in practical use for some time. The main use of the command has evolved to now be more about how to initialize and inherit properties, so update the docs to reflect that change in focus. Issue: #20698 --- Help/command/define_property.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Help/command/define_property.rst b/Help/command/define_property.rst index 82d6a0a..c882347 100644 --- a/Help/command/define_property.rst +++ b/Help/command/define_property.rst @@ -13,11 +13,13 @@ Define and document custom properties. [INITIALIZE_FROM_VARIABLE ]) Defines one property in a scope for use with the :command:`set_property` and -:command:`get_property` commands. This is primarily useful to associate -documentation with property names that may be retrieved with the -:command:`get_property` command. The first argument determines the kind of -scope in which the property should be used. It must be one of the -following: +:command:`get_property` commands. It is mainly useful for defining the way +a property is initialized or inherited. Historically, the command also +associated documentation with a property, but that is no longer considered a +primary use case. + +The first argument determines the kind of scope in which the property should +be used. It must be one of the following: :: @@ -56,8 +58,8 @@ out the contents to append to. The ``BRIEF_DOCS`` and ``FULL_DOCS`` options are followed by strings to be associated with the property as its brief and full documentation. -Corresponding options to the :command:`get_property` command will retrieve -the documentation. +CMake does not use this documentation other than making it available to the +project via corresponding options to the :command:`get_property` command. .. versionchanged:: 3.23 -- cgit v0.12 From 87c3b5e421b3f39d52caa113da4b577c6b68fa03 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sat, 19 Mar 2022 17:03:26 +1100 Subject: define_property(): Only test prefix if INITIALIZE_FROM_VARIABLE is given --- Source/cmDefinePropertyCommand.cxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 7a2f34f..15b2652 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -97,20 +97,20 @@ bool cmDefinePropertyCommand(std::vector const& args, PropertyName, "\"")); return false; } - } - // Make sure the variable is not reserved. - static constexpr const char* reservedPrefixes[] = { - "CMAKE_", - "_CMAKE_", - }; - if (std::any_of(std::begin(reservedPrefixes), std::end(reservedPrefixes), - [&initializeFromVariable](const char* prefix) { - return cmHasPrefix(initializeFromVariable, prefix); - })) { - status.SetError( - cmStrCat("variable name \"", initializeFromVariable, "\" is reserved")); - return false; + // Make sure the variable is not reserved. + static constexpr const char* reservedPrefixes[] = { + "CMAKE_", + "_CMAKE_", + }; + if (std::any_of(std::begin(reservedPrefixes), std::end(reservedPrefixes), + [&initializeFromVariable](const char* prefix) { + return cmHasPrefix(initializeFromVariable, prefix); + })) { + status.SetError(cmStrCat("variable name \"", initializeFromVariable, + "\" is reserved")); + return false; + } } // Actually define the property. -- cgit v0.12