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

Method ComputeLinkCmd

Source/cmNinjaNormalTargetGenerator.cxx:729–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727}
728
729std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd(
730 std::string const& config)
731{
732 cmList linkCmds;
733 cmMakefile* mf = this->GetMakefile();
734 {
735 // If we have a rule variable prefer it. In the case of static libraries
736 // this occurs when things like IPO is enabled, and we need to use the
737 // CMAKE_<lang>_CREATE_STATIC_LIBRARY_IPO define instead.
738 std::string linkCmdVar = this->GetGeneratorTarget()->GetCreateRuleVariable(
739 this->TargetLinkLanguage(config), config);
740 cmValue linkCmd = mf->GetDefinition(linkCmdVar);
741 if (linkCmd) {
742 std::string linkCmdStr = *linkCmd;
743 if (this->GetGeneratorTarget()->HasImplibGNUtoMS(config)) {
744 std::string ruleVar =
745 cmStrCat("CMAKE_", this->GeneratorTarget->GetLinkerLanguage(config),
746 "_GNUtoMS_RULE");
747 if (cmValue rule = this->Makefile->GetDefinition(ruleVar)) {
748 linkCmdStr += *rule;
749 }
750 }
751 linkCmds.assign(linkCmdStr);
752 if (this->UseLWYU) {
753 cmValue lwyuCheck = mf->GetDefinition("CMAKE_LINK_WHAT_YOU_USE_CHECK");
754 if (lwyuCheck) {
755 std::string cmakeCommand = cmStrCat(
756 this->GetLocalGenerator()->ConvertToOutputFormat(
757 cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL),
758 " -E __run_co_compile --lwyu=");
759 cmakeCommand +=
760 this->GetLocalGenerator()->EscapeForShell(*lwyuCheck);
761
762 std::string targetOutputReal =
763 this->ConvertToNinjaPath(this->GetGeneratorTarget()->GetFullPath(
764 config, cmStateEnums::RuntimeBinaryArtifact,
765 /*realname=*/true));
766 cmakeCommand += cmStrCat(" --source=", targetOutputReal);
767 linkCmds.push_back(std::move(cmakeCommand));
768 }
769 }
770 return std::move(linkCmds.data());
771 }
772 }
773 switch (this->GetGeneratorTarget()->GetType()) {
774 case cmStateEnums::STATIC_LIBRARY: {
775 // We have archive link commands set. First, delete the existing archive.
776 {
777 std::string cmakeCommand =
778 this->GetLocalGenerator()->ConvertToOutputFormat(
779 cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
780 linkCmds.push_back(cmakeCommand + " -E rm -f $TARGET_FILE");
781 }
782 // TODO: Use ARCHIVE_APPEND for archives over a certain size.
783 {
784 std::string linkCmdVar = cmStrCat(
785 "CMAKE_", this->TargetLinkLanguage(config), "_ARCHIVE_CREATE");
786

Callers 1

WriteLinkRuleMethod · 0.95

Calls 15

TargetLinkLanguageMethod · 0.95
moveFunction · 0.85
GetCreateRuleVariableMethod · 0.80
HasImplibGNUtoMSMethod · 0.80
assignMethod · 0.80
EscapeForShellMethod · 0.80
push_backMethod · 0.80
appendMethod · 0.80
cmStrCatFunction · 0.70
GetMakefileMethod · 0.45
GetGeneratorTargetMethod · 0.45

Tested by

no test coverage detected