diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2021-07-02 08:47:32 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2021-07-09 12:50:50 (GMT) |
commit | 14e57e9637964594461711954c6c906bc22eb7c7 (patch) | |
tree | 7e6bbfb2303d1c4377470180a36a6103df1a55fb /Source/cmLocalGenerator.cxx | |
parent | 9c5132a586562c00511fd8ff2bac0250c70dae95 (diff) | |
download | CMake-14e57e9637964594461711954c6c906bc22eb7c7.zip CMake-14e57e9637964594461711954c6c906bc22eb7c7.tar.gz CMake-14e57e9637964594461711954c6c906bc22eb7c7.tar.bz2 |
LINK_WHAT_YOU_USE feature: externalize configuration
Currently, this feature is only supported on ELF platforms. So, the property
LINK_WHAT_YOU_USE will be ignored for other plateforms.
Moreover, flags and commands are now controled by CMake variables.
Fixes: #20174
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 a14f085..6b88a03 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3047,6 +3047,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 |