summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-11-24 01:28:24 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2022-12-01 13:33:43 (GMT)
commitf0899e46fb52332c868f2246f99cea8cfd08384e (patch)
treeea3506aa6dd4d0871a34b7c9384490262b6e7931 /Source/cmVisualStudio10TargetGenerator.cxx
parentb0283aaa7ca4b6e3020798ef20cee9f827ce16fc (diff)
downloadCMake-f0899e46fb52332c868f2246f99cea8cfd08384e.zip
CMake-f0899e46fb52332c868f2246f99cea8cfd08384e.tar.gz
CMake-f0899e46fb52332c868f2246f99cea8cfd08384e.tar.bz2
cmVisualStudio10TargetGenerator: write C++ module elements
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-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");