diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2024-04-27 22:40:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-05-01 13:54:50 (GMT) |
commit | 3022f0363fa7402588ddf911dc0076dc55e5e9fa (patch) | |
tree | fe9eefef0a4dcccc2c40e6a6e560d608c8a15011 | |
parent | dff511ad28a309003d36c5d83ca0c9b82881de03 (diff) | |
download | CMake-3022f0363fa7402588ddf911dc0076dc55e5e9fa.zip CMake-3022f0363fa7402588ddf911dc0076dc55e5e9fa.tar.gz CMake-3022f0363fa7402588ddf911dc0076dc55e5e9fa.tar.bz2 |
VS: set ScanSourceForModuleDependencies at vcxproj level
Implement the target-wide `CXX_SCAN_FOR_MODULES`/`CMP0155` selection
with the `.vcxproj`-wide `ScanSourceForModuleDependencies` setting.
Set the per-source equivalent only when needed for a per-source
`CXX_SCAN_FOR_MODULES` property.
This approach enables Intellisense for interfaces imported from modules.
It is also more consistent with what a user might expect when
investigating the state of module scanning from the VS property panels.
Fixes: #25806
Fixes: #25947
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 25 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 1 |
2 files changed, 21 insertions, 5 deletions
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; |