summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileExecutableTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefileExecutableTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx53
1 files changed, 28 insertions, 25 deletions
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 9d42257..3b8bf5a 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -187,6 +187,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->LocalGenerator->AppendFlags(
linkFlags, this->Makefile->GetDefinition(export_flag_var));
}
+ if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) {
+ this->LocalGenerator->AppendFlags(linkFlags, " -Wl,--no-as-needed");
+ }
// Add language feature flags.
this->AddFeatureFlags(flags, linkLanguage);
@@ -274,27 +277,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
}
- // Select whether to use a response file for objects.
- bool useResponseFileForObjects = false;
- {
- std::string responseVar = "CMAKE_";
- responseVar += linkLanguage;
- responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
- if (this->Makefile->IsOn(responseVar)) {
- useResponseFileForObjects = true;
- }
- }
-
- // Select whether to use a response file for libraries.
- bool useResponseFileForLibs = false;
- {
- std::string responseVar = "CMAKE_";
- responseVar += linkLanguage;
- responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
- if (this->Makefile->IsOn(responseVar)) {
- useResponseFileForLibs = true;
- }
- }
+ bool useResponseFileForObjects =
+ this->CheckUseResponseFileForObjects(linkLanguage);
+ bool const useResponseFileForLibs =
+ this->CheckUseResponseFileForLibraries(linkLanguage);
// Expand the rule variables.
{
@@ -315,6 +301,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->CreateObjectLists(useLinkScript, false, useResponseFileForObjects,
buildObjs, depends, useWatcomQuote);
+ // maybe create .def file from list of objects
+ if (this->GeneratorTarget->IsExecutableWithExports() &&
+ this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) {
+ this->GenDefFile(real_link_commands, linkFlags);
+ }
+
std::string manifests = this->GetManifests();
cmLocalGenerator::RuleVariables vars;
@@ -356,6 +348,15 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
vars.LinkFlags = linkFlags.c_str();
vars.Manifests = manifests.c_str();
+ if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) {
+ std::string cmakeCommand =
+ this->Convert(cmSystemTools::GetCMakeCommand(), cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL);
+ cmakeCommand += " -E __run_iwyu --lwyu=";
+ cmakeCommand += targetOutPathReal;
+ real_link_commands.push_back(cmakeCommand);
+ }
+
// Expand placeholders in the commands.
this->LocalGenerator->TargetImplib = targetOutPathImport;
for (std::vector<std::string>::iterator i = real_link_commands.begin();
@@ -406,8 +407,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
// Write the build rule.
- this->LocalGenerator->WriteMakeRule(
- *this->BuildFileStream, 0, targetFullPathReal, depends, commands, false);
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ targetFullPathReal, depends, commands,
+ false);
// The symlink name for the target should depend on the real target
// so if the target version changes it rebuilds and recreates the
@@ -416,8 +418,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
depends.clear();
commands.clear();
depends.push_back(targetFullPathReal);
- this->LocalGenerator->WriteMakeRule(
- *this->BuildFileStream, 0, targetFullPath, depends, commands, false);
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ targetFullPath, depends, commands,
+ false);
}
// Write the main driver rule to build everything in this target.