mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-04 14:50:23 +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:
committed by
Brad King
parent
e769e61f99
commit
65198cfd0f
@@ -3838,7 +3838,16 @@ void cmMakefile::RaiseScope(const std::string& var, const char* varDef)
|
|||||||
std::ostringstream m;
|
std::ostringstream m;
|
||||||
m << "Cannot set \"" << var << "\": current scope has no parent.";
|
m << "Cannot set \"" << var << "\": current scope has no parent.";
|
||||||
this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
|
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,
|
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(NoWatcher)
|
||||||
run_cmake(WatchTwice)
|
run_cmake(WatchTwice)
|
||||||
run_cmake(ModifyWatchInCallback)
|
run_cmake(ModifyWatchInCallback)
|
||||||
|
run_cmake(RaiseInParentScope)
|
||||||
|
|||||||
Reference in New Issue
Block a user