VS: Refactor flag table lookup

In cmVisualStudio10TargetGenerator, convert the static functions
currently used to lookup the flag table for each tool into class
methods.  This avoids passing the this->LocalGenerator member and
gives the methods access to other information that may be useful
in the future.
This commit is contained in:
Brad King 2014-06-03 13:34:21 -04:00
parent 9e8fa1043c
commit ee329d543c
2 changed files with 24 additions and 16 deletions

View File

@ -32,34 +32,37 @@
#include <cmsys/auto_ptr.hxx>
static cmVS7FlagTable const*
cmVSGetCLFlagTable(cmLocalVisualStudioGenerator* lg)
cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const
{
if(lg->GetVersion() >= cmLocalVisualStudioGenerator::VS12)
cmLocalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS12)
{ return cmVS12CLFlagTable; }
else if(lg->GetVersion() == cmLocalVisualStudioGenerator::VS11)
else if(v == cmLocalVisualStudioGenerator::VS11)
{ return cmVS11CLFlagTable; }
else
{ return cmVS10CLFlagTable; }
}
static cmVS7FlagTable const*
cmVSGetLibFlagTable(cmLocalVisualStudioGenerator* lg)
cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const
{
if(lg->GetVersion() >= cmLocalVisualStudioGenerator::VS12)
cmLocalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS12)
{ return cmVS12LibFlagTable; }
else if(lg->GetVersion() == cmLocalVisualStudioGenerator::VS11)
else if(v == cmLocalVisualStudioGenerator::VS11)
{ return cmVS11LibFlagTable; }
else
{ return cmVS10LibFlagTable; }
}
static cmVS7FlagTable const*
cmVSGetLinkFlagTable(cmLocalVisualStudioGenerator* lg)
cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const
{
if(lg->GetVersion() >= cmLocalVisualStudioGenerator::VS12)
cmLocalVisualStudioGenerator::VSVersion
v = this->LocalGenerator->GetVersion();
if(v >= cmLocalVisualStudioGenerator::VS12)
{ return cmVS12LinkFlagTable; }
else if(lg->GetVersion() == cmLocalVisualStudioGenerator::VS11)
else if(v == cmLocalVisualStudioGenerator::VS11)
{ return cmVS11LinkFlagTable; }
else
{ return cmVS10LinkFlagTable; }
@ -1198,7 +1201,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmVisualStudioGeneratorOptions
clOptions(this->LocalGenerator,
cmVisualStudioGeneratorOptions::Compiler,
cmVSGetCLFlagTable(this->LocalGenerator), 0, this);
this->GetClFlagTable(), 0, this);
clOptions.Parse(flags.c_str());
clOptions.AddDefines(configDefines.c_str());
clOptions.SetConfiguration((*config).c_str());
@ -1355,7 +1358,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
cmsys::auto_ptr<Options> pOptions(
new Options(this->LocalGenerator, Options::Compiler,
cmVSGetCLFlagTable(this->LocalGenerator)));
this->GetClFlagTable()));
Options& clOptions = *pOptions;
std::string flags;
@ -1508,7 +1511,7 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
cmVisualStudioGeneratorOptions
libOptions(this->LocalGenerator,
cmVisualStudioGeneratorOptions::Linker,
cmVSGetLibFlagTable(this->LocalGenerator), 0, this);
this->GetLibFlagTable(), 0, this);
libOptions.Parse(libflags.c_str());
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
@ -1543,7 +1546,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
{
cmsys::auto_ptr<Options> pOptions(
new Options(this->LocalGenerator, Options::Linker,
cmVSGetLinkFlagTable(this->LocalGenerator), 0, this));
this->GetLinkFlagTable(), 0, this));
Options& linkOptions = *pOptions;
const std::string& linkLanguage =

View File

@ -23,6 +23,7 @@ class cmCustomCommand;
class cmLocalVisualStudio7Generator;
class cmComputeLinkInformation;
class cmVisualStudioGeneratorOptions;
struct cmIDEFlagTable;
#include "cmSourceGroup.h"
class cmVisualStudio10TargetGenerator
@ -98,6 +99,10 @@ private:
const std::vector<cmSourceGroup>& allGroups);
bool IsResxHeader(const std::string& headerFile);
cmIDEFlagTable const* GetClFlagTable() const;
cmIDEFlagTable const* GetLibFlagTable() const;
cmIDEFlagTable const* GetLinkFlagTable() const;
private:
typedef cmVisualStudioGeneratorOptions Options;
typedef std::map<std::string, Options*> OptionsMap;