| 412 | } |
| 413 | |
| 414 | void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( |
| 415 | std::string& input, cmGeneratorTarget const* target, |
| 416 | cmLocalGenerator const* lg) |
| 417 | { |
| 418 | std::string::size_type pos = 0; |
| 419 | std::string::size_type lastPos = pos; |
| 420 | |
| 421 | while ((pos = input.find("$<TARGET_PROPERTY:", lastPos)) != |
| 422 | std::string::npos) { |
| 423 | std::string::size_type nameStartPos = pos + cmStrLen("$<TARGET_PROPERTY:"); |
| 424 | std::string::size_type closePos = input.find('>', nameStartPos); |
| 425 | std::string::size_type commaPos = input.find(',', nameStartPos); |
| 426 | std::string::size_type nextOpenPos = input.find("$<", nameStartPos); |
| 427 | if (commaPos == std::string::npos // Implied 'this' target |
| 428 | || closePos == std::string::npos // Incomplete expression. |
| 429 | || closePos < commaPos // Implied 'this' target |
| 430 | || nextOpenPos < commaPos) // Non-literal |
| 431 | { |
| 432 | lastPos = nameStartPos; |
| 433 | continue; |
| 434 | } |
| 435 | |
| 436 | std::string targetName = |
| 437 | input.substr(nameStartPos, commaPos - nameStartPos); |
| 438 | |
| 439 | if (this->AddTargetNamespace(targetName, target, lg)) { |
| 440 | input.replace(nameStartPos, commaPos - nameStartPos, targetName); |
| 441 | } |
| 442 | lastPos = nameStartPos + targetName.size() + 1; |
| 443 | } |
| 444 | |
| 445 | std::string errorString; |
| 446 | pos = 0; |
| 447 | lastPos = pos; |
| 448 | while ((pos = input.find("$<TARGET_NAME:", lastPos)) != std::string::npos) { |
| 449 | std::string::size_type nameStartPos = pos + cmStrLen("$<TARGET_NAME:"); |
| 450 | std::string::size_type endPos = input.find('>', nameStartPos); |
| 451 | if (endPos == std::string::npos) { |
| 452 | errorString = "$<TARGET_NAME:...> expression incomplete"; |
| 453 | break; |
| 454 | } |
| 455 | std::string targetName = input.substr(nameStartPos, endPos - nameStartPos); |
| 456 | if (targetName.find("$<") != std::string::npos) { |
| 457 | errorString = "$<TARGET_NAME:...> requires its parameter to be a " |
| 458 | "literal."; |
| 459 | break; |
| 460 | } |
| 461 | if (!this->AddTargetNamespace(targetName, target, lg)) { |
| 462 | errorString = "$<TARGET_NAME:...> requires its parameter to be a " |
| 463 | "reachable target."; |
| 464 | break; |
| 465 | } |
| 466 | input.replace(pos, endPos - pos + 1, targetName); |
| 467 | lastPos = pos + targetName.size(); |
| 468 | } |
| 469 | |
| 470 | pos = 0; |
| 471 | lastPos = pos; |
no test coverage detected