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

Method ResolveLanguageCompiler

Source/cmGlobalGenerator.cxx:251–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void cmGlobalGenerator::ResolveLanguageCompiler(std::string const& lang,
252 cmMakefile* mf,
253 bool optional) const
254{
255 std::string langComp = cmStrCat("CMAKE_", lang, "_COMPILER");
256
257 if (!mf->GetDefinition(langComp)) {
258 if (!optional) {
259 cmSystemTools::Error(
260 cmStrCat(langComp, " not set, after EnableLanguage"));
261 }
262 return;
263 }
264 std::string const& name = mf->GetRequiredDefinition(langComp);
265 std::string path;
266 if (!cmSystemTools::FileIsFullPath(name)) {
267 path = cmSystemTools::FindProgram(name);
268 } else {
269 path = name;
270 }
271 if (!optional && (path.empty() || !cmSystemTools::FileExists(path))) {
272 return;
273 }
274 cmValue cname =
275 this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp);
276
277 // Split compiler from arguments
278 cmList cnameArgList;
279 if (cname && !cname->empty()) {
280 cnameArgList.assign(*cname);
281 cname = cmValue(cnameArgList.front());
282 }
283
284 std::string changeVars;
285 if (cname && !optional) {
286 cmCMakePath cachedPath;
287 if (!cmSystemTools::FileIsFullPath(*cname)) {
288 cachedPath = cmSystemTools::FindProgram(*cname);
289 } else {
290 cachedPath = *cname;
291 }
292 cmCMakePath foundPath = path;
293 if (foundPath.Normal() != cachedPath.Normal()) {
294 cmValue cvars = this->GetCMakeInstance()->GetState()->GetGlobalProperty(
295 "__CMAKE_DELETE_CACHE_CHANGE_VARS_");
296 if (cvars) {
297 changeVars += *cvars;
298 changeVars += ";";
299 }
300 changeVars += langComp;
301 changeVars += ";";
302 changeVars += *cname;
303 this->GetCMakeInstance()->GetState()->SetGlobalProperty(
304 "__CMAKE_DELETE_CACHE_CHANGE_VARS_", changeVars);
305 }
306 }
307}
308

Callers 3

EnableLanguageMethod · 0.80
EnableLanguageMethod · 0.80
EnableLanguageMethod · 0.80

Calls 14

GetCMakeInstanceMethod · 0.95
assignMethod · 0.80
NormalMethod · 0.80
GetGlobalPropertyMethod · 0.80
SetGlobalPropertyMethod · 0.80
cmStrCatFunction · 0.70
ErrorClass · 0.70
cmValueClass · 0.70
FileExistsFunction · 0.50
GetDefinitionMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected