diff options
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/cmExperimental.cxx | 2 | ||||
| -rw-r--r-- | Source/cmGlobalVisualStudio7Generator.h | 4 | ||||
| -rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.h | 10 | ||||
| -rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 43 |
4 files changed, 51 insertions, 8 deletions
diff --git a/Source/cmExperimental.cxx b/Source/cmExperimental.cxx index 922b53f..bbb5840 100644 --- a/Source/cmExperimental.cxx +++ b/Source/cmExperimental.cxx @@ -27,7 +27,7 @@ struct FeatureData bool Warned; } LookupTable[] = { // CxxModuleCMakeApi - { "3c375311-a3c9-4396-a187-3227ef642046", + { "9629ab6c-6c0e-423f-bb9d-cc5ac4a22041", "CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API", "CMake's C++ module support is experimental. It is meant only for " "experimentation and feedback to CMake developers.", diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 1594457..6f6109e 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -115,6 +115,8 @@ public: cmIDEFlagTable const* ExtraFlagTable; + virtual bool SupportsCxxModuleDyndep() const { return false; } + protected: cmGlobalVisualStudio7Generator(cmake* cm, std::string const& platformInGeneratorName); @@ -158,8 +160,6 @@ protected: cmValue typeGuid, const std::set<BT<std::pair<std::string, bool>>>& dependencies) = 0; - virtual bool SupportsCxxModuleDyndep() const { return false; } - std::string ConvertToSolutionPath(const std::string& path); std::set<std::string> IsPartOfDefaultBuild( diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index 2e573ec..4c69aeb 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -46,6 +46,16 @@ public: const char* GetAndroidApplicationTypeRevision() const override; + bool CheckCxxModuleSupport() override + { + this->CxxModuleSupportCheck(); + return this->SupportsCxxModuleDyndep(); + } + bool SupportsCxxModuleDyndep() const override + { + return this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS17; + } + protected: cmGlobalVisualStudioVersionedGenerator( VSVersion version, cmake* cm, const std::string& name, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index e06dc9b..ef4bcf8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -356,7 +356,8 @@ void cmVisualStudio10TargetGenerator::Generate() this->GeneratorTarget->CheckCxxModuleStatus(config); } - if (this->GeneratorTarget->HaveCxx20ModuleSources()) { + if (this->GeneratorTarget->HaveCxx20ModuleSources() && + !this->GlobalGenerator->SupportsCxxModuleDyndep()) { this->Makefile->IssueMessage( MessageType::FATAL_ERROR, cmStrCat("The \"", this->GeneratorTarget->GetName(), @@ -2710,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); @@ -2722,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 @@ -2744,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(); @@ -2770,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"); |
