| 2388 | } |
| 2389 | |
| 2390 | cmValue cmMakefile::GetDefinition(std::string const& name) const |
| 2391 | { |
| 2392 | cmValue def = this->StateSnapshot.GetDefinition(name); |
| 2393 | if (!def) { |
| 2394 | def = this->GetState()->GetInitializedCacheValue(name); |
| 2395 | } |
| 2396 | #ifndef CMAKE_BOOTSTRAP |
| 2397 | cmVariableWatch* vv = this->GetVariableWatch(); |
| 2398 | if (vv) { |
| 2399 | bool const watch_function_executed = |
| 2400 | vv->VariableAccessed(name, |
| 2401 | def ? cmVariableWatch::VARIABLE_READ_ACCESS |
| 2402 | : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, |
| 2403 | def.GetCStr(), this); |
| 2404 | |
| 2405 | if (watch_function_executed) { |
| 2406 | // A callback was executed and may have caused re-allocation of the |
| 2407 | // variable storage. Look it up again for now. |
| 2408 | // FIXME: Refactor variable storage to avoid this problem. |
| 2409 | def = this->StateSnapshot.GetDefinition(name); |
| 2410 | if (!def) { |
| 2411 | def = this->GetState()->GetInitializedCacheValue(name); |
| 2412 | } |
| 2413 | } |
| 2414 | } |
| 2415 | #endif |
| 2416 | return def; |
| 2417 | } |
| 2418 | |
| 2419 | std::string const& cmMakefile::GetSafeDefinition(std::string const& name) const |
| 2420 | { |