Commit 13e6d559 authored by Brad King's avatar Brad King
Browse files

VS: Set some options directly instead of using flag map

Instead of passing /TC, /TP, and /STACK: as strings to be parsed through
the flag map, directly set the results in the options map.
parent 8f4bdcc6
...@@ -1147,17 +1147,18 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( ...@@ -1147,17 +1147,18 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
} }
// if the source file does not match the linker language // if the source file does not match the linker language
// then force c or c++ // then force c or c++
const char* compileAs = 0;
if(needForceLang || (linkLanguage != lang)) if(needForceLang || (linkLanguage != lang))
{ {
if(lang == "CXX") if(lang == "CXX")
{ {
// force a C++ file type // force a C++ file type
flags += " /TP "; compileAs = "CompileAsCpp";
} }
else if(lang == "C") else if(lang == "C")
{ {
// force to c // force to c
flags += " /TC "; compileAs = "CompileAsC";
} }
} }
bool hasFlags = false; bool hasFlags = false;
...@@ -1193,7 +1194,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( ...@@ -1193,7 +1194,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
} }
// if we have flags or defines for this config then // if we have flags or defines for this config then
// use them // use them
if(flags.size() || configDefines.size()) if(!flags.empty() || !configDefines.empty() || compileAs)
{ {
(*this->BuildFileStream ) << firstString; (*this->BuildFileStream ) << firstString;
firstString = ""; // only do firstString once firstString = ""; // only do firstString once
...@@ -1202,6 +1203,10 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( ...@@ -1202,6 +1203,10 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
clOptions(this->LocalGenerator, clOptions(this->LocalGenerator,
cmVisualStudioGeneratorOptions::Compiler, cmVisualStudioGeneratorOptions::Compiler,
this->GetClFlagTable(), 0, this); this->GetClFlagTable(), 0, this);
if(compileAs)
{
clOptions.AddFlag("CompileAs", compileAs);
}
clOptions.Parse(flags.c_str()); clOptions.Parse(flags.c_str());
clOptions.AddDefines(configDefines.c_str()); clOptions.AddDefines(configDefines.c_str());
clOptions.SetConfiguration((*config).c_str()); clOptions.SetConfiguration((*config).c_str());
...@@ -1393,11 +1398,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( ...@@ -1393,11 +1398,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
// set the correct language // set the correct language
if(linkLanguage == "C") if(linkLanguage == "C")
{ {
flags += " /TC "; clOptions.AddFlag("CompileAs", "CompileAsC");
} }
if(linkLanguage == "CXX") if(linkLanguage == "CXX")
{ {
flags += " /TP "; clOptions.AddFlag("CompileAs", "CompileAsCpp");
} }
this->LocalGenerator->AddCompileOptions(flags, this->Target, this->LocalGenerator->AddCompileOptions(flags, this->Target,
linkLanguage, configName.c_str()); linkLanguage, configName.c_str());
...@@ -1571,16 +1576,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) ...@@ -1571,16 +1576,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
{ {
linkType = "EXE"; linkType = "EXE";
} }
std::string stackVar = "CMAKE_";
stackVar += linkLanguage;
stackVar += "_STACK_SIZE";
const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
std::string flags; std::string flags;
if(stackVal)
{
flags += " /STACK:";
flags += stackVal;
}
std::string linkFlagVarBase = "CMAKE_"; std::string linkFlagVarBase = "CMAKE_";
linkFlagVarBase += linkType; linkFlagVarBase += linkType;
linkFlagVarBase += "_LINKER_FLAGS"; linkFlagVarBase += "_LINKER_FLAGS";
...@@ -1666,6 +1662,13 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) ...@@ -1666,6 +1662,13 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str()); linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str());
linkOptions.AddFlag("AdditionalDependencies", libs.c_str()); linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
linkOptions.AddFlag("Version", ""); linkOptions.AddFlag("Version", "");
if(const char* stackVal =
this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE"))
{
linkOptions.AddFlag("StackReserveSize", stackVal);
}
if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos) if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos)
{ {
linkOptions.AddFlag("GenerateDebugInformation", "true"); linkOptions.AddFlag("GenerateDebugInformation", "true");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment