| 1491 | } |
| 1492 | |
| 1493 | CompileData Target::BuildCompileData(cmSourceFile* sf) |
| 1494 | { |
| 1495 | CompileData fd; |
| 1496 | |
| 1497 | fd.Language = sf->GetOrDetermineLanguage(); |
| 1498 | if (fd.Language.empty()) { |
| 1499 | return fd; |
| 1500 | } |
| 1501 | |
| 1502 | cmLocalGenerator* lg = this->GT->GetLocalGenerator(); |
| 1503 | cmGeneratorExpressionInterpreter genexInterpreter(lg, this->Config, this->GT, |
| 1504 | fd.Language); |
| 1505 | |
| 1506 | std::string const COMPILE_FLAGS("COMPILE_FLAGS"); |
| 1507 | if (cmValue cflags = sf->GetProperty(COMPILE_FLAGS)) { |
| 1508 | std::string flags = genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS); |
| 1509 | fd.Flags.emplace_back(std::move(flags), JBTIndex()); |
| 1510 | } |
| 1511 | std::string const COMPILE_OPTIONS("COMPILE_OPTIONS"); |
| 1512 | for (BT<std::string> tmpOpt : sf->GetCompileOptions()) { |
| 1513 | tmpOpt.Value = genexInterpreter.Evaluate(tmpOpt.Value, COMPILE_OPTIONS); |
| 1514 | // After generator evaluation we need to use the AppendCompileOptions |
| 1515 | // method so we handle situations where backtrace entries have lists |
| 1516 | // and properly escape flags. |
| 1517 | std::string tmp; |
| 1518 | lg->AppendCompileOptions(tmp, tmpOpt.Value); |
| 1519 | BT<std::string> opt(tmp, tmpOpt.Backtrace); |
| 1520 | fd.Flags.emplace_back(this->ToJBT(opt)); |
| 1521 | } |
| 1522 | |
| 1523 | // Add precompile headers compile options. |
| 1524 | std::vector<std::string> pchArchs = |
| 1525 | this->GT->GetPchArchs(this->Config, fd.Language); |
| 1526 | |
| 1527 | std::unordered_map<std::string, std::string> pchSources; |
| 1528 | for (std::string const& arch : pchArchs) { |
| 1529 | std::string const pchSource = |
| 1530 | this->GT->GetPchSource(this->Config, fd.Language, arch); |
| 1531 | if (!pchSource.empty()) { |
| 1532 | pchSources.insert(std::make_pair(pchSource, arch)); |
| 1533 | } |
| 1534 | } |
| 1535 | |
| 1536 | if (!pchSources.empty() && !sf->GetProperty("SKIP_PRECOMPILE_HEADERS")) { |
| 1537 | std::string pchOptions; |
| 1538 | auto pchIt = pchSources.find(sf->ResolveFullPath()); |
| 1539 | if (pchIt != pchSources.end()) { |
| 1540 | pchOptions = this->GT->GetPchCreateCompileOptions( |
| 1541 | this->Config, fd.Language, pchIt->second); |
| 1542 | } else { |
| 1543 | pchOptions = |
| 1544 | this->GT->GetPchUseCompileOptions(this->Config, fd.Language); |
| 1545 | } |
| 1546 | |
| 1547 | BT<std::string> tmpOpt(pchOptions); |
| 1548 | tmpOpt.Value = genexInterpreter.Evaluate(tmpOpt.Value, COMPILE_OPTIONS); |
| 1549 | |
| 1550 | // After generator evaluation we need to use the AppendCompileOptions |
no test coverage detected