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

Method GetPchFile

Source/cmGeneratorTarget.cxx:3204–3261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3202}
3203
3204std::string cmGeneratorTarget::GetPchFile(std::string const& config,
3205 std::string const& language,
3206 std::string const& arch)
3207{
3208 auto const inserted =
3209 this->PchFiles.insert(std::make_pair(language + config + arch, ""));
3210 if (inserted.second) {
3211 std::string& pchFile = inserted.first->second;
3212
3213 std::string const pchExtension =
3214 this->Makefile->GetSafeDefinition("CMAKE_PCH_EXTENSION");
3215
3216 if (this->Makefile->IsOn("CMAKE_LINK_PCH")) {
3217 auto replaceExtension = [](std::string const& str,
3218 std::string const& ext) -> std::string {
3219 auto dot_pos = str.rfind('.');
3220 std::string result;
3221 if (dot_pos != std::string::npos) {
3222 result = str.substr(0, dot_pos);
3223 }
3224 result += ext;
3225 return result;
3226 };
3227
3228 cmGeneratorTarget* generatorTarget = this;
3229 cmGeneratorTarget* reuseTarget = this->GetPchReuseTarget();
3230 if (reuseTarget) {
3231 generatorTarget = reuseTarget;
3232 }
3233
3234 std::string const pchFileObject =
3235 generatorTarget->GetPchFileObject(config, language, arch);
3236 if (!pchExtension.empty()) {
3237 pchFile = replaceExtension(pchFileObject, pchExtension);
3238 }
3239 } else {
3240 if (this->GetUseShortObjectNames() && !pchExtension.empty()) {
3241 auto pchSource = this->GetPchSource(config, language, arch);
3242 auto* pchSf = this->Makefile->GetOrCreateSource(
3243 pchSource, false, cmSourceFileLocationKind::Known);
3244 pchSf->SetSpecialSourceType(
3245 cmSourceFile::SpecialSourceType::PchSource);
3246 pchSf->ResolveFullPath();
3247 std::string cfgSubdir;
3248 if (this->GetGlobalGenerator()->IsMultiConfig()) {
3249 cfgSubdir = cmStrCat(config, '/');
3250 }
3251 pchFile = cmStrCat(
3252 this->GetSupportDirectory(), '/', cfgSubdir,
3253 this->LocalGenerator->GetShortObjectFileName(*pchSf), pchExtension);
3254 } else {
3255 pchFile =
3256 cmStrCat(this->GetPchHeader(config, language, arch), pchExtension);
3257 }
3258 }
3259 }
3260 return inserted.first->second;
3261}

Callers 9

WriteObjectRuleFilesMethod · 0.80
AddPchDependenciesMethod · 0.80
CopyPchCompilePdbMethod · 0.80
ComputePCHMethod · 0.80
ComputeClOptionsMethod · 0.80

Calls 15

GetPchReuseTargetMethod · 0.95
GetPchSourceMethod · 0.95
GetGlobalGeneratorMethod · 0.95
GetSupportDirectoryMethod · 0.95
GetPchHeaderMethod · 0.95
rfindMethod · 0.80
GetPchFileObjectMethod · 0.80
GetOrCreateSourceMethod · 0.80
SetSpecialSourceTypeMethod · 0.80
cmStrCatFunction · 0.70

Tested by

no test coverage detected