mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
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
This commit is contained in:
@@ -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()
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user