Help: SYSTEM target property initialization docs ambiguious for imported targets
Explicitly setting the SYSTEM directory property to false has no effect for imported targets.
The docs for the SYSTEM
target property say that the property is initialised from the SYSTEM
directory property. But those docs also say SYSTEM
defaults to true for imported targets. These two statements conflict with each other.
Looking at the code, the SYSTEM
target property is set to true if either the target is imported or the SYSTEM
directory property is set to true. This means explicitly setting the SYSTEM
directory property to false will have no effect for imported targets. One cannot avoid having imported targets created with their SYSTEM
property being set to true (you can still modify the target property later though). The code doesn't appear to ever explicitly set the SYSTEM
directory property to false, so if it is set to false, that would have to be something the project explicitly did. In such situations, the only reason to do that would be to change the defaults for imported targets, since non-imported targets already default to SYSTEM
being off.
I think the logic should be that if the SYSTEM
directory property is set, then we shouldn't be looking at whether the target is imported or not. As this feature was only added in CMake 3.25, we should be able to modify this behavior in a 3.25.x patch release. Either way, the target property docs should be updated to no longer contradict itself.