As mentioned in the documentation of the set command, each directory added with add_subdirectory or each function declared with function creates a new scope.
The new child scope inherits all variable definitions from its parent scope. Variable assignments in the new child sope with the set command will only be visible in the child scope unless the PARENT_SCOPE option is used.
The new child scope inherits all variable definitions from its parent scope. Variable assignments in the new child sope with the set command will only be visible in the child scope unless the PARENT_SCOPE option is used.