VS: Populate MASM tool build settings in .vcxproj files

This commit is contained in:
Brad King 2014-08-13 11:20:20 -04:00
parent 0271a5f9ba
commit e872744990
3 changed files with 99 additions and 0 deletions

View File

@ -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 <cmsys/auto_ptr.hxx>
@ -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, "&", "&amp;");
@ -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("</ResourceCompile>\n", 2);
}
//----------------------------------------------------------------------------
bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
{
if(!this->GlobalGenerator->IsMasmEnabled())
{
return true;
}
std::vector<std::string> const* configs =
this->GlobalGenerator->GetConfigurations();
for(std::vector<std::string>::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<Options> 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<std::string> const& includes)
{
if(!this->MSTools || !this->GlobalGenerator->IsMasmEnabled())
{
return;
}
this->WriteString("<MASM>\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("</MASM>\n", 2);
}
void
cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
@ -1990,6 +2081,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
this->WriteClOptions(*i, includes);
// output rc compile flags <ResourceCompile></ResourceCompile>
this->WriteRCOptions(*i, includes);
this->WriteMasmOptions(*i, includes);
}
// output midl flags <Midl></Midl>
this->WriteMidlOptions(*i, includes);

View File

@ -78,6 +78,10 @@ private:
bool ComputeRcOptions(std::string const& config);
void WriteRCOptions(std::string const& config,
std::vector<std::string> const & includes);
bool ComputeMasmOptions();
bool ComputeMasmOptions(std::string const& config);
void WriteMasmOptions(std::string const& config,
std::vector<std::string> 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<std::string, Options*> OptionsMap;
OptionsMap ClOptions;
OptionsMap RcOptions;
OptionsMap MasmOptions;
OptionsMap LinkOptions;
std::string PathToVcxproj;
cmTarget* Target;

View File

@ -28,6 +28,7 @@ public:
{
Compiler,
ResourceCompiler,
MasmCompiler,
Linker,
FortranCompiler
};