diff options
author | Brad King <brad.king@kitware.com> | 2021-07-12 12:43:25 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-07-12 12:43:32 (GMT) |
commit | c9cd039e5f312f2717c6522ac7117791856f734b (patch) | |
tree | b58053d2319951dbff155e1453d1fe3969065403 /Source/cmLocalGenerator.cxx | |
parent | 2d830247bae808cc68f26288ff72768b21d0c102 (diff) | |
parent | 14e57e9637964594461711954c6c906bc22eb7c7 (diff) | |
download | CMake-c9cd039e5f312f2717c6522ac7117791856f734b.zip CMake-c9cd039e5f312f2717c6522ac7117791856f734b.tar.gz CMake-c9cd039e5f312f2717c6522ac7117791856f734b.tar.bz2 |
Merge topic 'LWYU-externalization'
14e57e9637 LINK_WHAT_YOU_USE feature: externalize configuration
9c5132a586 PGI: Fix "LINKER:" prefix generated separator
8a93de080c cmGeneratorTarget: Add method for LINKER: prefix translation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6306
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3d36acd..028952a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3058,6 +3058,30 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags( } } +bool cmLocalGenerator::AppendLWYUFlags(std::string& flags, + const cmGeneratorTarget* target, + const std::string& lang) +{ + auto useLWYU = target->GetPropertyAsBool("LINK_WHAT_YOU_USE") && + (target->GetType() == cmStateEnums::TargetType::EXECUTABLE || + target->GetType() == cmStateEnums::TargetType::SHARED_LIBRARY || + target->GetType() == cmStateEnums::TargetType::MODULE_LIBRARY); + + if (useLWYU) { + const auto& lwyuFlag = this->GetMakefile()->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_LINK_WHAT_YOU_USE_FLAG")); + useLWYU = !lwyuFlag.empty(); + + if (useLWYU) { + std::vector<BT<std::string>> lwyuOpts; + lwyuOpts.emplace_back(lwyuFlag); + this->AppendFlags(flags, target->ResolveLinkerWrapper(lwyuOpts, lang)); + } + } + + return useLWYU; +} + void cmLocalGenerator::AppendCompileOptions(std::string& options, std::string const& options_list, const char* regex) const |