1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-17 07:11:52 +08:00

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.
This commit is contained in:
Ben Boeckel
2024-04-30 14:55:37 -04:00
committed by Brad King
parent f909fc2f92
commit dff511ad28
2 changed files with 31 additions and 9 deletions

View File

@@ -9374,11 +9374,25 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang,
return true; 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; bool haveRule = false;
switch (this->HaveCxxModuleSupport(config)) { switch (this->HaveCxxModuleSupport(config)) {
case Cxx20SupportLevel::MissingCxx: case Cxx20SupportLevel::MissingCxx:
case Cxx20SupportLevel::NoCxx20: case Cxx20SupportLevel::NoCxx20:
return false; return CxxModuleSupport::Unavailable;
case Cxx20SupportLevel::MissingRule: case Cxx20SupportLevel::MissingRule:
break; break;
case Cxx20SupportLevel::Supported: case Cxx20SupportLevel::Supported:
@@ -9388,28 +9402,29 @@ bool cmGeneratorTarget::NeedDyndepForSource(std::string const& lang,
bool haveGeneratorSupport = bool haveGeneratorSupport =
this->GetGlobalGenerator()->CheckCxxModuleSupport( this->GetGlobalGenerator()->CheckCxxModuleSupport(
cmGlobalGenerator::CxxModuleSupportQuery::Inspect); 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"); auto const tgtProp = this->GetProperty("CXX_SCAN_FOR_MODULES");
if (tgtProp.IsSet()) { if (tgtProp.IsSet()) {
return tgtProp.IsOn(); return tgtProp.IsOn() ? CxxModuleSupport::Enabled
: CxxModuleSupport::Disabled;
} }
bool policyAnswer = false; CxxModuleSupport policyAnswer = CxxModuleSupport::Unavailable;
switch (this->GetPolicyStatusCMP0155()) { switch (this->GetPolicyStatusCMP0155()) {
case cmPolicies::WARN: case cmPolicies::WARN:
case cmPolicies::OLD: case cmPolicies::OLD:
// The OLD behavior is to not scan the source. // The OLD behavior is to not scan the source.
policyAnswer = false; policyAnswer = CxxModuleSupport::Disabled;
break; break;
case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW: case cmPolicies::NEW:
// The NEW behavior is to scan the source if the compiler supports // The NEW behavior is to scan the source if the compiler supports
// scanning and the generator supports it. // scanning and the generator supports it.
policyAnswer = haveRule && haveGeneratorSupport; if (haveRule && haveGeneratorSupport) {
policyAnswer = CxxModuleSupport::Enabled;
} else {
policyAnswer = CxxModuleSupport::Disabled;
}
break; break;
} }
return policyAnswer; return policyAnswer;

View File

@@ -1327,6 +1327,13 @@ public:
cmSourceFile const* sf) const; cmSourceFile const* sf) const;
bool NeedDyndepForSource(std::string const& lang, std::string const& config, bool NeedDyndepForSource(std::string const& lang, std::string const& config,
cmSourceFile const* sf) const; cmSourceFile const* sf) const;
enum class CxxModuleSupport
{
Unavailable,
Enabled,
Disabled,
};
CxxModuleSupport NeedCxxDyndep(std::string const& config) const;
private: private:
void BuildFileSetInfoCache(std::string const& config) const; void BuildFileSetInfoCache(std::string const& config) const;