Merge topic 'cpack-rpm-extend-exclude-from-auto-filelist'

545d9a17 CPack/RPM: new CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST exclude paths

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1299
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index b2916b4..666293c 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
 set(CMake_VERSION_MINOR 9)
-set(CMake_VERSION_PATCH 20170921)
+set(CMake_VERSION_PATCH 20170922)
 #set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index 87e7089..a01fc4e 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -162,7 +162,7 @@
   void CharacterDataHandler(const char* data, int length) override
   {
     std::string content(data, data + length);
-    if (content == "" || content == " " || content == "  " ||
+    if (content.empty() || content == " " || content == "  " ||
         content == "\n") {
       return;
     }
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 28fc113..1da42d4 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -260,11 +260,11 @@
                      "MakeCommand:" << makeCommand << "\n", this->Quiet);
 
   std::string configType = this->CTest->GetConfigType();
-  if (configType == "") {
+  if (configType.empty()) {
     configType =
       this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
   }
-  if (configType == "") {
+  if (configType.empty()) {
     configType = "Release";
   }
 
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index c853373..6a7bdc0 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -491,7 +491,7 @@
     }
     // Next part of the file is the failed tests
     while (std::getline(fin, line)) {
-      if (line != "") {
+      if (!line.empty()) {
         this->LastTestsFailed.push_back(line);
       }
     }
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 56a9cb8..abdb643 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -494,7 +494,7 @@
     }
   }
   // log and return if we did not find the executable
-  if (this->ActualCommand == "") {
+  if (this->ActualCommand.empty()) {
     // if the command was not found create a TestResult object
     // that has that information
     this->TestProcess = new cmProcess;
@@ -595,7 +595,7 @@
 {
   double timeout = this->TestProperties->Timeout;
 
-  if (this->CTest->GetStopTime() == "") {
+  if (this->CTest->GetStopTime().empty()) {
     return timeout;
   }
   struct tm* lctime;
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 087eb38..ce96224 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -410,7 +410,7 @@
 
   // Ignore changes in the old revision for external repositories
   if (revision.Rev == revision.SVNInfo->OldRevision &&
-      revision.SVNInfo->LocalPath != "") {
+      !revision.SVNInfo->LocalPath.empty()) {
     return;
   }
 
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 137cea9..e51e168 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -496,11 +496,11 @@
           ? ""
           : this->GetOption("RetryCount");
 
-        int delay = retryDelay == ""
+        int delay = retryDelay.empty()
           ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
                    .c_str())
           : atoi(retryDelay.c_str());
-        int count = retryCount == ""
+        int count = retryCount.empty()
           ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
                    .c_str())
           : atoi(retryCount.c_str());
@@ -1032,14 +1032,14 @@
     ? ""
     : this->GetOption("RetryCount");
   unsigned long retryDelay = 0;
-  if (retryDelayString != "") {
+  if (!retryDelayString.empty()) {
     if (!cmSystemTools::StringToULong(retryDelayString.c_str(), &retryDelay)) {
       cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
                    << retryDelayString << std::endl);
     }
   }
   unsigned long retryCount = 0;
-  if (retryCountString != "") {
+  if (!retryCountString.empty()) {
     if (!cmSystemTools::StringToULong(retryCountString.c_str(), &retryCount)) {
       cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
                    << retryCountString << std::endl);
@@ -1361,7 +1361,7 @@
 
   std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
 
-  if (dropMethod == "" || dropMethod == "ftp") {
+  if (dropMethod.empty() || dropMethod == "ftp") {
     ofs << "Using drop method: FTP" << std::endl;
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
                        "   Using FTP submit method" << std::endl
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f3404a5..5896014 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1596,7 +1596,7 @@
   // wasn't specified
   if (fullPath.empty() && filepath.empty()) {
     std::string const path = cmSystemTools::FindProgram(filename.c_str());
-    if (path != "") {
+    if (!path.empty()) {
       resultingConfig.clear();
       return path;
     }
@@ -1802,7 +1802,7 @@
     if (fileNameSubstring != pattern) {
       continue;
     }
-    if (logName == "") {
+    if (logName.empty()) {
       logName = fileName;
     } else {
       // if multiple matching logs were found we use the most recently
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index 3e85339..61ce7d4 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -78,7 +78,7 @@
             }
           }
 
-          if (this->CurFileName == "") {
+          if (this->CurFileName.empty()) {
             // Check if this is a path that is relative to our source or
             // binary directories.
             for (std::string const& filePath : FilePaths) {
@@ -91,7 +91,7 @@
           }
 
           cmsys::ifstream fin(this->CurFileName.c_str());
-          if (this->CurFileName == "" || !fin) {
+          if (this->CurFileName.empty() || !fin) {
             this->CurFileName =
               this->Coverage.BinaryDir + "/" + atts[tagCount + 1];
             fin.open(this->CurFileName.c_str());
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
index 4b781a6..6d82cb2 100644
--- a/Source/CTest/cmParseDelphiCoverage.cxx
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -71,7 +71,8 @@
         }
       }
       // Based up what was found, add a line to the coverageVector
-      if (!beginSet.empty() && line != "" && !blockComFlag && !lineComFlag) {
+      if (!beginSet.empty() && !line.empty() && !blockComFlag &&
+          !lineComFlag) {
         coverageVector.push_back(0);
       } else {
         coverageVector.push_back(-1);
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index 56d07e7..7acb5ca 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -36,7 +36,7 @@
     } else if (name == "sourcefile") {
       std::string fileName = atts[1];
 
-      if (this->PackagePath == "") {
+      if (this->PackagePath.empty()) {
         if (!this->FindPackagePath(fileName)) {
           cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
                        << this->PackageName << "/" << fileName << std::endl);
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index d60ce55..ba50986 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -147,7 +147,7 @@
 std::string cmCTest::GetCostDataFile()
 {
   std::string fname = this->GetCTestConfiguration("CostDataFile");
-  if (fname == "") {
+  if (fname.empty()) {
     fname = this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt";
   }
   return fname;
@@ -1235,7 +1235,7 @@
 {
   std::string safevalue(value);
 
-  if (safevalue != "") {
+  if (!safevalue.empty()) {
     // Disallow non-filename and non-space whitespace characters.
     // If they occur, replace them with ""
     //
@@ -1254,7 +1254,7 @@
     }
   }
 
-  if (safevalue == "") {
+  if (safevalue.empty()) {
     safevalue = "(empty)";
   }
 
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 85dfc7d..f227cf2 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -310,7 +310,7 @@
 void cmDependsJavaParserHelper::UpdateCombine(const char* str1,
                                               const char* str2)
 {
-  if (this->CurrentCombine == "" && str1 != nullptr) {
+  if (this->CurrentCombine.empty() && str1 != nullptr) {
     this->CurrentCombine = str1;
   }
   this->CurrentCombine += ".";
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 09a9648..b8b51ba 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -68,8 +68,8 @@
     this->AddArchitecturePaths("x32");
   }
 
-  std::string library = this->FindLibrary();
-  if (library != "") {
+  std::string const library = this->FindLibrary();
+  if (!library.empty()) {
     // Save the value in the cache
     this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(),
                                        this->VariableDocumentation.c_str(),
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index a5dc1c6..2059b3d 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -97,8 +97,8 @@
     return true;
   }
 
-  std::string result = FindProgram();
-  if (result != "") {
+  std::string const result = FindProgram();
+  if (!result.empty()) {
     // Save the value in the cache
     this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(),
                                        this->VariableDocumentation.c_str(),
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 15ddeff..be40126 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -230,7 +230,7 @@
 
   // The all and preinstall rules might never have any dependencies
   // added to them.
-  if (this->EmptyRuleHackDepends != "") {
+  if (!this->EmptyRuleHackDepends.empty()) {
     depends.push_back(this->EmptyRuleHackDepends);
   }
 
@@ -438,7 +438,7 @@
 
   // Work-around for makes that drop rules that have no dependencies
   // or commands.
-  if (depends.empty() && this->EmptyRuleHackDepends != "") {
+  if (depends.empty() && !this->EmptyRuleHackDepends.empty()) {
     depends.push_back(this->EmptyRuleHackDepends);
   }
 
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index ece2a77..0651536 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -150,7 +150,7 @@
 {
   std::string dir = this->GetUserMacrosDirectory();
 
-  if (dir != "") {
+  if (!dir.empty()) {
     std::string src = cmSystemTools::GetCMakeRoot();
     src += "/Templates/" CMAKE_VSMACROS_FILENAME;
 
@@ -190,7 +190,7 @@
   //  - the CMake vsmacros file is registered
   //  - there were .sln/.vcproj files changed during generation
   //
-  if (dir != "") {
+  if (!dir.empty()) {
     std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
     std::string nextSubkeyName;
     if (cmSystemTools::FileExists(macrosFile.c_str()) &&
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 2850032..6bfac17 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -197,7 +197,7 @@
 
   // Try to find the program.
   std::string fullPath = cmSystemTools::FindFile(moduleName, path);
-  if (fullPath == "") {
+  if (fullPath.empty()) {
     std::ostringstream e;
     e << "Attempt to load command failed from file \"" << moduleName << "\"";
     this->SetError(e.str());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e1662ac..1a088ea 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1410,7 +1410,7 @@
 
   // If the input name is the empty string, there is no real
   // dependency. Short-circuit the other checks:
-  if (name == "") {
+  if (name.empty()) {
     return false;
   }
 
@@ -2096,7 +2096,7 @@
     }
 
     // Install this target if a destination is given.
-    if (l->Target->GetInstallPath() != "") {
+    if (!l->Target->GetInstallPath().empty()) {
       // Compute the full install destination.  Note that converting
       // to unix slashes also removes any trailing slash.
       // We also skip over the leading slash given by the user.
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index c978936..a1771ee 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1591,7 +1591,7 @@
 
   // If the group has a name, write the header.
   std::string name = sg->GetName();
-  if (name != "") {
+  if (!name.empty()) {
     this->WriteVCProjBeginGroup(fout, name.c_str(), "");
   }
 
@@ -1709,7 +1709,7 @@
   }
 
   // If the group has a name, write the footer.
-  if (name != "") {
+  if (!name.empty()) {
     this->WriteVCProjEndGroup(fout);
   }
 
@@ -2006,7 +2006,7 @@
        i != props.end(); ++i) {
     if (i->find("VS_GLOBAL_") == 0) {
       std::string name = i->substr(10);
-      if (name != "") {
+      if (!name.empty()) {
         /* clang-format off */
         fout << "\t\t<Global\n"
              << "\t\t\tName=\"" << name << "\"\n"
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index c430298..cde9037 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -510,7 +510,7 @@
   // now recurse with info's dependencies
   for (cmDependInformation* d : info->DependencySet) {
     if (visited->find(d) == visited->end()) {
-      if (info->FullPath != "") {
+      if (!info->FullPath.empty()) {
         std::string tmp = d->FullPath;
         std::string::size_type pos = tmp.rfind('.');
         if (pos != std::string::npos && (tmp.substr(pos) != ".h")) {
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index a1f346a..e7d1b72 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -140,7 +140,7 @@
     *defaultSetting = cmPolicies::NEW;
   } else if (defaultValue == "OLD") {
     *defaultSetting = cmPolicies::OLD;
-  } else if (defaultValue == "") {
+  } else if (defaultValue.empty()) {
     *defaultSetting = cmPolicies::WARN;
   } else {
     std::ostringstream e;
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 30d0f51..e923c22 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -84,7 +84,7 @@
   const cmServerRequest request(this, connection, value[kTYPE_KEY].asString(),
                                 value[kCOOKIE_KEY].asString(), value);
 
-  if (request.Type == "") {
+  if (request.Type.empty()) {
     cmServerResponse response(request);
     response.SetError("No type given in request.");
     this->WriteResponse(connection, response, nullptr);
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 5f2737d..58adc43 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1375,7 +1375,7 @@
   if (fileComponents.empty()) {
     return dir;
   }
-  if (fileComponents[0] != "") {
+  if (!fileComponents[0].empty()) {
     // File is not a relative path.
     return file;
   }
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 0e072b8..bd5d19c 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -2,11 +2,9 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmVariableWatch.h"
 
-#include "cmAlgorithms.h"
-
-#include "cm_auto_ptr.hxx"
-#include <algorithm>
+#include <memory>
 #include <utility>
+#include <vector>
 
 static const char* const cmVariableWatchAccessStrings[] = {
   "READ_ACCESS",     "UNKNOWN_READ_ACCESS", "UNKNOWN_DEFINED_ACCESS",
@@ -25,35 +23,27 @@
 {
 }
 
-template <typename C>
-void deleteAllSecond(typename C::value_type it)
-{
-  cmDeleteAll(it.second);
-}
-
 cmVariableWatch::~cmVariableWatch()
 {
-  std::for_each(this->WatchMap.begin(), this->WatchMap.end(),
-                deleteAllSecond<cmVariableWatch::StringToVectorOfPairs>);
 }
 
 bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method,
                                void* client_data /*=0*/,
                                DeleteData delete_data /*=0*/)
 {
-  CM_AUTO_PTR<cmVariableWatch::Pair> p(new cmVariableWatch::Pair);
+  auto p = std::make_shared<cmVariableWatch::Pair>();
   p->Method = method;
   p->ClientData = client_data;
   p->DeleteDataCall = delete_data;
   cmVariableWatch::VectorOfPairs& vp = this->WatchMap[variable];
-  for (cmVariableWatch::Pair* pair : vp) {
+  for (auto& pair : vp) {
     if (pair->Method == method && client_data &&
         client_data == pair->ClientData) {
       // Callback already exists
       return false;
     }
   }
-  vp.push_back(p.release());
+  vp.push_back(std::move(p));
   return true;
 }
 
@@ -70,7 +60,6 @@
         // If client_data is NULL, we want to disconnect all watches against
         // the given method; otherwise match ClientData as well.
         (!client_data || (client_data == (*it)->ClientData))) {
-      delete *it;
       vp->erase(it);
       return;
     }
@@ -84,9 +73,17 @@
   cmVariableWatch::StringToVectorOfPairs::const_iterator mit =
     this->WatchMap.find(variable);
   if (mit != this->WatchMap.end()) {
-    const cmVariableWatch::VectorOfPairs* vp = &mit->second;
-    for (cmVariableWatch::Pair* it : *vp) {
-      it->Method(variable, access_type, it->ClientData, newValue, mf);
+    // The strategy here is to copy the list of callbacks, and ignore
+    // new callbacks that existing ones may add.
+    std::vector<std::weak_ptr<Pair>> vp(mit->second.begin(),
+                                        mit->second.end());
+    for (auto& weak_it : vp) {
+      // In the case where a callback was removed, the weak_ptr will not be
+      // lockable, and so this ensures we don't attempt to call into freed
+      // memory
+      if (auto it = weak_it.lock()) {
+        it->Method(variable, access_type, it->ClientData, newValue, mf);
+      }
     }
     return true;
   }
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 05a0a56..27d1b12 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -6,6 +6,7 @@
 #include "cmConfigure.h" // IWYU pragma: keep
 
 #include <map>
+#include <memory> // IWYU pragma: keep
 #include <string>
 #include <vector>
 
@@ -79,7 +80,7 @@
     }
   };
 
-  typedef std::vector<Pair*> VectorOfPairs;
+  typedef std::vector<std::shared_ptr<Pair>> VectorOfPairs;
   typedef std::map<std::string, VectorOfPairs> StringToVectorOfPairs;
 
   StringToVectorOfPairs WatchMap;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 99b9bce..8dce028 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -407,7 +407,7 @@
       continue;
     std::string globalKey = keyIt->substr(strlen(prefix));
     // Skip invalid or separately-handled properties.
-    if (globalKey == "" || globalKey == "PROJECT_TYPES" ||
+    if (globalKey.empty() || globalKey == "PROJECT_TYPES" ||
         globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
       continue;
     }
@@ -614,7 +614,7 @@
        ++i) {
     if (i->first.find("VS_DOTNET_REFERENCE_") == 0) {
       std::string name = i->first.substr(20);
-      if (name != "") {
+      if (!name.empty()) {
         std::string path = i->second.GetValue();
         if (!cmsys::SystemTools::FileIsFullPath(path)) {
           path = std::string(this->GeneratorTarget->Target->GetMakefile()
diff --git a/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake b/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake
new file mode 100644
index 0000000..1dee837
--- /dev/null
+++ b/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake
@@ -0,0 +1,17 @@
+function (watch2)
+
+endfunction ()
+
+function (watch1)
+  variable_watch(watched watch2)
+  variable_watch(watched watch2)
+  variable_watch(watched watch2)
+  variable_watch(watched watch2)
+  variable_watch(watched watch2)
+  variable_watch(watched watch2)
+endfunction ()
+
+variable_watch(watched watch1)
+variable_watch(watched watch2)
+
+set(access "${watched}")
diff --git a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake
index 9becb4c..2fa6275 100644
--- a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake
+++ b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake
@@ -3,3 +3,4 @@
 run_cmake(ModifiedAccess)
 run_cmake(NoWatcher)
 run_cmake(WatchTwice)
+run_cmake(ModifyWatchInCallback)