cmGlobalGenerator: Move some flags from cmLocalGenerator.

These flags are global, and so they belong here instead of being
set on each local generator.
This commit is contained in:
Stephen Kelly 2015-05-04 22:40:11 +02:00
parent ed41a8e7b4
commit b17686d2bb
16 changed files with 79 additions and 81 deletions

View File

@ -21,6 +21,7 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
this->WindowsShell = true;
}
@ -43,7 +44,6 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
cmLocalUnixMakefileGenerator3* lg =
new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetIncludeDirective("!include");
lg->SetWindowsShell(true);
lg->SetDefineWindowsNULL(true);
lg->SetMakefileVariableSize(32);
lg->SetPassMakeflags(true);

View File

@ -71,6 +71,13 @@ cmGlobalGenerator::cmGlobalGenerator()
this->ExtraGenerator = 0;
this->CurrentLocalGenerator = 0;
this->TryCompileOuterMakefile = 0;
this->WindowsShell = false;
this->WindowsVSIDE = false;
this->WatcomWMake = false;
this->MinGWMake = false;
this->NMake = false;
this->MSYSShell = false;
}
cmGlobalGenerator::~cmGlobalGenerator()

View File

@ -354,6 +354,13 @@ public:
cmFileLockPool& GetFileLockPool() { return FileLockPool; }
#endif
bool WindowsShell;
bool WindowsVSIDE;
bool WatcomWMake;
bool MinGWMake;
bool NMake;
bool MSYSShell;
protected:
virtual void Generate();

View File

@ -19,6 +19,8 @@ cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator()
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
this->WindowsShell = true;
this->NMake = true;
}
void cmGlobalJOMMakefileGenerator
@ -51,11 +53,9 @@ cmGlobalJOMMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
cmLocalUnixMakefileGenerator3* lg
= new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetDefineWindowsNULL(true);
lg->SetWindowsShell(true);
lg->SetMakeSilentFlag("/nologo");
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(true);
lg->SetNMake(true);
lg->SetUnixCD(false);
return lg;
}

View File

@ -21,6 +21,7 @@ cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator()
this->ForceUnixPaths = true;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
this->MSYSShell = true;
}
std::string
@ -98,8 +99,6 @@ cmGlobalMSYSMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
{
cmLocalUnixMakefileGenerator3* lg =
new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetWindowsShell(false);
lg->SetMSYSShell(true);
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(false);
lg->SetUnixCD(true);

View File

@ -19,6 +19,8 @@ cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator()
this->ForceUnixPaths = true;
this->ToolSupportsColor = true;
this->UseLinkScript = true;
this->WindowsShell = true;
this->MinGWMake = true;
}
void cmGlobalMinGWMakefileGenerator
@ -62,11 +64,9 @@ cmGlobalMinGWMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
{
cmLocalUnixMakefileGenerator3* lg =
new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetWindowsShell(true);
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(false);
lg->SetUnixCD(true);
lg->SetMinGWMake(true);
return lg;
}

View File

@ -19,6 +19,8 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->UseLinkScript = false;
this->WindowsShell = true;
this->NMake = true;
}
void cmGlobalNMakeMakefileGenerator
@ -51,11 +53,9 @@ cmGlobalNMakeMakefileGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
cmLocalUnixMakefileGenerator3* lg =
new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetDefineWindowsNULL(true);
lg->SetWindowsShell(true);
lg->SetMakeSilentFlag("/nologo");
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(true);
lg->SetNMake(true);
lg->SetUnixCD(false);
return lg;
}

View File

@ -488,6 +488,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
, ComputingUnknownDependencies(false)
, PolicyCMP0058(cmPolicies::WARN)
{
#ifdef _WIN32
this->WindowsShell = true;
#endif
// // Ninja is not ported to non-Unix OS yet.
// this->ForceUnixPaths = true;
this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake";

View File

@ -23,6 +23,8 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
{
this->WindowsShell = true;
this->WindowsVSIDE = true;
}
//----------------------------------------------------------------------------

View File

@ -22,6 +22,10 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator()
this->ToolSupportsColor = true;
this->NeedSymbolicMark = true;
this->EmptyRuleHackCommand = "@cd .";
#ifdef _WIN32
this->WindowsShell = true;
#endif
this->WatcomWMake = true;
}
void cmGlobalWatcomWMakeGenerator
@ -47,10 +51,6 @@ cmGlobalWatcomWMakeGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
cmLocalUnixMakefileGenerator3* lg
= new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetDefineWindowsNULL(true);
#ifdef _WIN32
lg->SetWindowsShell(true);
#endif
lg->SetWatcomWMake(true);
lg->SetMakeSilentFlag("-h");
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(false);

View File

@ -61,12 +61,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
}
this->Makefile = new cmMakefile(this);
this->WindowsShell = false;
this->WindowsVSIDE = false;
this->WatcomWMake = false;
this->MinGWMake = false;
this->NMake = false;
this->MSYSShell = false;
this->LinkScriptShell = false;
this->IgnoreLibPrefix = false;
this->UseRelativePaths = false;
@ -1254,7 +1248,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote,
// If this is a windows shell, the result has a space, and the path
// already exists, we can use a short-path to reference it without a
// space.
if(this->WindowsShell && result.find(' ') != result.npos &&
if(this->GlobalGenerator->WindowsShell && result.find(' ') != result.npos &&
cmSystemTools::FileExists(remote.c_str()))
{
std::string tmp;
@ -2626,7 +2620,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
{
// Append the definition with proper escaping.
std::string def = dflag;
if(this->WatcomWMake)
if(this->GlobalGenerator->WatcomWMake)
{
// The Watcom compiler does its own command line parsing instead
// of using the windows shell rules. Definitions are one of
@ -2805,7 +2799,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
// For the MSYS shell convert drive letters to posix paths, so
// that c:/some/path becomes /c/some/path. This is needed to
// avoid problems with the shell path translation.
if(this->MSYSShell && !this->LinkScriptShell)
if(this->GlobalGenerator->MSYSShell && !this->LinkScriptShell)
{
if(result.size() > 2 && result[1] == ':')
{
@ -2813,7 +2807,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
result[0] = '/';
}
}
if(this->WindowsShell)
if(this->GlobalGenerator->WindowsShell)
{
std::replace(result.begin(), result.end(), '/', '\\');
}
@ -3324,6 +3318,26 @@ void cmLocalGenerator::ComputeObjectFilenames(
}
bool cmLocalGenerator::IsWindowsShell() const
{
return this->GlobalGenerator->WindowsShell;
}
bool cmLocalGenerator::IsWatcomWMake() const
{
return this->GlobalGenerator->WatcomWMake;
}
bool cmLocalGenerator::IsMinGWMake() const
{
return this->GlobalGenerator->MinGWMake;
}
bool cmLocalGenerator::IsNMake() const
{
return this->GlobalGenerator->NMake;
}
//----------------------------------------------------------------------------
std::string
cmLocalGenerator
@ -3467,7 +3481,7 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
// Compute the flags for the target shell environment.
int flags = 0;
if(this->WindowsVSIDE)
if(this->GlobalGenerator->WindowsVSIDE)
{
flags |= cmsysSystem_Shell_Flag_VSIDE;
}
@ -3487,27 +3501,27 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
{
flags |= cmsysSystem_Shell_Flag_WatcomQuote;
}
if(this->WatcomWMake)
if(this->GlobalGenerator->WatcomWMake)
{
flags |= cmsysSystem_Shell_Flag_WatcomWMake;
}
if(this->MinGWMake)
if(this->GlobalGenerator->MinGWMake)
{
flags |= cmsysSystem_Shell_Flag_MinGWMake;
}
if(this->NMake)
if(this->GlobalGenerator->NMake)
{
flags |= cmsysSystem_Shell_Flag_NMake;
}
// Compute the buffer size needed.
int size = (this->WindowsShell ?
int size = (this->GlobalGenerator->WindowsShell ?
cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) :
cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags));
// Compute the shell argument itself.
std::vector<char> arg(size);
if(this->WindowsShell)
if(this->GlobalGenerator->WindowsShell)
{
cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags);
}

View File

@ -383,6 +383,11 @@ public:
std::map<cmSourceFile const*, std::string>& mapping,
cmGeneratorTarget const* gt = 0);
bool IsWindowsShell() const;
bool IsWatcomWMake() const;
bool IsMinGWMake() const;
bool IsNMake() const;
protected:
///! put all the libraries for a target on into the given stream
virtual void OutputLinkLibraries(std::string& linkLibraries,
@ -457,17 +462,13 @@ protected:
std::map<std::string, std::string> UniqueObjectNamesMap;
std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations;
bool WindowsShell;
bool WindowsVSIDE;
bool WatcomWMake;
bool MinGWMake;
bool NMake;
bool MSYSShell;
bool LinkScriptShell;
bool UseRelativePaths;
bool IgnoreLibPrefix;
bool Configured;
bool EmitUniversalBinaryFlags;
// Hack for ExpandRuleVariable until object-oriented version is
// committed.
std::string TargetImplib;

View File

@ -28,9 +28,6 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
, ConfigName("")
, HomeRelativeOutputPath("")
{
#ifdef _WIN32
this->WindowsShell = true;
#endif
this->TargetImplib = "$TARGET_IMPLIB";
}

View File

@ -83,7 +83,6 @@ cmLocalUnixMakefileGenerator3::
cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent)
: cmLocalGenerator(gg, parent)
{
this->WindowsShell = false;
this->IncludeDirective = "include";
this->MakefileVariableSize = 0;
this->IgnoreLibPrefix = false;
@ -679,7 +678,7 @@ cmLocalUnixMakefileGenerator3
// Write the list of commands.
os << cmWrap("\t", commands, "", "\n") << "\n";
if(symbolic && !this->WatcomWMake)
if(symbolic && !this->IsWatcomWMake())
{
os << ".PHONY : " << cmMakeSafe(tgt) << "\n";
}
@ -696,7 +695,7 @@ std::string
cmLocalUnixMakefileGenerator3
::ConvertShellCommand(std::string const& cmd, RelativeRoot root)
{
if(this->WatcomWMake &&
if(this->IsWatcomWMake() &&
cmSystemTools::FileIsFullPath(cmd.c_str()) &&
cmd.find_first_of("( )") != cmd.npos)
{
@ -730,7 +729,7 @@ cmLocalUnixMakefileGenerator3
<< "NULL=nul\n"
<< "!ENDIF\n";
}
if(this->WindowsShell)
if(this->IsWindowsShell())
{
makefileStream
<< "SHELL = cmd.exe\n"
@ -798,7 +797,8 @@ cmLocalUnixMakefileGenerator3
makefileStream, "Disable implicit rules so canonical targets will work.",
".SUFFIXES", no_depends, no_commands, false);
if(!this->NMake && !this->WatcomWMake && !this->BorlandMakeCurlyHack)
if(!this->IsNMake()
&& !this->IsWatcomWMake() && !this->BorlandMakeCurlyHack)
{
// turn off RCS and SCCS automatic stuff from gmake
makefileStream
@ -810,7 +810,7 @@ cmLocalUnixMakefileGenerator3
depends.push_back(".hpux_make_needs_suffix_list");
this->WriteMakeRule(makefileStream, 0,
".SUFFIXES", depends, no_commands, false);
if(this->WatcomWMake)
if(this->IsWatcomWMake())
{
// Switch on WMake feature, if an error or interrupt occurs during
// makefile processing, the current target being made may be deleted
@ -828,7 +828,7 @@ cmLocalUnixMakefileGenerator3
<< "VERBOSE = 1\n"
<< "\n";
}
if(this->WatcomWMake)
if(this->IsWatcomWMake())
{
makefileStream <<
"!ifndef VERBOSE\n"
@ -962,7 +962,7 @@ cmLocalUnixMakefileGenerator3
void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
const std::string& newFlags)
{
if(this->WatcomWMake && !newFlags.empty())
if(this->IsWatcomWMake() && !newFlags.empty())
{
std::string newf = newFlags;
if(newf.find("\\\"") != newf.npos)
@ -1112,7 +1112,7 @@ cmLocalUnixMakefileGenerator3
//
bool useCall = false;
if (this->WindowsShell)
if (this->IsWindowsShell())
{
std::string suffix;
if (cmd.size() > 4)
@ -1179,7 +1179,7 @@ cmLocalUnixMakefileGenerator3
{
cmd = "call " + cmd;
}
else if (this->NMake && cmd[0]=='"')
else if (this->IsNMake() && cmd[0]=='"')
{
cmd = "echo >nul && " + cmd;
}
@ -2344,7 +2344,7 @@ void cmLocalUnixMakefileGenerator3
// used by NMake and Borland make does not support "cd /d" so this
// feature simply cannot work with them (Borland make does not even
// support changing the drive letter with just "d:").
const char* cd_cmd = this->MinGWMake? "cd /d " : "cd ";
const char* cd_cmd = this->IsMinGWMake() ? "cd /d " : "cd ";
if(!this->UnixCD)
{

View File

@ -80,36 +80,6 @@ public:
void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; }
std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; }
/**
* Set to true if the shell being used is the windows shell.
* This controls if statements in the makefile and the SHELL variable.
* The default is false.
*/
void SetWindowsShell(bool v) {this->WindowsShell = v;}
/**
* Set to true if the make tool being used is Watcom WMake.
*/
void SetWatcomWMake(bool v) {this->WatcomWMake = v;}
/**
* Set to true if the make tool being used is MinGW Make.
*/
void SetMinGWMake(bool v) {this->MinGWMake = v;}
bool IsMinGWMake() const { return this->MinGWMake; }
/**
* Set to true if the make tool being used is NMake.
*/
void SetNMake(bool v) {this->NMake = v;}
/**
* Set to true if the shell being used is the MSYS shell.
* This controls if statements in the makefile and the SHELL variable.
* The default is false.
*/
void SetMSYSShell(bool v) {this->MSYSShell = v;}
/**
* If set to true, then NULL is set to nil for non Windows_NT.
* This uses make syntax used by nmake and borland.

View File

@ -23,8 +23,6 @@ cmLocalVisualStudioGenerator
cmLocalGenerator* parent)
: cmLocalGenerator(gg, parent)
{
this->WindowsShell = true;
this->WindowsVSIDE = true;
this->Version = v;
}