|
@@ -295,6 +295,22 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
|
|
|
const char* linkCmd = mf->GetDefinition(linkCmdVar);
|
|
const char* linkCmd = mf->GetDefinition(linkCmdVar);
|
|
|
if (linkCmd) {
|
|
if (linkCmd) {
|
|
|
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
|
|
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
|
|
|
|
|
+ if (this->GetGeneratorTarget()->GetProperty("LINK_WHAT_YOU_USE")) {
|
|
|
|
|
+ std::string cmakeCommand =
|
|
|
|
|
+ this->GetLocalGenerator()->ConvertToOutputFormat(
|
|
|
|
|
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
|
|
|
|
|
+ cmakeCommand += " -E __run_iwyu --lwyu=";
|
|
|
|
|
+ cmGeneratorTarget& gt = *this->GetGeneratorTarget();
|
|
|
|
|
+ const std::string cfgName = this->GetConfigName();
|
|
|
|
|
+ std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
|
|
|
|
|
+ std::string targetOutputReal =
|
|
|
|
|
+ this->ConvertToNinjaPath(gt.GetFullPath(cfgName,
|
|
|
|
|
+ /*implib=*/false,
|
|
|
|
|
+ /*realpath=*/true));
|
|
|
|
|
+ cmakeCommand += targetOutputReal;
|
|
|
|
|
+ cmakeCommand += " || true";
|
|
|
|
|
+ linkCmds.push_back(cmakeCommand);
|
|
|
|
|
+ }
|
|
|
return linkCmds;
|
|
return linkCmds;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -467,6 +483,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|
|
vars["MANIFESTS"] = this->GetManifests();
|
|
vars["MANIFESTS"] = this->GetManifests();
|
|
|
|
|
|
|
|
vars["LINK_PATH"] = frameworkPath + linkPath;
|
|
vars["LINK_PATH"] = frameworkPath + linkPath;
|
|
|
|
|
+ std::string lwyuFlags;
|
|
|
|
|
+ if (genTarget.GetProperty("LINK_WHAT_YOU_USE")) {
|
|
|
|
|
+ lwyuFlags = " -Wl,--no-as-needed";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Compute architecture specific link flags. Yes, these go into a different
|
|
// Compute architecture specific link flags. Yes, these go into a different
|
|
|
// variable for executables, probably due to a mistake made when duplicating
|
|
// variable for executables, probably due to a mistake made when duplicating
|
|
@@ -474,16 +494,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|
|
if (targetType == cmState::EXECUTABLE) {
|
|
if (targetType == cmState::EXECUTABLE) {
|
|
|
std::string t = vars["FLAGS"];
|
|
std::string t = vars["FLAGS"];
|
|
|
localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
|
|
localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
|
|
|
|
|
+ t += lwyuFlags;
|
|
|
vars["FLAGS"] = t;
|
|
vars["FLAGS"] = t;
|
|
|
} else {
|
|
} else {
|
|
|
std::string t = vars["ARCH_FLAGS"];
|
|
std::string t = vars["ARCH_FLAGS"];
|
|
|
localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
|
|
localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
|
|
|
vars["ARCH_FLAGS"] = t;
|
|
vars["ARCH_FLAGS"] = t;
|
|
|
t = "";
|
|
t = "";
|
|
|
|
|
+ t += lwyuFlags;
|
|
|
localGen.AddLanguageFlags(t, TargetLinkLanguage, cfgName);
|
|
localGen.AddLanguageFlags(t, TargetLinkLanguage, cfgName);
|
|
|
vars["LANGUAGE_COMPILE_FLAGS"] = t;
|
|
vars["LANGUAGE_COMPILE_FLAGS"] = t;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if (this->GetGeneratorTarget()->HasSOName(cfgName)) {
|
|
if (this->GetGeneratorTarget()->HasSOName(cfgName)) {
|
|
|
vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage);
|
|
vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage);
|
|
|
vars["SONAME"] = this->TargetNameSO;
|
|
vars["SONAME"] = this->TargetNameSO;
|
|
@@ -607,7 +628,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|
|
vars["POST_BUILD"] = ":";
|
|
vars["POST_BUILD"] = ":";
|
|
|
symlinkVars["POST_BUILD"] = postBuildCmdLine;
|
|
symlinkVars["POST_BUILD"] = postBuildCmdLine;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
|
|
cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
|
|
|
|
|
|
|
|
int commandLineLengthLimit = -1;
|
|
int commandLineLengthLimit = -1;
|