Skip to content

define_property: Add documentation and unit tests for property redefinition

Frank Dana requested to merge ferdnyc/cmake:test-define-prop into master

Recently I became curious whether define_property() could be used on existing property definitions — would it update the definition? Was it an error to call define_property() if a property definition already exists?

From reading Source/cmDefinePropertyCommand.cxx and Source/cmPropertyDefinition.cxx, I found that attempts to redefine an existing property using define_property() are silently ignored. Once a property is defined for a given scope, it cannot be redefined and its definition cannot be modified.

But that didn't appear to actually be documented anywhere. Nor could I find any signs that the behavior was tested by the existing collection of unit tests.

So, this MR adds two things (in two commits):

  1. A § Property Redefinition, added to the define_property() documentation. (Perhaps a slightly misleading section title, arguably, since what it says is basically, "You can't." Better suggestions welcome.)

    The new section also contains a code example demonstrating how to define a new property with define_property(), then query and examine the definition using get_property().

  2. A set of basic unit tests for property redefinition, added to the RunCMake.define_property test (as a new define_property-redefine subtest), to confirm that the behavior of define_property() remains as expected based on the current implementation.

Edited by Frank Dana

Merge request reports