Merge topic 'vs-scan-module-deps-settings' into release-3.29
3022f0363f
VS: set ScanSourceForModuleDependencies at vcxproj leveldff511ad28
cmGeneratorTarget: add a target-level query for "needs dyndep" Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: AaronRuizMoraUK <aaronruizmora@gmail.com> Merge-request: !9471
This commit is contained in:
commit
a344140dfa
@ -9498,11 +9498,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:
|
||||
@ -9512,28 +9526,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;
|
||||
|
@ -1341,6 +1341,13 @@ public:
|
||||
cmSourceFile const* sf) const;
|
||||
bool NeedDyndepForSource(std::string const& lang, std::string const& config,
|
||||
cmSourceFile const* sf) const;
|
||||
enum class CxxModuleSupport
|
||||
{
|
||||
Unavailable,
|
||||
Enabled,
|
||||
Disabled,
|
||||
};
|
||||
CxxModuleSupport NeedCxxDyndep(std::string const& config) const;
|
||||
|
||||
private:
|
||||
void BuildFileSetInfoCache(std::string const& config) const;
|
||||
|
@ -281,6 +281,16 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
|
||||
this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
|
||||
this->NsightTegra = gg->IsNsightTegra();
|
||||
this->Android = gg->TargetsAndroid();
|
||||
auto scanProp = target->GetProperty("CXX_SCAN_FOR_MODULES");
|
||||
for (auto const& config : this->Configurations) {
|
||||
if (scanProp.IsSet()) {
|
||||
this->ScanSourceForModuleDependencies[config] = scanProp.IsOn();
|
||||
} else {
|
||||
this->ScanSourceForModuleDependencies[config] =
|
||||
target->NeedCxxDyndep(config) ==
|
||||
cmGeneratorTarget::CxxModuleSupport::Enabled;
|
||||
}
|
||||
}
|
||||
for (unsigned int& version : this->NsightTegraVersion) {
|
||||
version = 0;
|
||||
}
|
||||
@ -2827,7 +2837,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||
// use them
|
||||
if (!flags.empty() || !options.empty() || !configDefines.empty() ||
|
||||
!includes.empty() || compileAsPerConfig || noWinRT ||
|
||||
!options.empty() || needsPCHFlags || shouldScanForModules) {
|
||||
!options.empty() || needsPCHFlags ||
|
||||
(shouldScanForModules !=
|
||||
this->ScanSourceForModuleDependencies[config])) {
|
||||
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
|
||||
cmIDEFlagTable const* flagtable = nullptr;
|
||||
const std::string& srclang = source->GetLanguage();
|
||||
@ -2855,8 +2867,10 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||
if (compileAsPerConfig) {
|
||||
clOptions.AddFlag("CompileAs", compileAsPerConfig);
|
||||
}
|
||||
if (shouldScanForModules) {
|
||||
clOptions.AddFlag("ScanSourceForModuleDependencies", "true");
|
||||
if (shouldScanForModules !=
|
||||
this->ScanSourceForModuleDependencies[config]) {
|
||||
clOptions.AddFlag("ScanSourceForModuleDependencies",
|
||||
shouldScanForModules ? "true" : "false");
|
||||
}
|
||||
if (noWinRT) {
|
||||
clOptions.AddFlag("CompileAsWinRT", "false");
|
||||
@ -3573,8 +3587,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||
}
|
||||
}
|
||||
|
||||
// Disable C++ source scanning by default.
|
||||
e2.Element("ScanSourceForModuleDependencies", "false");
|
||||
e2.Element("ScanSourceForModuleDependencies",
|
||||
this->ScanSourceForModuleDependencies[configName] ? "true"
|
||||
: "false");
|
||||
}
|
||||
|
||||
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
|
||||
|
@ -238,6 +238,7 @@ private:
|
||||
bool NsightTegra;
|
||||
bool Android;
|
||||
bool HaveCustomCommandDepfile = false;
|
||||
std::map<std::string, bool> ScanSourceForModuleDependencies;
|
||||
unsigned int NsightTegraVersion[4];
|
||||
bool TargetCompileAsWinRT;
|
||||
std::set<std::string> IPOEnabledConfigurations;
|
||||
|
Loading…
Reference in New Issue
Block a user