mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 07:11:52 +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->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
|
||||||
this->NsightTegra = gg->IsNsightTegra();
|
this->NsightTegra = gg->IsNsightTegra();
|
||||||
this->Android = gg->TargetsAndroid();
|
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) {
|
for (unsigned int& version : this->NsightTegraVersion) {
|
||||||
version = 0;
|
version = 0;
|
||||||
}
|
}
|
||||||
@@ -2827,7 +2837,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
|||||||
// use them
|
// use them
|
||||||
if (!flags.empty() || !options.empty() || !configDefines.empty() ||
|
if (!flags.empty() || !options.empty() || !configDefines.empty() ||
|
||||||
!includes.empty() || compileAsPerConfig || noWinRT ||
|
!includes.empty() || compileAsPerConfig || noWinRT ||
|
||||||
!options.empty() || needsPCHFlags || shouldScanForModules) {
|
!options.empty() || needsPCHFlags ||
|
||||||
|
(shouldScanForModules !=
|
||||||
|
this->ScanSourceForModuleDependencies[config])) {
|
||||||
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
|
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
|
||||||
cmIDEFlagTable const* flagtable = nullptr;
|
cmIDEFlagTable const* flagtable = nullptr;
|
||||||
const std::string& srclang = source->GetLanguage();
|
const std::string& srclang = source->GetLanguage();
|
||||||
@@ -2855,8 +2867,10 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
|||||||
if (compileAsPerConfig) {
|
if (compileAsPerConfig) {
|
||||||
clOptions.AddFlag("CompileAs", compileAsPerConfig);
|
clOptions.AddFlag("CompileAs", compileAsPerConfig);
|
||||||
}
|
}
|
||||||
if (shouldScanForModules) {
|
if (shouldScanForModules !=
|
||||||
clOptions.AddFlag("ScanSourceForModuleDependencies", "true");
|
this->ScanSourceForModuleDependencies[config]) {
|
||||||
|
clOptions.AddFlag("ScanSourceForModuleDependencies",
|
||||||
|
shouldScanForModules ? "true" : "false");
|
||||||
}
|
}
|
||||||
if (noWinRT) {
|
if (noWinRT) {
|
||||||
clOptions.AddFlag("CompileAsWinRT", "false");
|
clOptions.AddFlag("CompileAsWinRT", "false");
|
||||||
@@ -3563,8 +3577,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable C++ source scanning by default.
|
e2.Element("ScanSourceForModuleDependencies",
|
||||||
e2.Element("ScanSourceForModuleDependencies", "false");
|
this->ScanSourceForModuleDependencies[configName] ? "true"
|
||||||
|
: "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
|
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
|
||||||
|
@@ -238,6 +238,7 @@ private:
|
|||||||
bool NsightTegra;
|
bool NsightTegra;
|
||||||
bool Android;
|
bool Android;
|
||||||
bool HaveCustomCommandDepfile = false;
|
bool HaveCustomCommandDepfile = false;
|
||||||
|
std::map<std::string, bool> ScanSourceForModuleDependencies;
|
||||||
unsigned int NsightTegraVersion[4];
|
unsigned int NsightTegraVersion[4];
|
||||||
bool TargetCompileAsWinRT;
|
bool TargetCompileAsWinRT;
|
||||||
std::set<std::string> IPOEnabledConfigurations;
|
std::set<std::string> IPOEnabledConfigurations;
|
||||||
|
Reference in New Issue
Block a user