mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 03:59:58 +00:00
variable_watch: trigger on variables set via PARENT_SCOPE
Make sure that we also trigger variable watches when a variable is set in the parent scope. Fixes: #17827
This commit is contained in:
parent
e769e61f99
commit
65198cfd0f
@ -3838,7 +3838,16 @@ void cmMakefile::RaiseScope(const std::string& var, const char* varDef)
|
||||
std::ostringstream m;
|
||||
m << "Cannot set \"" << var << "\": current scope has no parent.";
|
||||
this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
cmVariableWatch* vv = this->GetVariableWatch();
|
||||
if (vv) {
|
||||
vv->VariableAccessed(var, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
|
||||
varDef, this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
|
||||
|
@ -0,0 +1,2 @@
|
||||
var MODIFIED_ACCESS a
|
||||
var MODIFIED_ACCESS b
|
15
Tests/RunCMake/variable_watch/RaiseInParentScope.cmake
Normal file
15
Tests/RunCMake/variable_watch/RaiseInParentScope.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
function(watch variable access value)
|
||||
message("${variable} ${access} ${value}")
|
||||
endfunction ()
|
||||
|
||||
# --------------
|
||||
|
||||
variable_watch(var watch)
|
||||
set(var "a")
|
||||
|
||||
function(f)
|
||||
set(var "b" PARENT_SCOPE)
|
||||
endfunction(f)
|
||||
|
||||
f()
|
@ -4,3 +4,4 @@ run_cmake(ModifiedAccess)
|
||||
run_cmake(NoWatcher)
|
||||
run_cmake(WatchTwice)
|
||||
run_cmake(ModifyWatchInCallback)
|
||||
run_cmake(RaiseInParentScope)
|
||||
|
Loading…
Reference in New Issue
Block a user