Commit 33cb0173 authored by Jamie Snape's avatar Jamie Snape Committed by Brad King
Browse files

Honor LINK_WHAT_YOU_USE when set to OFF

Explicitly setting variable CMAKE_LINK_WHAT_YOU_USE or property
LINK_WHAT_YOU_USE to OFF should not cause LWYU to run.  Fix the
property lookup to use GetPropertyAsBool.
parent 8eb6038d
Pipeline #30909 passed with stage
...@@ -198,7 +198,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) ...@@ -198,7 +198,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->LocalGenerator->GetLinkLibsCMP0065( this->LocalGenerator->GetLinkLibsCMP0065(
linkLanguage, *this->GeneratorTarget)); linkLanguage, *this->GeneratorTarget));
if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
this->LocalGenerator->AppendFlags(linkFlags, " -Wl,--no-as-needed"); this->LocalGenerator->AppendFlags(linkFlags, " -Wl,--no-as-needed");
} }
...@@ -375,7 +375,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) ...@@ -375,7 +375,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
vars.LinkFlags = linkFlags.c_str(); vars.LinkFlags = linkFlags.c_str();
vars.Manifests = manifests.c_str(); vars.Manifests = manifests.c_str();
if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat( std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
cmakeCommand += " -E __run_iwyu --lwyu="; cmakeCommand += " -E __run_iwyu --lwyu=";
......
...@@ -168,7 +168,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) ...@@ -168,7 +168,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags); this->AddModuleDefinitionFlag(linkLineComputer.get(), extraFlags);
if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
this->LocalGenerator->AppendFlags(extraFlags, " -Wl,--no-as-needed"); this->LocalGenerator->AppendFlags(extraFlags, " -Wl,--no-as-needed");
} }
this->WriteLibraryRules(linkRuleVar, extraFlags, relink); this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
...@@ -660,7 +660,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( ...@@ -660,7 +660,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Get the set of commands. // Get the set of commands.
std::string linkRule = this->GetLinkRule(linkRuleVar); std::string linkRule = this->GetLinkRule(linkRuleVar);
cmSystemTools::ExpandListArgument(linkRule, real_link_commands); cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE") && if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE") &&
(this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)) { (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)) {
std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat( std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
......
...@@ -316,7 +316,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() ...@@ -316,7 +316,7 @@ 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")) { if (this->GetGeneratorTarget()->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
std::string cmakeCommand = std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat( this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
...@@ -512,7 +512,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() ...@@ -512,7 +512,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
vars["LINK_PATH"] = frameworkPath + linkPath; vars["LINK_PATH"] = frameworkPath + linkPath;
std::string lwyuFlags; std::string lwyuFlags;
if (genTarget.GetProperty("LINK_WHAT_YOU_USE")) { if (genTarget.GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
lwyuFlags = " -Wl,--no-as-needed"; lwyuFlags = " -Wl,--no-as-needed";
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment