diff options
author | Brad King <brad.king@kitware.com> | 2024-05-02 13:39:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-05-02 13:39:27 (GMT) |
commit | 1584432c35198348dc65d7d9035723908c809aae (patch) | |
tree | fe9eefef0a4dcccc2c40e6a6e560d608c8a15011 | |
parent | f909fc2f92a78c8bbf73180edf0b81aba69d4467 (diff) | |
parent | 3022f0363fa7402588ddf911dc0076dc55e5e9fa (diff) | |
download | CMake-1584432c35198348dc65d7d9035723908c809aae.zip CMake-1584432c35198348dc65d7d9035723908c809aae.tar.gz CMake-1584432c35198348dc65d7d9035723908c809aae.tar.bz2 |
Merge topic 'vs-scan-module-deps-settings' into release-3.28
3022f0363f VS: set ScanSourceForModuleDependencies at vcxproj level
dff511ad28 cmGeneratorTarget: add a target-level query for "needs dyndep"
Acked-by: Kitware Robot <kwrobot@kitware.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 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; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7cd7f43..ed5a4be 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -1327,6 +1327,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 708cbaf..73fd89f 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"); @@ -3563,8 +3577,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; |