cmGlobalGenerator: Call SetGeneratorToolset even for empty toolset

Move handling of an empty toolset name into the implementation of the
method.  This simplifies the VS 10 implementation of default toolset
selection because it has one code path that is always called.
This commit is contained in:
Brad King 2014-09-05 13:40:31 -04:00
parent ff1fddb0bf
commit 03b7b6cda1
4 changed files with 26 additions and 26 deletions

View File

@ -78,6 +78,12 @@ cmGlobalGenerator::~cmGlobalGenerator()
bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts, bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
cmMakefile* mf) cmMakefile* mf)
{
if(ts.empty())
{
return true;
}
else
{ {
cmOStringStream e; cmOStringStream e;
e << e <<
@ -89,6 +95,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
mf->IssueMessage(cmake::FATAL_ERROR, e.str()); mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false; return false;
} }
}
std::string cmGlobalGenerator::SelectMakeProgram( std::string cmGlobalGenerator::SelectMakeProgram(
const std::string& inMakeProgram, const std::string& inMakeProgram,
@ -454,8 +461,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// Tell the generator about the toolset, if any. // Tell the generator about the toolset, if any.
std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET"); std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET");
if(!toolset.empty() && if(!this->SetGeneratorToolset(toolset, mf))
!this->SetGeneratorToolset(toolset, mf))
{ {
cmSystemTools::SetFatalErrorOccured(); cmSystemTools::SetFatalErrorOccured();
return; return;

View File

@ -121,7 +121,10 @@ cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts,
cmMakefile* mf) cmMakefile* mf)
{ {
this->GeneratorToolset = ts; this->GeneratorToolset = ts;
this->AddVSPlatformToolsetDefinition(mf); if(const char* toolset = this->GetPlatformToolset())
{
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset);
}
return true; return true;
} }
@ -142,7 +145,6 @@ bool cmGlobalVisualStudio10Generator::SetSystemName(std::string const& s,
return false; return false;
} }
} }
this->AddVSPlatformToolsetDefinition(mf);
return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf); return this->cmGlobalVisualStudio8Generator::SetSystemName(s, mf);
} }
@ -186,16 +188,6 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
return false; return false;
} }
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator
::AddVSPlatformToolsetDefinition(cmMakefile* mf) const
{
if(const char* toolset = this->GetPlatformToolset())
{
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
{ {

View File

@ -140,6 +140,5 @@ private:
virtual std::string FindMSBuildCommand(); virtual std::string FindMSBuildCommand();
virtual std::string FindDevEnvCommand(); virtual std::string FindDevEnvCommand();
virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); } virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); }
void AddVSPlatformToolsetDefinition(cmMakefile* mf) const;
}; };
#endif #endif

View File

@ -208,8 +208,11 @@ bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
if(this->XcodeVersion >= 30) if(this->XcodeVersion >= 30)
{ {
this->GeneratorToolset = ts; this->GeneratorToolset = ts;
if(!this->GeneratorToolset.empty())
{
mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
this->GeneratorToolset.c_str()); this->GeneratorToolset.c_str());
}
return true; return true;
} }
else else