diff options
author | Brad King <brad.king@kitware.com> | 2022-11-10 15:02:38 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-11-10 15:02:57 (GMT) |
commit | 6f4cffa5b712b5b296316bcae1b503d13f85d262 (patch) | |
tree | 28fdd11b517efaa5ba463215dc9f4586488c0d7b /Source | |
parent | 3d2400929f0f81d3091b4e74e7b58f0c652922e9 (diff) | |
parent | 3166547cf6d62217d3142a18e3aae3fc84e49b24 (diff) | |
download | CMake-6f4cffa5b712b5b296316bcae1b503d13f85d262.zip CMake-6f4cffa5b712b5b296316bcae1b503d13f85d262.tar.gz CMake-6f4cffa5b712b5b296316bcae1b503d13f85d262.tar.bz2 |
Merge topic 'marmasm-language'
3166547cf6 ASM_MARMASM: Add support for Microsoft ARM assembler language
ce4babb566 Tests: Fix ARM64 test conditions for non-VS generators
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7793
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 8 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio11Generator.cxx | 12 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio11Generator.h | 3 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.h | 2 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 33 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 73 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmVisualStudioGeneratorOptions.h | 1 |
11 files changed, 141 insertions, 1 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a539d33..a9485b5 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -827,7 +827,8 @@ void cmGlobalGenerator::EnableLanguage( "No " << compilerName << " could be found.\n" ; /* clang-format on */ - } else if ((lang != "RC") && (lang != "ASM_MASM")) { + } else if ((lang != "RC") && (lang != "ASM_MARMASM") && + (lang != "ASM_MASM")) { if (!cmSystemTools::FileIsFullPath(*compilerFile)) { /* clang-format off */ noCompiler << diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index bea2ae7..d6d808d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -56,6 +56,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( { this->DefaultCudaFlagTableName = "v10"; this->DefaultCudaHostFlagTableName = "v10"; + this->DefaultMarmasmFlagTableName = "v10"; this->DefaultNasmFlagTableName = "v10"; } @@ -1466,6 +1467,13 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() "CudaHost"); } +cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMarmasmFlagTable() + const +{ + return LoadFlagTable(std::string(), this->DefaultMarmasmFlagTableName, + "MARMASM"); +} + cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { return LoadFlagTable(this->GetMasmFlagTableName(), diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index b32c0a7..b3d9552 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -163,6 +163,7 @@ public: cmIDEFlagTable const* GetLinkFlagTable() const; cmIDEFlagTable const* GetCudaFlagTable() const; cmIDEFlagTable const* GetCudaHostFlagTable() const; + cmIDEFlagTable const* GetMarmasmFlagTable() const; cmIDEFlagTable const* GetMasmFlagTable() const; cmIDEFlagTable const* GetNasmFlagTable() const; @@ -226,6 +227,7 @@ protected: std::string DefaultLinkFlagTableName; std::string DefaultCudaFlagTableName; std::string DefaultCudaHostFlagTableName; + std::string DefaultMarmasmFlagTableName; std::string DefaultMasmFlagTableName; std::string DefaultNasmFlagTableName; std::string DefaultRCFlagTableName; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 086d3af..c53ddf5 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -161,6 +161,18 @@ bool cmGlobalVisualStudio11Generator::MatchesGeneratorName( return false; } +void cmGlobalVisualStudio11Generator::EnableLanguage( + std::vector<std::string> const& lang, cmMakefile* mf, bool optional) +{ + for (std::string const& it : lang) { + if (it == "ASM_MARMASM") { + this->MarmasmEnabled = true; + } + } + this->AddPlatformDefinitions(mf); + cmGlobalVisualStudio10Generator::EnableLanguage(lang, mf, optional); +} + bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf) { if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) { diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 2f8a7f6..fd25984 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -25,6 +25,9 @@ public: bool MatchesGeneratorName(const std::string& name) const override; + void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, + bool optional) override; + bool SupportsCustomCommandDepfile() const override { return true; } cm::optional<cmDepfileFormat> DepfileFormat() const override diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index ff76762..7431176 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -70,6 +70,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName) { this->DevEnvCommandInitialized = false; + this->MarmasmEnabled = false; this->MasmEnabled = false; this->NasmEnabled = false; this->ExtraFlagTable = cmVS7ExtraFlagTable; diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 288069c..e901ecd 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -106,6 +106,7 @@ public: bool FindMakeProgram(cmMakefile* mf) override; /** Is the Microsoft Assembler enabled? */ + bool IsMarmasmEnabled() const { return this->MarmasmEnabled; } bool IsMasmEnabled() const { return this->MasmEnabled; } bool IsNasmEnabled() const { return this->NasmEnabled; } @@ -176,6 +177,7 @@ protected: // Set during OutputSLNFile with the name of the current project. // There is one SLN file per project. std::string CurrentProject; + bool MarmasmEnabled; bool MasmEnabled; bool NasmEnabled; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index af2d31d..383045d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -842,6 +842,24 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( } } fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool + if (gg->IsMarmasmEnabled() && !this->FortranProject) { + Options marmasmOptions(this, Options::MarmasmCompiler, 0, 0); + /* clang-format off */ + fout << + "\t\t\t<Tool\n" + "\t\t\t\tName=\"MARMASM\"\n" + ; + /* clang-format on */ + targetOptions.OutputAdditionalIncludeDirectories(fout, 4, "ASM_MARMASM"); + // Use same preprocessor definitions as VCCLCompilerTool. + targetOptions.OutputPreprocessorDefinitions(fout, 4, "ASM_MARMASM"); + marmasmOptions.OutputFlagMap(fout, 4); + /* clang-format off */ + fout << + "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n" + "\t\t\t/>\n"; + /* clang-format on */ + } if (gg->IsMasmEnabled() && !this->FortranProject) { Options masmOptions(this, Options::MasmCompiler, 0, 0); /* clang-format off */ @@ -1720,6 +1738,10 @@ bool cmLocalVisualStudio7Generator::WriteGroup( aCompilerTool = "VFCustomBuildTool"; } } + if (gg->IsMarmasmEnabled() && !this->FortranProject && + lang == "ASM_MARMASM") { + aCompilerTool = "MARMASM"; + } if (gg->IsMasmEnabled() && !this->FortranProject && lang == "ASM_MASM") { aCompilerTool = "MASM"; @@ -2050,6 +2072,17 @@ void cmLocalVisualStudio7Generator::WriteProjectStart( << "\t\t<Platform\n\t\t\tName=\"" << gg->GetPlatformName() << "\"/>\n" << "\t</Platforms>\n"; /* clang-format on */ + if (gg->IsMarmasmEnabled()) { + /* clang-format off */ + fout << + "\t<ToolFiles>\n" + "\t\t<DefaultToolFile\n" + "\t\t\tFileName=\"marmasm.rules\"\n" + "\t\t/>\n" + "\t</ToolFiles>\n" + ; + /* clang-format on */ + } if (gg->IsMasmEnabled()) { /* clang-format off */ fout << diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index c982713..9393389 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -406,6 +406,9 @@ void cmVisualStudio10TargetGenerator::Generate() if (!this->ComputeCudaLinkOptions()) { return; } + if (!this->ComputeMarmasmOptions()) { + return; + } if (!this->ComputeMasmOptions()) { return; } @@ -732,6 +735,11 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( 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", @@ -830,6 +838,11 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( 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", @@ -2485,6 +2498,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"; @@ -2740,6 +2756,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( 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(); @@ -3751,6 +3770,59 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions( cudaLinkOptions.OutputFlagMap(); } +bool cmVisualStudio10TargetGenerator::ComputeMarmasmOptions() +{ + if (!this->GlobalGenerator->IsMarmasmEnabled()) { + return true; + } + for (std::string const& c : this->Configurations) { + if (!this->ComputeMarmasmOptions(c)) { + return false; + } + } + return true; +} + +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); + + 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()) { @@ -4451,6 +4523,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); } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 17dcecd..60e9736 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -132,6 +132,9 @@ private: bool ComputeCudaLinkOptions(std::string const& config); void WriteCudaLinkOptions(Elem& e1, std::string const& config); + bool ComputeMarmasmOptions(); + bool ComputeMarmasmOptions(std::string const& config); + void WriteMarmasmOptions(Elem& e1, std::string const& config); bool ComputeMasmOptions(); bool ComputeMasmOptions(std::string const& config); void WriteMasmOptions(Elem& e1, std::string const& config); @@ -208,6 +211,7 @@ private: OptionsMap RcOptions; OptionsMap CudaOptions; OptionsMap CudaLinkOptions; + OptionsMap MarmasmOptions; OptionsMap MasmOptions; OptionsMap NasmOptions; OptionsMap LinkOptions; diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index ed4ee1d..20e2d22 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -24,6 +24,7 @@ public: Compiler, ResourceCompiler, CudaCompiler, + MarmasmCompiler, MasmCompiler, NasmCompiler, Linker, |