MCPcopy Create free account
hub / github.com/Kitware/CMake / cmVariableWatchCommand

Function cmVariableWatchCommand

Source/cmVariableWatchCommand.cxx:123–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121} // anonymous namespace
122
123bool cmVariableWatchCommand(std::vector<std::string> const& args,
124 cmExecutionStatus& status)
125{
126 if (args.empty()) {
127 status.SetError("must be called with at least one argument.");
128 return false;
129 }
130 std::string const& variable = args[0];
131 std::string command;
132 if (args.size() > 1) {
133 command = args[1];
134 }
135 if (variable == "CMAKE_CURRENT_LIST_FILE") {
136 status.SetError(cmStrCat("cannot be set on the variable: ", variable));
137 return false;
138 }
139
140 auto* const data = new cmVariableWatchCallbackData;
141
142 data->InCallback = false;
143 data->Command = std::move(command);
144
145 if (!status.GetMakefile().GetCMakeInstance()->GetVariableWatch()->AddWatch(
146 variable, cmVariableWatchCommandVariableAccessed, data,
147 deleteVariableWatchCallbackData)) {
148 deleteVariableWatchCallbackData(data);
149 return false;
150 }
151
152 status.GetMakefile().AddGeneratorAction(
153 FinalAction{ &status.GetMakefile(), variable });
154 return true;
155}

Callers

nothing calls this directly

Calls 11

moveFunction · 0.85
AddWatchMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
SetErrorMethod · 0.45
sizeMethod · 0.45
GetVariableWatchMethod · 0.45
GetCMakeInstanceMethod · 0.45
GetMakefileMethod · 0.45
AddGeneratorActionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…