From ee329d543c558a2064edc805b08f337bd31ab1fd Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 3 Jun 2014 13:34:21 -0400 Subject: [PATCH] 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. --- Source/cmVisualStudio10TargetGenerator.cxx | 35 ++++++++++++---------- Source/cmVisualStudio10TargetGenerator.h | 5 ++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 72bb02087..5dad67d6c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -32,34 +32,37 @@ #include -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 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 pOptions( new Options(this->LocalGenerator, Options::Linker, - cmVSGetLinkFlagTable(this->LocalGenerator), 0, this)); + this->GetLinkFlagTable(), 0, this)); Options& linkOptions = *pOptions; const std::string& linkLanguage = diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index d72c6fd6a..67a248875 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -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& 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 OptionsMap;