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

Method WriteObjectRuleFiles

Source/cmMakefileTargetGenerator.cxx:632–1319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632void cmMakefileTargetGenerator::WriteObjectRuleFiles(
633 cmSourceFile const& source)
634{
635 // Identify the language of the source file.
636 std::string const& lang = source.GetLanguage();
637 if (lang.empty()) {
638 // don't know anything about this file so skip it
639 return;
640 }
641
642 // Use compiler to generate dependencies, if supported.
643 bool const compilerGenerateDeps =
644 this->GlobalGenerator->SupportsCompilerDependencies() &&
645 this->Makefile
646 ->GetDefinition(cmStrCat("CMAKE_", lang, "_DEPENDS_USE_COMPILER"))
647 .IsOn();
648 auto const scanner = compilerGenerateDeps ? cmDependencyScannerKind::Compiler
649 : cmDependencyScannerKind::CMake;
650
651 // Get the full path name of the object file.
652 std::string const& objectName =
653 this->GeneratorTarget->GetObjectName(&source);
654 std::string const obj =
655 cmStrCat(this->TargetBuildDirectory, '/', objectName);
656
657 // Avoid generating duplicate rules.
658 if (this->ObjectFiles.find(obj) == this->ObjectFiles.end()) {
659 this->ObjectFiles.insert(obj);
660 } else {
661 std::ostringstream err;
662 err << "Warning: Source file \"" << source.GetFullPath()
663 << "\" is listed multiple times for target \""
664 << this->GeneratorTarget->GetName() << "\".";
665 cmSystemTools::Message(err.str(), "Warning");
666 return;
667 }
668
669 // Create the directory containing the object file. This may be a
670 // subdirectory under the target's directory.
671 {
672 std::string const dir = cmSystemTools::GetFilenamePath(obj);
673 cmSystemTools::MakeDirectory(this->LocalGenerator->ConvertToFullPath(dir));
674 }
675
676 // Save this in the target's list of object files.
677 this->Objects.push_back(obj);
678 this->CleanFiles.insert(obj);
679
680 std::vector<std::string> depends;
681
682 // The object file should be checked for dependency integrity.
683 std::string objFullPath =
684 cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/', obj);
685 std::string const srcFullPath = source.GetFullPath();
686 this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang,
687 objFullPath, srcFullPath, scanner);
688
689 this->LocalGenerator->AppendRuleDepend(depends,

Callers 1

WriteTargetBuildRulesMethod · 0.95

Calls 15

MakeEchoProgressMethod · 0.95
GetGeneratorTargetMethod · 0.95
WriteMakeRuleMethod · 0.95
MessageClass · 0.85
cmHasSuffixFunction · 0.85
cmMakeRangeFunction · 0.85
cmNonemptyFunction · 0.85
appendFunction · 0.85
moveFunction · 0.85
GetLanguageMethod · 0.80

Tested by

no test coverage detected