diff options
author | Brad King <brad.king@kitware.com> | 2018-04-12 15:32:31 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-04-12 15:32:37 (GMT) |
commit | 2cdefcbe62707a82eccbc301fe34f85bb74d932a (patch) | |
tree | fca403211b0449955f38e3f7dfdb6ea9169e314a | |
parent | d59cd3b131a0c18d93fbc04f745bed990cfefa31 (diff) | |
parent | 65198cfd0f96d51269c748a84bafe27cf3312abd (diff) | |
download | CMake-2cdefcbe62707a82eccbc301fe34f85bb74d932a.zip CMake-2cdefcbe62707a82eccbc301fe34f85bb74d932a.tar.gz CMake-2cdefcbe62707a82eccbc301fe34f85bb74d932a.tar.bz2 |
Merge topic 'variable_watch-on-PARENT_SCOPE'
65198cfd0f variable_watch: trigger on variables set via PARENT_SCOPE
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1948
-rw-r--r-- | Source/cmMakefile.cxx | 9 | ||||
-rw-r--r-- | Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/variable_watch/RaiseInParentScope.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/variable_watch/RunCMakeTest.cmake | 1 |
4 files changed, 27 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 87cfc3b..9aeeb5c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3839,7 +3839,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, diff --git a/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt b/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt new file mode 100644 index 0000000..51db19c --- /dev/null +++ b/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt @@ -0,0 +1,2 @@ +var MODIFIED_ACCESS a +var MODIFIED_ACCESS b diff --git a/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake b/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake new file mode 100644 index 0000000..207798e --- /dev/null +++ b/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake @@ -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() diff --git a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake index 2fa6275..3883999 100644 --- a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake +++ b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake @@ -4,3 +4,4 @@ run_cmake(ModifiedAccess) run_cmake(NoWatcher) run_cmake(WatchTwice) run_cmake(ModifyWatchInCallback) +run_cmake(RaiseInParentScope) |