diff options
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 325 |
1 files changed, 220 insertions, 105 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8882c45..ef0fcf3 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -80,10 +80,10 @@ struct cmVisualStudio10TargetGenerator::Elem bool HasContent = false; std::string Tag; - Elem(std::ostream& s, const std::string& tag) + Elem(std::ostream& s, std::string tag) : S(s) , Indent(0) - , Tag(tag) + , Tag(std::move(tag)) { this->StartElement(); } @@ -200,7 +200,7 @@ struct cmVisualStudio10TargetGenerator::OptionsHelper } }; -static std::string cmVS10EscapeComment(std::string comment) +static std::string cmVS10EscapeComment(std::string const& comment) { // MSBuild takes the CDATA of a <Message></Message> element and just // does "echo $CDATA" with no escapes. We must encode the string. @@ -275,8 +275,8 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); this->NsightTegra = gg->IsNsightTegra(); this->Android = gg->TargetsAndroid(); - for (int i = 0; i < 4; ++i) { - this->NsightTegraVersion[i] = 0; + for (unsigned int& version : this->NsightTegraVersion) { + version = 0; } sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u", &this->NsightTegraVersion[0], &this->NsightTegraVersion[1], @@ -293,9 +293,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->ClassifyAllConfigSources(); } -cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() -{ -} +cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() = default; std::string cmVisualStudio10TargetGenerator::CalcCondition( const std::string& config) const @@ -358,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(), @@ -406,6 +405,9 @@ void cmVisualStudio10TargetGenerator::Generate() if (!this->ComputeCudaLinkOptions()) { return; } + if (!this->ComputeMarmasmOptions()) { + return; + } if (!this->ComputeMasmOptions()) { return; } @@ -423,7 +425,7 @@ void cmVisualStudio10TargetGenerator::Generate() cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->Name, ProjectFileExtension); cmGeneratedFileStream BuildFileStream(path); - const std::string PathToProjectFile = path; + const std::string& PathToProjectFile = path; BuildFileStream.SetCopyIfDifferent(true); // Write the encoding header into the file @@ -453,7 +455,7 @@ void cmVisualStudio10TargetGenerator::Generate() void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( cmGeneratedFileStream& BuildFileStream) { - BuildFileStream << "<?xml version=\"1.0\" encoding=\"" + BuildFileStream << R"(<?xml version="1.0" encoding=")" << this->GlobalGenerator->Encoding() << "\"?>"; { Elem e0(BuildFileStream, "Project"); @@ -548,7 +550,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( e1.Element("Platform", this->Platform); cmValue projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL"); - e1.Element("ProjectName", projLabel ? projLabel : this->Name); + e1.Element("ProjectName", projLabel ? *projLabel : this->Name); { cm::optional<std::string> targetFramework; cm::optional<std::string> targetFrameworkVersion; @@ -691,12 +693,12 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( switch (this->ProjectType) { case VsProjectType::vcxproj: { + Elem(e0, "Import").Attribute("Project", VS10_CXX_DEFAULT_PROPS); std::string const& props = this->GlobalGenerator->GetPlatformToolsetVersionProps(); if (!props.empty()) { Elem(e0, "Import").Attribute("Project", props); } - Elem(e0, "Import").Attribute("Project", VS10_CXX_DEFAULT_PROPS); } break; case VsProjectType::csproj: Elem(e0, "Import") @@ -725,13 +727,18 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( : customDir + this->GlobalGenerator ->GetPlatformToolsetCudaVSIntegrationSubdirString() + - "extras\\visual_studio_integration\\MSBuildExtensions\\"; + R"(extras\visual_studio_integration\MSBuildExtensions\)"; Elem(e1, "Import") .Attribute("Project", std::move(cudaPath) + "CUDA " + this->GlobalGenerator->GetPlatformToolsetCuda() + ".props"); } + if (this->GlobalGenerator->IsMarmasmEnabled()) { + Elem(e1, "Import") + .Attribute("Project", + "$(VCTargetsPath)\\BuildCustomizations\\marmasm.props"); + } if (this->GlobalGenerator->IsMasmEnabled()) { Elem(e1, "Import") .Attribute("Project", @@ -823,13 +830,18 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( : customDir + this->GlobalGenerator ->GetPlatformToolsetCudaVSIntegrationSubdirString() + - "extras\\visual_studio_integration\\MSBuildExtensions\\"; + R"(extras\visual_studio_integration\MSBuildExtensions\)"; Elem(e1, "Import") .Attribute("Project", std::move(cudaPath) + "CUDA " + this->GlobalGenerator->GetPlatformToolsetCuda() + ".targets"); } + if (this->GlobalGenerator->IsMarmasmEnabled()) { + Elem(e1, "Import") + .Attribute("Project", + "$(VCTargetsPath)\\BuildCustomizations\\marmasm.targets"); + } if (this->GlobalGenerator->IsMasmEnabled()) { Elem(e1, "Import") .Attribute("Project", @@ -943,7 +955,11 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile( "executables.")); return; } - outputType = "Exe"; + if (cmIsOn(win32)) { + outputType = "WinExe"; + } else { + outputType = "Exe"; + } } break; case cmStateEnums::UTILITY: case cmStateEnums::INTERFACE_LIBRARY: @@ -979,6 +995,8 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile( this->WriteDotNetDocumentationFile(e0); this->WriteAllSources(e0); + this->WriteEmbeddedResourceGroup(e0); + this->WriteXamlFilesGroup(e0); this->WriteDotNetReferences(e0); this->WritePackageReferences(e0); this->WriteProjectReferences(e0); @@ -1020,8 +1038,9 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1) std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys(); for (std::string const& keyIt : keys) { static const cm::string_view prefix = "VS_GLOBAL_"; - if (!cmHasPrefix(keyIt, prefix)) + if (!cmHasPrefix(keyIt, prefix)) { continue; + } cm::string_view globalKey = cm::string_view(keyIt).substr(prefix.length()); // Skip invalid or separately-handled properties. if (globalKey.empty() || globalKey == "PROJECT_TYPES" || @@ -1029,8 +1048,9 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1) continue; } cmValue value = this->GeneratorTarget->GetProperty(keyIt); - if (!value) + if (!value) { continue; + } e1.Element(globalKey, *value); } } @@ -1043,14 +1063,11 @@ bool cmVisualStudio10TargetGenerator::HasCustomCommands() const return true; } - for (cmGeneratorTarget::AllConfigSource const& si : - this->GeneratorTarget->GetAllConfigSources()) { - if (si.Source->GetCustomCommand()) { - return true; - } - } - - return false; + auto const& config_sources = this->GeneratorTarget->GetAllConfigSources(); + return std::any_of(config_sources.begin(), config_sources.end(), + [](cmGeneratorTarget::AllConfigSource const& si) { + return si.Source->GetCustomCommand(); + }); } void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0) @@ -1220,7 +1237,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) e2.Attribute("Include", obj); if (this->ProjectType != VsProjectType::csproj) { - std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h"; + std::string hFileName = obj.substr(0, obj.find_last_of('.')) + ".h"; e2.Element("DependentUpon", hFileName); for (std::string const& c : this->Configurations) { @@ -1793,8 +1810,15 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(), outputs.str(), comment, ccg); } else { + BuildInParallel buildInParallel = BuildInParallel::No; + if (command.GetCMP0147Status() == cmPolicies::NEW && + !command.GetUsesTerminal() && + !(command.HasMainDependency() && source->GetIsGenerated())) { + buildInParallel = BuildInParallel::Yes; + } this->WriteCustomRuleCpp(*spe2, c, script, additional_inputs.str(), - outputs.str(), comment, ccg, symbolic); + outputs.str(), comment, ccg, symbolic, + buildInParallel); } } } @@ -1803,9 +1827,13 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp( Elem& e2, std::string const& config, std::string const& script, std::string const& additional_inputs, std::string const& outputs, std::string const& comment, cmCustomCommandGenerator const& ccg, - bool symbolic) + bool symbolic, BuildInParallel buildInParallel) { const std::string cond = this->CalcCondition(config); + if (buildInParallel == BuildInParallel::Yes && + this->GlobalGenerator->IsBuildInParallelSupported()) { + e2.WritePlatformConfigTag("BuildInParallel", cond, "true"); + } e2.WritePlatformConfigTag("Message", cond, comment); e2.WritePlatformConfigTag("Command", cond, script); e2.WritePlatformConfigTag("AdditionalInputs", cond, additional_inputs); @@ -1912,7 +1940,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() char magic[] = { char(0xEF), char(0xBB), char(0xBF) }; fout.write(magic, 3); - fout << "<?xml version=\"1.0\" encoding=\"" + fout << R"(<?xml version="1.0" encoding=")" << this->GlobalGenerator->Encoding() << "\"?>"; { Elem e0(fout, "Project"); @@ -2068,7 +2096,7 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource( e2.Element("FileType", "CppForm"); } else if (this->IsXamlHeader(fileName)) { e2.Element("DependentUpon", - fileName.substr(0, fileName.find_last_of("."))); + fileName.substr(0, fileName.find_last_of('.'))); } this->FinishWritingSource(e2, toolSettings); } @@ -2077,7 +2105,7 @@ void cmVisualStudio10TargetGenerator::ParseSettingsProperty( const std::string& settingsPropertyValue, ConfigToSettings& toolSettings) { if (!settingsPropertyValue.empty()) { - cmGeneratorExpression ge; + cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance()); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(settingsPropertyValue); @@ -2104,7 +2132,7 @@ void cmVisualStudio10TargetGenerator::ParseSettingsProperty( bool cmVisualStudio10TargetGenerator::PropertyIsSameInAllConfigs( const ConfigToSettings& toolSettings, const std::string& propName) { - std::string firstPropValue = ""; + std::string firstPropValue; for (const auto& configToSettings : toolSettings) { const std::unordered_map<std::string, std::string>& settings = configToSettings.second; @@ -2177,7 +2205,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( } // Figure out if there's any additional flags to use if (cmValue saf = sf->GetProperty("VS_SHADER_FLAGS")) { - cmGeneratorExpression ge; + cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance()); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*saf); for (const std::string& config : this->Configurations) { @@ -2190,7 +2218,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( } // Figure out if debug information should be generated if (cmValue sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) { - cmGeneratorExpression ge; + cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance()); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sed); for (const std::string& config : this->Configurations) { @@ -2204,7 +2232,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( } // Figure out if optimizations should be disabled if (cmValue sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) { - cmGeneratorExpression ge; + cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance()); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sdo); for (const std::string& config : this->Configurations) { @@ -2318,26 +2346,23 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource( this->FinishWritingSource(e2, toolSettings); if (!deployContent.empty()) { - cmGeneratorExpression ge; + cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance()); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(deployContent); // Deployment location cannot be set on a configuration basis if (!deployLocation.empty()) { e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)"); } - for (size_t i = 0; i != this->Configurations.size(); ++i) { - if (cge->Evaluate(this->LocalGenerator, this->Configurations[i]) == - "1") { + for (auto& config : this->Configurations) { + if (cge->Evaluate(this->LocalGenerator, config) == "1") { e2.WritePlatformConfigTag("DeploymentContent", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + - this->Platform + "'", + config + "|" + this->Platform + "'", "true"); } else { e2.WritePlatformConfigTag("ExcludedFromBuild", "'$(Configuration)|$(Platform)'=='" + - this->Configurations[i] + "|" + - this->Platform + "'", + config + "|" + this->Platform + "'", "true"); } } @@ -2388,8 +2413,9 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, // added with the plain filename without any path. This means the file will // show up at root-level of the csproj (where CMakeLists.txt etc. are). std::string link = this->GetCSharpSourceLink(sf); - if (link.empty()) + if (link.empty()) { link = cmsys::SystemTools::GetFilenameName(sf->GetFullPath()); + } e2.Element("Link", link); } @@ -2485,6 +2511,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) const std::string& lang = si.Source->GetLanguage(); if (lang == "C" || lang == "CXX") { tool = "ClCompile"; + } else if (lang == "ASM_MARMASM" && + this->GlobalGenerator->IsMarmasmEnabled()) { + tool = "MARMASM"; } else if (lang == "ASM_MASM" && this->GlobalGenerator->IsMasmEnabled()) { tool = "MASM"; @@ -2519,7 +2548,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) Elem e2(e1, tool); bool isCSharp = (si.Source->GetLanguage() == "CSharp"); - if (isCSharp && exclude_configs.size() > 0) { + if (isCSharp && !exclude_configs.empty()) { std::stringstream conditions; bool firstConditionSet{ false }; for (const auto& ci : include_configs) { @@ -2661,7 +2690,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( ? "C" : this->GlobalGenerator->GetLanguageFromExtension(ext.c_str()); std::string lang = this->LocalGenerator->GetSourceFileLanguage(sf); - const char* compileAs = 0; + const char* compileAs = nullptr; if (lang != extLang) { if (lang == "CXX") { // force a C++ file type @@ -2699,6 +2728,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); @@ -2711,6 +2742,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 @@ -2733,13 +2789,16 @@ 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(); if (srclang == "C" || srclang == "CXX") { flagtable = gg->GetClFlagTable(); + } else if (srclang == "ASM_MARMASM" && + this->GlobalGenerator->IsMarmasmEnabled()) { + flagtable = gg->GetMarmasmFlagTable(); } else if (srclang == "ASM_MASM" && this->GlobalGenerator->IsMasmEnabled()) { flagtable = gg->GetMasmFlagTable(); @@ -2756,8 +2815,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"); @@ -2842,10 +2906,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( if (this->IsXamlSource(source->GetFullPath())) { const std::string& fileName = source->GetFullPath(); e2.Element("DependentUpon", - fileName.substr(0, fileName.find_last_of("."))); + fileName.substr(0, fileName.find_last_of('.'))); } if (this->ProjectType == VsProjectType::csproj) { - std::string f = source->GetFullPath(); using CsPropMap = std::map<std::string, std::string>; CsPropMap sourceFileTags; this->GetCSharpSourceProperties(&sf, sourceFileTags); @@ -2886,7 +2949,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( if (ttype >= cmStateEnums::UTILITY) { e1.WritePlatformConfigTag( - "IntDir", cond, "$(Platform)\\$(Configuration)\\$(ProjectName)\\"); + "IntDir", cond, R"($(Platform)\$(Configuration)\$(ProjectName)\)"); } else { std::string intermediateDir = cmStrCat( this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/', @@ -3051,14 +3114,22 @@ std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes( return includes; } -bool cmVisualStudio10TargetGenerator::ComputeClOptions() +std::string cmVisualStudio10TargetGenerator::GetTargetOutputName() const { - for (std::string const& c : this->Configurations) { - if (!this->ComputeClOptions(c)) { - return false; - } + std::string config; + if (!this->Configurations.empty()) { + config = this->Configurations[0]; } - return true; + const auto& nameComponents = + this->GeneratorTarget->GetFullNameComponents(config); + return nameComponents.prefix + nameComponents.base; +} + +bool cmVisualStudio10TargetGenerator::ComputeClOptions() +{ + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeClOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeClOptions( @@ -3274,6 +3345,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( this->GeneratorTarget->GetLanguages(languages, configName); if (languages.count("C")) { std::string flagsC; + this->LocalGenerator->AddLanguageFlags( + flagsC, this->GeneratorTarget, cmBuildStep::Compile, "C", configName); this->LocalGenerator->AddCompileOptions(flagsC, this->GeneratorTarget, "C", configName); Options optC(this->LocalGenerator, Options::Compiler, @@ -3316,9 +3389,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } } - if (this->ProjectType != VsProjectType::csproj && clOptions.IsManaged()) { + if (this->ProjectType != VsProjectType::csproj && + (clOptions.IsManaged() || clOptions.HasFlag("CLRSupport"))) { this->Managed = true; - std::string managedType = clOptions.GetFlag("CompileAsManaged"); + std::string managedType = clOptions.HasFlag("CompileAsManaged") + ? clOptions.GetFlag("CompileAsManaged") + : "Mixed"; if (managedType == "Safe" || managedType == "Pure") { // force empty calling convention if safe clr is used clOptions.AddFlag("CallingConvention", ""); @@ -3411,7 +3487,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( // add AdditionalUsingDirectories if (this->AdditionalUsingDirectories.count(configName) > 0) { std::string dirs; - for (auto u : this->AdditionalUsingDirectories[configName]) { + for (auto const& u : this->AdditionalUsingDirectories[configName]) { if (!dirs.empty()) { dirs.append(";"); } @@ -3424,12 +3500,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( bool cmVisualStudio10TargetGenerator::ComputeRcOptions() { - for (std::string const& c : this->Configurations) { - if (!this->ComputeRcOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeRcOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeRcOptions( @@ -3478,13 +3551,12 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions() if (!this->GlobalGenerator->IsCudaEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (this->GeneratorTarget->IsLanguageUsed("CUDA", c) && - !this->ComputeCudaOptions(c)) { - return false; - } - } - return true; + return std::all_of(this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { + return !this->GeneratorTarget->IsLanguageUsed("CUDA", + c) || + this->ComputeCudaOptions(c); + }); } bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( @@ -3570,7 +3642,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions( // limitation by creating the directory and passing the flag ourselves. pdb = this->ConvertPath(pdb, true); ConvertToWindowsSlash(pdb); - std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\""; + std::string const clFd = R"(-Xcompiler="-Fd\")" + pdb + R"(\"")"; cudaOptions.AppendFlagString("AdditionalOptions", clFd); } } @@ -3654,12 +3726,9 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions() if (!this->GlobalGenerator->IsCudaEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (!this->ComputeCudaLinkOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeCudaLinkOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions( @@ -3748,17 +3817,66 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions( cudaLinkOptions.OutputFlagMap(); } +bool cmVisualStudio10TargetGenerator::ComputeMarmasmOptions() +{ + if (!this->GlobalGenerator->IsMarmasmEnabled()) { + return true; + } + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeMarmasmOptions(c); }); +} + +bool cmVisualStudio10TargetGenerator::ComputeMarmasmOptions( + std::string const& configName) +{ + cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; + auto pOptions = cm::make_unique<Options>( + this->LocalGenerator, Options::MarmasmCompiler, gg->GetMarmasmFlagTable()); + Options& marmasmOptions = *pOptions; + + std::string flags; + this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, + cmBuildStep::Compile, "ASM_MARMASM", + configName); + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, + "ASM_MARMASM", configName); + + marmasmOptions.Parse(flags); + + // Get includes for this target + marmasmOptions.AddIncludes(this->GetIncludes(configName, "ASM_MARMASM")); + + this->MarmasmOptions[configName] = std::move(pOptions); + return true; +} + +void cmVisualStudio10TargetGenerator::WriteMarmasmOptions( + Elem& e1, std::string const& configName) +{ + if (!this->MSTools || !this->GlobalGenerator->IsMarmasmEnabled()) { + return; + } + Elem e2(e1, "MARMASM"); + + // Preprocessor definitions and includes are shared with clOptions. + OptionsHelper clOptions(*(this->ClOptions[configName]), e2); + clOptions.OutputPreprocessorDefinitions("ASM_MARMASM"); + + OptionsHelper marmasmOptions(*(this->MarmasmOptions[configName]), e2); + marmasmOptions.OutputAdditionalIncludeDirectories("ASM_MARMASM"); + marmasmOptions.PrependInheritedString("AdditionalOptions"); + marmasmOptions.OutputFlagMap(); +} + bool cmVisualStudio10TargetGenerator::ComputeMasmOptions() { if (!this->GlobalGenerator->IsMasmEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (!this->ComputeMasmOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeMasmOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeMasmOptions( @@ -3777,6 +3895,8 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions( this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, cmBuildStep::Compile, "ASM_MASM", configName); + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, + "ASM_MASM", configName); masmOptions.Parse(flags); @@ -3810,12 +3930,9 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions() if (!this->GlobalGenerator->IsNasmEnabled()) { return true; } - for (std::string const& c : this->Configurations) { - if (!this->ComputeNasmOptions(c)) { - return false; - } - } - return true; + return std::all_of( + this->Configurations.begin(), this->Configurations.end(), + [this](std::string const& c) { return this->ComputeNasmOptions(c); }); } bool cmVisualStudio10TargetGenerator::ComputeNasmOptions( @@ -3830,6 +3947,8 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions( this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, cmBuildStep::Compile, "ASM_NASM", configName); + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, + "ASM_NASM", configName); flags += " -f"; flags += this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT"); nasmOptions.Parse(flags); @@ -4452,6 +4571,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups(Elem& e0) // output rc compile flags <ResourceCompile></ResourceCompile> this->WriteRCOptions(e1, c); this->WriteCudaOptions(e1, c); + this->WriteMarmasmOptions(e1, c); this->WriteMasmOptions(e1, c); this->WriteNasmOptions(e1, c); } @@ -4954,8 +5074,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1) this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = - cmVS10EscapeXML(this->GeneratorTarget->GetName()); + const std::string& targetNameXML = cmVS10EscapeXML(GetTargetOutputName()); cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); @@ -5037,8 +5156,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1) this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = - cmVS10EscapeXML(this->GeneratorTarget->GetName()); + const std::string& targetNameXML = cmVS10EscapeXML(GetTargetOutputName()); cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); @@ -5100,8 +5218,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1) this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = - cmVS10EscapeXML(this->GeneratorTarget->GetName()); + const std::string& targetNameXML = cmVS10EscapeXML(GetTargetOutputName()); cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); @@ -5155,8 +5272,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1) this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = - cmVS10EscapeXML(this->GeneratorTarget->GetName()); + const std::string& targetNameXML = cmVS10EscapeXML(GetTargetOutputName()); cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); @@ -5215,8 +5331,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0(Elem& e1) this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); ConvertToWindowsSlash(artifactDir); std::string artifactDirXML = cmVS10EscapeXML(artifactDir); - std::string targetNameXML = - cmVS10EscapeXML(this->GeneratorTarget->GetName()); + const std::string& targetNameXML = cmVS10EscapeXML(GetTargetOutputName()); cmGeneratedFileStream fout(manifestFile); fout.SetCopyIfDifferent(true); |