| 347 | } |
| 348 | |
| 349 | cmValue cmSourceFile::GetPropertyForUser(std::string const& prop) |
| 350 | { |
| 351 | // This method is a consequence of design history and backwards |
| 352 | // compatibility. GetProperty is (and should be) a const method. |
| 353 | // Computed properties should not be stored back in the property map |
| 354 | // but instead reference information already known. If they need to |
| 355 | // cache information in a mutable ivar to provide the return string |
| 356 | // safely then so be it. |
| 357 | // |
| 358 | // The LOCATION property is particularly problematic. The CMake |
| 359 | // language has very loose restrictions on the names that will match |
| 360 | // a given source file (for historical reasons). Implementing |
| 361 | // lookups correctly with such loose naming requires the |
| 362 | // cmSourceFileLocation class to commit to a particular full path to |
| 363 | // the source file as late as possible. If the users requests the |
| 364 | // LOCATION property we must commit now. |
| 365 | if (prop == propLOCATION) { |
| 366 | // Commit to a location. |
| 367 | this->ResolveFullPath(); |
| 368 | } |
| 369 | |
| 370 | // Similarly, LANGUAGE can be determined by the file extension |
| 371 | // if it is requested by the user. |
| 372 | if (prop == propLANGUAGE) { |
| 373 | // The pointer is valid until `this->Language` is modified. |
| 374 | return cmValue(this->GetOrDetermineLanguage()); |
| 375 | } |
| 376 | |
| 377 | // Special handling for GENERATED property. |
| 378 | if (prop == propGENERATED) { |
| 379 | // We need to check policy CMP0163 and CMP0118 in order to determine if we |
| 380 | // need to possibly consider the value of a locally set GENERATED property, |
| 381 | // too. |
| 382 | auto cmp0163 = |
| 383 | this->Location.GetMakefile()->GetPolicyStatus(cmPolicies::CMP0163); |
| 384 | auto cmp0118 = |
| 385 | this->Location.GetMakefile()->GetPolicyStatus(cmPolicies::CMP0118); |
| 386 | bool const cmp0163new = |
| 387 | cmp0163 != cmPolicies::OLD && cmp0163 != cmPolicies::WARN; |
| 388 | bool const cmp0118new = cmp0163new || |
| 389 | (cmp0118 != cmPolicies::OLD && cmp0118 != cmPolicies::WARN); |
| 390 | if (this->GetIsGenerated((!cmp0118new) ? CheckScope::GlobalAndLocal |
| 391 | : CheckScope::Global)) { |
| 392 | return cmValue(propTRUE); |
| 393 | } |
| 394 | return cmValue(propFALSE); |
| 395 | } |
| 396 | |
| 397 | // Perform the normal property lookup. |
| 398 | return this->GetProperty(prop); |
| 399 | } |
| 400 | |
| 401 | cmValue cmSourceFile::GetProperty(std::string const& prop) const |
| 402 | { |
no test coverage detected