Skip to content

block: Fix variable scope protection from modification by subdirectories

Brad King requested to merge brad.king/cmake:block-var-scope into master

When cmStateSnapshot::RaiseScope raises a variable in to a parent directory scope, it uses GetBuildsystemDirectoryParent to find the current top-most scope on the directory's stack. Since commit 3f4e5e8c, that depends on the DirectoryEnd field in the directory's state. However, when variable-only scopes were added by commit 6954c893, we neglected to account for the addition of that field by commit 52dbe654.

Prior to !7575 (merged) this problem went unnoticed because there was no way to have a variable scope at the top of a directory's stack while processing a subdirectory. Now the block()/endblock() commands enable the behavior, so fix tracking of a variable scope as the top-most scope in a directory.

Also rename DirectoryEnd to CurrentScope to clarify its role of tracking the active scope at the top of the stack in its directory.

Fixes: #24138 (closed)
Backport: release

Edited by Brad King

Merge request reports