diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2024-04-30 18:55:37 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-05-01 13:41:07 (GMT) |
commit | dff511ad28a309003d36c5d83ca0c9b82881de03 (patch) | |
tree | 10bde4b793c6482d2e3cfe99df33f4e865e2966c /Source/cmGeneratorTarget.cxx | |
parent | f909fc2f92a78c8bbf73180edf0b81aba69d4467 (diff) | |
download | CMake-dff511ad28a309003d36c5d83ca0c9b82881de03.zip CMake-dff511ad28a309003d36c5d83ca0c9b82881de03.tar.gz CMake-dff511ad28a309003d36c5d83ca0c9b82881de03.tar.bz2 |
cmGeneratorTarget: add a target-level query for "needs dyndep"
This can still be overridden per-source, but it indicates the state of
the target's default behavior.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 332098e..26ae2da 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -9374,11 +9374,25 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang, return true; } + auto targetDyndep = this->NeedCxxDyndep(config); + if (targetDyndep == CxxModuleSupport::Unavailable) { + return false; + } + auto const sfProp = sf->GetProperty("CXX_SCAN_FOR_MODULES"); + if (sfProp.IsSet()) { + return sfProp.IsOn(); + } + return targetDyndep == CxxModuleSupport::Enabled; +} + +cmGeneratorTarget::CxxModuleSupport cmGeneratorTarget::NeedCxxDyndep( + std::string const& config) const +{ bool haveRule = false; switch (this->HaveCxxModuleSupport(config)) { case Cxx20SupportLevel::MissingCxx: case Cxx20SupportLevel::NoCxx20: - return false; + return CxxModuleSupport::Unavailable; case Cxx20SupportLevel::MissingRule: break; case Cxx20SupportLevel::Supported: @@ -9388,28 +9402,29 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang, bool haveGeneratorSupport = this->GetGlobalGenerator()->CheckCxxModuleSupport( cmGlobalGenerator::CxxModuleSupportQuery::Inspect); - auto const sfProp = sf->GetProperty("CXX_SCAN_FOR_MODULES"); - if (sfProp.IsSet()) { - return sfProp.IsOn(); - } auto const tgtProp = this->GetProperty("CXX_SCAN_FOR_MODULES"); if (tgtProp.IsSet()) { - return tgtProp.IsOn(); + return tgtProp.IsOn() ? CxxModuleSupport::Enabled + : CxxModuleSupport::Disabled; } - bool policyAnswer = false; + CxxModuleSupport policyAnswer = CxxModuleSupport::Unavailable; switch (this->GetPolicyStatusCMP0155()) { case cmPolicies::WARN: case cmPolicies::OLD: // The OLD behavior is to not scan the source. - policyAnswer = false; + policyAnswer = CxxModuleSupport::Disabled; break; case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_IF_USED: case cmPolicies::NEW: // The NEW behavior is to scan the source if the compiler supports // scanning and the generator supports it. - policyAnswer = haveRule && haveGeneratorSupport; + if (haveRule && haveGeneratorSupport) { + policyAnswer = CxxModuleSupport::Enabled; + } else { + policyAnswer = CxxModuleSupport::Disabled; + } break; } return policyAnswer; |