summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx40
1 files changed, 36 insertions, 4 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 4097f95..ef4bcf8 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2711,6 +2711,8 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
}
for (std::string const& config : this->Configurations) {
+ this->GeneratorTarget->NeedCxxModuleSupport(lang, config);
+
std::string configUpper = cmSystemTools::UpperCase(config);
std::string configDefines = defines;
std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
@@ -2723,6 +2725,31 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
configDefines += *ccdefs;
}
+ bool const shouldScanForModules = lang == "CXX"_s &&
+ this->GeneratorTarget->NeedDyndepForSource(lang, config, source);
+ auto const* fs =
+ this->GeneratorTarget->GetFileSetForSource(config, source);
+ const char* compileAsPerConfig = compileAs;
+ if (fs &&
+ (fs->GetType() == "CXX_MODULES"_s ||
+ fs->GetType() == "CXX_MODULE_HEADER_UNITS"_s)) {
+ if (lang == "CXX"_s) {
+ if (fs->GetType() == "CXX_MODULES"_s) {
+ compileAsPerConfig = "CompileAsCppModule";
+ } else {
+ compileAsPerConfig = "CompileAsHeaderUnit";
+ }
+ } else {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Target \"", this->GeneratorTarget->Target->GetName(),
+ "\" contains the source\n ", source->GetFullPath(),
+ "\nin a file set of type \"", fs->GetType(),
+ R"(" but the source is not classified as a "CXX" source.)"));
+ }
+ }
+
// We have pch state in the following situation:
// 1. We have SKIP_PRECOMPILE_HEADERS == true
// 2. We are creating the pre-compiled header
@@ -2745,8 +2772,8 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
// if we have flags or defines for this config then
// use them
if (!flags.empty() || !options.empty() || !configDefines.empty() ||
- !includes.empty() || compileAs || noWinRT || !options.empty() ||
- needsPCHFlags) {
+ !includes.empty() || compileAsPerConfig || noWinRT ||
+ !options.empty() || needsPCHFlags) {
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
cmIDEFlagTable const* flagtable = nullptr;
const std::string& srclang = source->GetLanguage();
@@ -2771,8 +2798,13 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmVS10GeneratorOptions clOptions(
this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
flagtable, this);
- if (compileAs) {
- clOptions.AddFlag("CompileAs", compileAs);
+ if (compileAsPerConfig) {
+ clOptions.AddFlag("CompileAs", compileAsPerConfig);
+ }
+ if (shouldScanForModules) {
+ clOptions.AddFlag("ScanSourceforModuleDependencies", "true");
+ } else {
+ clOptions.AddFlag("ScanSourceforModuleDependencies", "false");
}
if (noWinRT) {
clOptions.AddFlag("CompileAsWinRT", "false");