diff options
author | Brad King <brad.king@kitware.com> | 2024-05-02 13:39:52 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-05-02 13:40:03 (GMT) |
commit | a344140dfaddd5df9ab8853cd9633d52fa02786c (patch) | |
tree | 2c646db79bfacc73f987e52459a1eb538de7e3d3 | |
parent | 9fd37ca65e59d61ea04ab93c32c189701030f19d (diff) | |
parent | 3022f0363fa7402588ddf911dc0076dc55e5e9fa (diff) | |
download | CMake-a344140dfaddd5df9ab8853cd9633d52fa02786c.zip CMake-a344140dfaddd5df9ab8853cd9633d52fa02786c.tar.gz CMake-a344140dfaddd5df9ab8853cd9633d52fa02786c.tar.bz2 |
Merge topic 'vs-scan-module-deps-settings' into release-3.29
3022f0363f VS: set ScanSourceForModuleDependencies at vcxproj level
dff511ad28 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
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 33 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 7 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 25 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 1 |
4 files changed, 52 insertions, 14 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index ccb6748..0fe19de 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -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; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 90b15ec..71785b6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -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; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index d572f30..fbd676d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -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() diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 2080e9e..1f8b2eb 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -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; |