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

Method WriteObjectBuildStatement

Source/cmNinjaTargetGenerator.cxx:1394–1764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1392}
1393
1394void cmNinjaTargetGenerator::WriteObjectBuildStatement(
1395 cmSourceFile const* source, std::string const& config,
1396 std::string const& fileConfig, bool firstForConfig)
1397{
1398 std::string const language = source->GetLanguage();
1399 std::string const sourceFilePath = this->GetCompiledSourceNinjaPath(source);
1400 std::string const targetSupportDir =
1401 this->ConvertToNinjaPath(this->GeneratorTarget->GetCMFSupportDirectory());
1402 std::string const objectDir =
1403 this->ConvertToNinjaPath(this->GetObjectFileDir(config));
1404 std::string const objectFileName =
1405 this->ConvertToNinjaPath(this->GetObjectFilePath(source, config));
1406 std::string const objectFileDir =
1407 cmSystemTools::GetFilenamePath(objectFileName);
1408
1409 std::string cmakeVarLang = cmStrCat("CMAKE_", language);
1410
1411 // build response file name
1412 std::string cmakeLinkVar = cmStrCat(cmakeVarLang, "_RESPONSE_FILE_FLAG");
1413
1414 cmValue flag = this->GetMakefile()->GetDefinition(cmakeLinkVar);
1415
1416 bool const lang_supports_response =
1417 !(language == "RC" || (language == "CUDA" && !flag));
1418 int const commandLineLengthLimit =
1419 ((lang_supports_response && this->ForceResponseFile())) ? -1 : 0;
1420 cmValue pchExtension =
1421 this->GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION");
1422 bool const isPch = cmHasSuffix(objectFileName, pchExtension);
1423 bool const needDyndep = !isPch &&
1424 this->GeneratorTarget->NeedDyndepForSource(language, config, source);
1425
1426 WithScanning withScanning =
1427 needDyndep ? WithScanning::Yes : WithScanning::No;
1428 cmNinjaBuild objBuild(
1429 this->LanguageCompilerRule(language, config, withScanning));
1430 cmNinjaVars& vars = objBuild.Variables;
1431 vars["FLAGS"] =
1432 this->ComputeFlagsForObject(source, language, config, objectFileName);
1433 vars["DEFINES"] = this->ComputeDefines(source, language, config);
1434 vars["INCLUDES"] = this->ComputeIncludes(source, language, config);
1435 vars["CONFIG"] = config;
1436 if (this->GetGeneratorTarget()->GetUseShortObjectNames()) {
1437 vars.emplace(
1438 "description",
1439 cmStrCat("Compiling object ", objectFileName, " from source ",
1440 this->GetLocalGenerator()->GetRelativeSourceFileName(*source)));
1441 }
1442
1443 auto compilerLauncher = this->GetCompilerLauncher(language, config);
1444
1445 cmValue const srcSkipCodeCheckVal = source->GetProperty("SKIP_LINTING");
1446 bool const skipCodeCheck = srcSkipCodeCheckVal.IsSet()
1447 ? srcSkipCodeCheckVal.IsOn()
1448 : this->GetGeneratorTarget()->GetPropertyAsBool("SKIP_LINTING");
1449
1450 if (!skipCodeCheck) {
1451 auto const cmakeCmd =

Callers 1

Calls 15

GetObjectFileDirMethod · 0.95
GetObjectFilePathMethod · 0.95
GetMakefileMethod · 0.95
ForceResponseFileMethod · 0.95
LanguageCompilerRuleMethod · 0.95
ComputeFlagsForObjectMethod · 0.95
ComputeDefinesMethod · 0.95
ComputeIncludesMethod · 0.95
GetGeneratorTargetMethod · 0.95
GetLocalGeneratorMethod · 0.95

Tested by

no test coverage detected