From e872744990f48777a1f1cebc791911363515092d Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Aug 2014 11:20:20 -0400 Subject: [PATCH] VS: Populate MASM tool build settings in .vcxproj files --- Source/cmVisualStudio10TargetGenerator.cxx | 92 ++++++++++++++++++++++ Source/cmVisualStudio10TargetGenerator.h | 6 ++ Source/cmVisualStudioGeneratorOptions.h | 1 + 3 files changed, 99 insertions(+) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9256b8955c..b9295e41eb 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -24,18 +24,22 @@ #include "cmVS10RCFlagTable.h" #include "cmVS10LinkFlagTable.h" #include "cmVS10LibFlagTable.h" +#include "cmVS10MASMFlagTable.h" #include "cmVS11CLFlagTable.h" #include "cmVS11RCFlagTable.h" #include "cmVS11LinkFlagTable.h" #include "cmVS11LibFlagTable.h" +#include "cmVS11MASMFlagTable.h" #include "cmVS12CLFlagTable.h" #include "cmVS12RCFlagTable.h" #include "cmVS12LinkFlagTable.h" #include "cmVS12LibFlagTable.h" +#include "cmVS12MASMFlagTable.h" #include "cmVS14CLFlagTable.h" #include "cmVS14RCFlagTable.h" #include "cmVS14LinkFlagTable.h" #include "cmVS14LibFlagTable.h" +#include "cmVS14MASMFlagTable.h" #include @@ -111,6 +115,24 @@ cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const return 0; } +cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetMasmFlagTable() const +{ + if(this->MSTools) + { + cmLocalVisualStudioGenerator::VSVersion + v = this->LocalGenerator->GetVersion(); + if(v >= cmLocalVisualStudioGenerator::VS14) + { return cmVS14MASMFlagTable; } + else if(v >= cmLocalVisualStudioGenerator::VS12) + { return cmVS12MASMFlagTable; } + else if(v == cmLocalVisualStudioGenerator::VS11) + { return cmVS11MASMFlagTable; } + else + { return cmVS10MASMFlagTable; } + } + return 0; +} + static std::string cmVS10EscapeXML(std::string arg) { cmSystemTools::ReplaceString(arg, "&", "&"); @@ -251,6 +273,10 @@ void cmVisualStudio10TargetGenerator::Generate() { return; } + if(!this->ComputeMasmOptions()) + { + return; + } if(!this->ComputeLinkOptions()) { return; @@ -1646,6 +1672,71 @@ WriteRCOptions(std::string const& configName, this->WriteString("\n", 2); } +//---------------------------------------------------------------------------- +bool cmVisualStudio10TargetGenerator::ComputeMasmOptions() +{ + if(!this->GlobalGenerator->IsMasmEnabled()) + { + return true; + } + std::vector const* configs = + this->GlobalGenerator->GetConfigurations(); + for(std::vector::const_iterator i = configs->begin(); + i != configs->end(); ++i) + { + if(!this->ComputeMasmOptions(*i)) + { + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmVisualStudio10TargetGenerator::ComputeMasmOptions( + std::string const& configName) +{ + cmsys::auto_ptr pOptions( + new Options(this->LocalGenerator, Options::MasmCompiler, + this->GetMasmFlagTable())); + Options& masmOptions = *pOptions; + + std::string CONFIG = cmSystemTools::UpperCase(configName); + std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG; + std::string flags = + std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS")) + + std::string(" ") + + std::string(this->Makefile->GetSafeDefinition(configFlagsVar)); + + masmOptions.Parse(flags.c_str()); + this->MasmOptions[configName] = pOptions.release(); + return true; +} + +void cmVisualStudio10TargetGenerator:: +WriteMasmOptions(std::string const& configName, + std::vector const& includes) +{ + if(!this->MSTools || !this->GlobalGenerator->IsMasmEnabled()) + { + return; + } + this->WriteString("\n", 2); + + // Preprocessor definitions and includes are shared with clOptions. + Options& clOptions = *(this->ClOptions[configName]); + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", + "\n", "ASM_MASM"); + + Options& masmOptions = *(this->MasmOptions[configName]); + masmOptions.AppendFlag("IncludePaths", includes); + masmOptions.AppendFlag("IncludePaths", "%(IncludePaths)"); + masmOptions.OutputFlagMap(*this->BuildFileStream, " "); + masmOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); + + this->WriteString("\n", 2); +} + void cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) @@ -1990,6 +2081,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WriteClOptions(*i, includes); // output rc compile flags this->WriteRCOptions(*i, includes); + this->WriteMasmOptions(*i, includes); } // output midl flags this->WriteMidlOptions(*i, includes); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 4e9bcd132b..93b72f43cb 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -78,6 +78,10 @@ private: bool ComputeRcOptions(std::string const& config); void WriteRCOptions(std::string const& config, std::vector const & includes); + bool ComputeMasmOptions(); + bool ComputeMasmOptions(std::string const& config); + void WriteMasmOptions(std::string const& config, + std::vector const& includes); bool ComputeLinkOptions(); bool ComputeLinkOptions(std::string const& config); void WriteLinkOptions(std::string const& config); @@ -109,12 +113,14 @@ private: cmIDEFlagTable const* GetRcFlagTable() const; cmIDEFlagTable const* GetLibFlagTable() const; cmIDEFlagTable const* GetLinkFlagTable() const; + cmIDEFlagTable const* GetMasmFlagTable() const; private: typedef cmVisualStudioGeneratorOptions Options; typedef std::map OptionsMap; OptionsMap ClOptions; OptionsMap RcOptions; + OptionsMap MasmOptions; OptionsMap LinkOptions; std::string PathToVcxproj; cmTarget* Target; diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 47a7c62c60..8de6017f1f 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -28,6 +28,7 @@ public: { Compiler, ResourceCompiler, + MasmCompiler, Linker, FortranCompiler };