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

Method GetPchSource

Source/cmGeneratorTarget.cxx:3117–3175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3115}
3116
3117std::string cmGeneratorTarget::GetPchSource(std::string const& config,
3118 std::string const& language,
3119 std::string const& arch) const
3120{
3121 if (language != "C" && language != "CXX" && language != "OBJC" &&
3122 language != "OBJCXX") {
3123 return std::string();
3124 }
3125 auto const inserted =
3126 this->PchSources.insert(std::make_pair(language + config + arch, ""));
3127 if (inserted.second) {
3128 std::string const pchHeader = this->GetPchHeader(config, language, arch);
3129 if (pchHeader.empty()) {
3130 return std::string();
3131 }
3132 std::string& filename = inserted.first->second;
3133
3134 cmGeneratorTarget const* generatorTarget = this;
3135 cmGeneratorTarget const* reuseTarget = this->GetPchReuseTarget();
3136 bool const haveReuseTarget = reuseTarget && reuseTarget != this;
3137 if (reuseTarget) {
3138 generatorTarget = reuseTarget;
3139 }
3140
3141 filename =
3142 cmStrCat(generatorTarget->GetCMFSupportDirectory(), "/cmake_pch");
3143
3144 // For GCC the source extension will be transformed into .h[xx].gch
3145 if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) {
3146 std::map<std::string, std::string> const languageToExtension = {
3147 { "C", ".h.c" },
3148 { "CXX", ".hxx.cxx" },
3149 { "OBJC", ".objc.h.m" },
3150 { "OBJCXX", ".objcxx.hxx.mm" }
3151 };
3152
3153 filename = cmStrCat(filename, arch.empty() ? "" : cmStrCat('_', arch),
3154 languageToExtension.at(language));
3155 } else {
3156 std::map<std::string, std::string> const languageToExtension = {
3157 { "C", ".c" }, { "CXX", ".cxx" }, { "OBJC", ".m" }, { "OBJCXX", ".mm" }
3158 };
3159
3160 filename = cmStrCat(filename, arch.empty() ? "" : cmStrCat('_', arch),
3161 languageToExtension.at(language));
3162 }
3163
3164 std::string const filename_tmp = cmStrCat(filename, ".tmp");
3165 if (!haveReuseTarget) {
3166 {
3167 cmGeneratedFileStream file(filename_tmp);
3168 file << "/* generated by CMake */\n";
3169 }
3170 cmFileTimes::Copy(pchHeader, filename_tmp);
3171 cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
3172 }
3173 }
3174 return inserted.first->second;

Callers 12

GetPchFileObjectMethod · 0.95
GetPchFileMethod · 0.95
WriteObjectRuleFilesMethod · 0.80
ComputeFlagsForObjectMethod · 0.80
AddPchDependenciesMethod · 0.80
ComputePCHMethod · 0.80
GenerateObjectsMethod · 0.80
BuildCompileDataMethod · 0.80

Calls 8

GetPchHeaderMethod · 0.95
GetPchReuseTargetMethod · 0.95
cmStrCatFunction · 0.70
insertMethod · 0.45
emptyMethod · 0.45
IsOnMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected