diff options
author | Brad King <brad.king@kitware.com> | 2016-06-17 15:06:44 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-06-17 15:06:44 (GMT) |
commit | e4cb7d76095c429690255620a101b1a6f66f65df (patch) | |
tree | f65370811868c80fa3209bc76fff540182d1f19b /Source/cmMakefileLibraryTargetGenerator.cxx | |
parent | 5889eb43eaad2e377cee36f813872ddb381b2e43 (diff) | |
parent | a0902efaa747d567fdd35729c8f0dac7b4fbee6d (diff) | |
download | CMake-e4cb7d76095c429690255620a101b1a6f66f65df.zip CMake-e4cb7d76095c429690255620a101b1a6f66f65df.tar.gz CMake-e4cb7d76095c429690255620a101b1a6f66f65df.tar.bz2 |
Merge topic 'link_what_you_use'
a0902efa Help: Add notes for topic 'link_what_you_use'
96242f80 Add options to run `ldd -u -r` as a "link-what-you-use" tool
Diffstat (limited to 'Source/cmMakefileLibraryTargetGenerator.cxx')
-rw-r--r-- | Source/cmMakefileLibraryTargetGenerator.cxx | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 438f90f..5348b80 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -163,6 +163,9 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName); this->AddModuleDefinitionFlag(extraFlags); + if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE")) { + this->LocalGenerator->AppendFlags(extraFlags, " -Wl,--no-as-needed"); + } this->WriteLibraryRules(linkRuleVar, extraFlags, relink); } @@ -686,6 +689,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Get the set of commands. std::string linkRule = this->GetLinkRule(linkRuleVar); cmSystemTools::ExpandListArgument(linkRule, real_link_commands); + if (this->GeneratorTarget->GetProperty("LINK_WHAT_YOU_USE") && + (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)) { + 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. for (std::vector<std::string>::iterator i = real_link_commands.begin(); @@ -732,6 +744,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( commands.insert(commands.end(), commands1.begin(), commands1.end()); commands1.clear(); } + // Add the post-build rules when building but not when relinking. if (!relink) { this->LocalGenerator->AppendCustomCommands( |