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

Method ComputePCH

Source/cmFastbuildNormalTargetGenerator.cxx:422–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422void cmFastbuildNormalTargetGenerator::ComputePCH(
423 cmSourceFile const& srcFile, FastbuildObjectListNode& node,
424 std::set<std::string>& createdPCH)
425{
426 if (srcFile.GetProperty("SKIP_PRECOMPILE_HEADERS")) {
427 return;
428 }
429 // We have already computed PCH for this node.
430 if (!node.PCHOptions.empty() || !node.PCHInputFile.empty() ||
431 !node.PCHOutputFile.empty()) {
432 return;
433 }
434 std::string const language = srcFile.GetLanguage();
435 cmGeneratorExpressionInterpreter genexInterpreter(
436 this->GetLocalGenerator(), Config, this->GeneratorTarget, language);
437
438 //.cxx
439 std::string const pchSource =
440 this->GeneratorTarget->GetPchSource(Config, language);
441 //.hxx
442 std::string const pchHeader =
443 this->GeneratorTarget->GetPchHeader(Config, language);
444 //.pch
445 std::string const pchFile =
446 this->GeneratorTarget->GetPchFile(Config, language);
447
448 if (pchHeader.empty() || pchFile.empty()) {
449 return;
450 }
451 // In "RunCMake.GenEx-TARGET_PROPERTY" test we call set
452 // CMAKE_PCH_EXTENSION="", so pchHeader becomes same as pchFile...
453 if (pchHeader == pchFile) {
454 LogMessage("pchHeader == pchFile > skipping");
455 LogMessage("pchHeader: " + pchHeader);
456 LogMessage("pchFile: " + pchFile);
457 return;
458 }
459
460 node.PCHOutputFile =
461 this->GetGlobalGenerator()->ConvertToFastbuildPath(pchFile);
462 // Tell the ObjectList how to use PCH.
463 std::string const pchUseOption =
464 this->GeneratorTarget->GetPchUseCompileOptions(Config, language);
465 LogMessage(cmStrCat("pchUseOption: ", pchUseOption));
466
467 std::string origCompileOptions = node.CompilerOptions;
468 for (auto const& opt :
469 cmList{ genexInterpreter.Evaluate(pchUseOption, COMPILE_OPTIONS) }) {
470 node.CompilerOptions += " ";
471 node.CompilerOptions += opt;
472 }
473
474 if (!createdPCH.emplace(node.PCHOutputFile).second) {
475 LogMessage(node.PCHOutputFile + " is already created by this target");
476 return;
477 }
478
479 // Short circuit if the PCH has already been created by another target.

Callers

nothing calls this directly

Calls 14

GetLanguageMethod · 0.80
GetPchSourceMethod · 0.80
GetPchHeaderMethod · 0.80
GetPchFileMethod · 0.80
emplaceMethod · 0.80
cmStrCatFunction · 0.70
GetPropertyMethod · 0.45
emptyMethod · 0.45
GetLocalGeneratorMethod · 0.45

Tested by

no test coverage detected