Merge topic 'refactor-cmLocalGenerator'

ce167b54 cmMakefile: Handle CMP0014 before configuring the generator.
7baef756 cmLocalGenerator: Assert that there is a parent.
63255342 cmMakefile: Remove redundant variable set.
894961af cmMakefile: Use the state to determine the parent directory.
115e9199 Use new top-level check abstraction.
c5059c90 cmLocalGenerator: Add abstraction to check if top-level.
b17686d2 cmGlobalGenerator: Move some flags from cmLocalGenerator.
ed41a8e7 cmLocalGenerator: Port loops to cmState::Snapshot.
48a9e91b cmState: Add an accessor for Parent snapshot and a validity check.
e7f7c2e2 cmLocalGenerator: Convert two recursive methods to loops.
c5cb3a73 cmLocalGenerator: Get project directories from the cmState.
76b59831 cmLocalGenerator: Initialize state before creating cmMakefile.
34c9ee2e cmLocalGenerator: Require a global generator in the constructor.
3837c483 Tests: Add case for 'ctest' run with bad CTestTestfile
b317b38d cmGlobalBorlandMakefileGenerator: Do not inherit from NMake generator
94867698 Don't use a cmLocalGenerator instance to call static methods.
...
This commit is contained in:
Brad King 2015-05-15 11:22:36 -04:00 committed by CMake Topic Stage
commit 2e4ea0c055
52 changed files with 401 additions and 360 deletions

View File

@ -242,8 +242,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
} }
// Detect languages to enable. // Detect languages to enable.
cmLocalGenerator* lg = this->Makefile->GetLocalGenerator(); cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
std::set<std::string> testLangs; std::set<std::string> testLangs;
for(std::vector<std::string>::iterator si = sources.begin(); for(std::vector<std::string>::iterator si = sources.begin();
si != sources.end(); ++si) si != sources.end(); ++si)
@ -323,7 +322,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
std::string langFlags = "CMAKE_" + *li + "_FLAGS"; std::string langFlags = "CMAKE_" + *li + "_FLAGS";
const char* flags = this->Makefile->GetDefinition(langFlags); const char* flags = this->Makefile->GetDefinition(langFlags);
fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(), fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
lg->EscapeForCMake(flags?flags:"").c_str()); cmLocalGenerator::EscapeForCMake(flags?flags:"").c_str());
fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
" ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str());
} }
@ -356,7 +355,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
const char* exeLinkFlags = const char* exeLinkFlags =
this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS"); this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n", fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n",
lg->EscapeForCMake(exeLinkFlags?exeLinkFlags:"").c_str()); cmLocalGenerator::EscapeForCMake(
exeLinkFlags ? exeLinkFlags : "").c_str());
} break; } break;
} }
fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}" fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}"

View File

@ -50,6 +50,35 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
return this->GE->Parse(argv0)->Evaluate(this->Makefile, this->Config); return this->GE->Parse(argv0)->Evaluate(this->Makefile, this->Config);
} }
//----------------------------------------------------------------------------
std::string escapeForShellOldStyle(const std::string& str)
{
std::string result;
#if defined(_WIN32) && !defined(__CYGWIN__)
// if there are spaces
std::string temp = str;
if (temp.find(" ") != std::string::npos &&
temp.find("\"")==std::string::npos)
{
result = "\"";
result += str;
result += "\"";
return result;
}
return str;
#else
for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
{
if(*ch == ' ')
{
result += '\\';
}
result += *ch;
}
return result;
#endif
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmCustomCommandGenerator cmCustomCommandGenerator
@ -63,7 +92,7 @@ cmCustomCommandGenerator
cmd += " "; cmd += " ";
if(this->OldStyle) if(this->OldStyle)
{ {
cmd += this->LG->EscapeForShellOldStyle(arg); cmd += escapeForShellOldStyle(arg);
} }
else else
{ {

View File

@ -21,6 +21,7 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
this->ForceUnixPaths = false; this->ForceUnixPaths = false;
this->ToolSupportsColor = true; this->ToolSupportsColor = true;
this->UseLinkScript = false; this->UseLinkScript = false;
this->WindowsShell = true;
} }
@ -41,13 +42,11 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
cmLocalGenerator* parent) cmLocalGenerator* parent)
{ {
cmLocalUnixMakefileGenerator3* lg = cmLocalUnixMakefileGenerator3* lg =
new cmLocalUnixMakefileGenerator3(parent); new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetIncludeDirective("!include"); lg->SetIncludeDirective("!include");
lg->SetWindowsShell(true);
lg->SetDefineWindowsNULL(true); lg->SetDefineWindowsNULL(true);
lg->SetMakefileVariableSize(32); lg->SetMakefileVariableSize(32);
lg->SetPassMakeflags(true); lg->SetPassMakeflags(true);
lg->SetGlobalGenerator(this);
lg->SetUnixCD(false); lg->SetUnixCD(false);
lg->SetMakeCommandEscapeTargetTwice(true); lg->SetMakeCommandEscapeTargetTwice(true);
lg->SetBorlandMakeCurlyHack(true); lg->SetBorlandMakeCurlyHack(true);

View File

@ -19,7 +19,7 @@
* *
* cmGlobalBorlandMakefileGenerator manages nmake build process for a tree * cmGlobalBorlandMakefileGenerator manages nmake build process for a tree
*/ */
class cmGlobalBorlandMakefileGenerator : public cmGlobalNMakeMakefileGenerator class cmGlobalBorlandMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{ {
public: public:
cmGlobalBorlandMakefileGenerator(); cmGlobalBorlandMakefileGenerator();

View File

@ -71,6 +71,13 @@ cmGlobalGenerator::cmGlobalGenerator()
this->ExtraGenerator = 0; this->ExtraGenerator = 0;
this->CurrentLocalGenerator = 0; this->CurrentLocalGenerator = 0;
this->TryCompileOuterMakefile = 0; this->TryCompileOuterMakefile = 0;
this->WindowsShell = false;
this->WindowsVSIDE = false;
this->WatcomWMake = false;
this->MinGWMake = false;
this->NMake = false;
this->MSYSShell = false;
} }
cmGlobalGenerator::~cmGlobalGenerator() cmGlobalGenerator::~cmGlobalGenerator()
@ -1877,9 +1884,7 @@ void cmGlobalGenerator::EnableInstallTarget()
cmLocalGenerator * cmLocalGenerator *
cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator *parent) cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator *parent)
{ {
cmLocalGenerator *lg = new cmLocalGenerator(parent); return new cmLocalGenerator(this, parent);
lg->SetGlobalGenerator(this);
return lg;
} }
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,

View File

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

View File

@ -35,8 +35,7 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
cmLocalGenerator * cmLocalGenerator *
cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalGenerator *lg = new cmLocalGhsMultiGenerator(parent); cmLocalGenerator *lg = new cmLocalGhsMultiGenerator(this, parent);
lg->SetGlobalGenerator(this);
this->SetCurrentLocalGenerator(lg); this->SetCurrentLocalGenerator(lg);
return lg; return lg;
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -488,6 +488,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
, ComputingUnknownDependencies(false) , ComputingUnknownDependencies(false)
, PolicyCMP0058(cmPolicies::WARN) , PolicyCMP0058(cmPolicies::WARN)
{ {
#ifdef _WIN32
this->WindowsShell = true;
#endif
// // Ninja is not ported to non-Unix OS yet. // // Ninja is not ported to non-Unix OS yet.
// this->ForceUnixPaths = true; // this->ForceUnixPaths = true;
this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake"; this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake";
@ -500,9 +503,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
cmLocalGenerator* cmLocalGenerator*
cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalGenerator* lg = new cmLocalNinjaGenerator(parent); return new cmLocalNinjaGenerator(this, parent);
lg->SetGlobalGenerator(this);
return lg;
} }
void cmGlobalNinjaGenerator void cmGlobalNinjaGenerator

View File

@ -56,9 +56,7 @@ void cmGlobalUnixMakefileGenerator3
cmLocalGenerator * cmLocalGenerator *
cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalGenerator* lg = new cmLocalUnixMakefileGenerator3(parent); return new cmLocalUnixMakefileGenerator3(this, parent);
lg->SetGlobalGenerator(this);
return lg;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -524,7 +522,7 @@ cmGlobalUnixMakefileGenerator3
cmLocalUnixMakefileGenerator3* lg) cmLocalUnixMakefileGenerator3* lg)
{ {
// Only subdirectories need these rules. // Only subdirectories need these rules.
if(!lg->GetParent()) if(lg->IsRootMakefile())
{ {
return; return;
} }
@ -1029,7 +1027,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]); static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
// for the passed in makefile or if this is the top Makefile wripte out // for the passed in makefile or if this is the top Makefile wripte out
// the targets // the targets
if (lg2 == lg || !lg->GetParent()) if (lg2 == lg || lg->IsRootMakefile())
{ {
// for each target Generate the rule files for each target. // for each target Generate the rule files for each target.
cmTargets& targets = lg2->GetMakefile()->GetTargets(); cmTargets& targets = lg2->GetMakefile()->GetTargets();

View File

@ -311,11 +311,8 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio10Generator* lg = return new cmLocalVisualStudio10Generator(
new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS10, cmLocalVisualStudioGenerator::VS10, this, parent);
parent);
lg->SetGlobalGenerator(this);
return lg;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -240,11 +240,8 @@ void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio11Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio11Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio10Generator* lg = return new cmLocalVisualStudio10Generator(
new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11, cmLocalVisualStudioGenerator::VS11, this, parent);
parent);
lg->SetGlobalGenerator(this);
return lg;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -220,11 +220,8 @@ void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio12Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio12Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio10Generator* lg = return new cmLocalVisualStudio10Generator(
new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS12, cmLocalVisualStudioGenerator::VS12, this, parent);
parent);
lg->SetGlobalGenerator(this);
return lg;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -131,9 +131,6 @@ void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio14Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio14Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio10Generator* lg = return new cmLocalVisualStudio10Generator(
new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS14, cmLocalVisualStudioGenerator::VS14, this, parent);
parent);
lg->SetGlobalGenerator(this);
return lg;
} }

View File

@ -173,9 +173,7 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
cmLocalGenerator * cmLocalGenerator *
cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalGenerator *lg = new cmLocalVisualStudio6Generator(parent); return new cmLocalVisualStudio6Generator(this, parent);
lg->SetGlobalGenerator(this);
return lg;
} }

View File

@ -30,9 +30,8 @@ cmGlobalVisualStudio71Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg = cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71, new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71,
parent); this, parent);
lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS7());
lg->SetGlobalGenerator(this);
return lg; return lg;
} }

View File

@ -255,9 +255,8 @@ cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg = cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7, new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7,
parent); this, parent);
lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS7());
lg->SetGlobalGenerator(this);
return lg; return lg;
} }

View File

@ -130,9 +130,8 @@ cmGlobalVisualStudio8Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg = cmLocalVisualStudio7Generator *lg =
new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8, new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8,
parent); this, parent);
lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
lg->SetGlobalGenerator(this);
return lg; return lg;
} }

View File

@ -119,9 +119,8 @@ cmGlobalVisualStudio9Generator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalVisualStudio7Generator *lg cmLocalVisualStudio7Generator *lg
= new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9, = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9,
parent); this, parent);
lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
lg->SetGlobalGenerator(this);
return lg; return lg;
} }

View File

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

View File

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

View File

@ -371,9 +371,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
cmLocalGenerator * cmLocalGenerator *
cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent) cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent)
{ {
cmLocalGenerator *lg = new cmLocalXCodeGenerator(parent); return new cmLocalXCodeGenerator(this, parent);
lg->SetGlobalGenerator(this);
return lg;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -20,15 +20,14 @@
static std::string cmIfCommandError( static std::string cmIfCommandError(
cmMakefile* mf, std::vector<cmExpandedCommandArgument> const& args) std::vector<cmExpandedCommandArgument> const& args)
{ {
cmLocalGenerator* lg = mf->GetLocalGenerator();
std::string err = "given arguments:\n "; std::string err = "given arguments:\n ";
for(std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin(); for(std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin();
i != args.end(); ++i) i != args.end(); ++i)
{ {
err += " "; err += " ";
err += lg->EscapeForCMake(i->GetValue()); err += cmLocalGenerator::EscapeForCMake(i->GetValue());
} }
err += "\n"; err += "\n";
return err; return err;
@ -118,7 +117,7 @@ IsFunctionBlocked(const cmListFileFunction& lff,
if (!errorString.empty()) if (!errorString.empty())
{ {
std::string err = cmIfCommandError(&mf, expandedArguments); std::string err = cmIfCommandError(expandedArguments);
err += errorString; err += errorString;
mf.IssueMessage(messType, err); mf.IssueMessage(messType, err);
if (messType == cmake::FATAL_ERROR) if (messType == cmake::FATAL_ERROR)
@ -206,7 +205,7 @@ bool cmIfCommand
if (!errorString.empty()) if (!errorString.empty())
{ {
std::string err = cmIfCommandError(this->Makefile, expandedArguments); std::string err = cmIfCommandError(expandedArguments);
err += errorString; err += errorString;
if (status == cmake::FATAL_ERROR) if (status == cmake::FATAL_ERROR)
{ {

View File

@ -43,20 +43,24 @@
#include <StorageDefs.h> #include <StorageDefs.h>
#endif #endif
cmLocalGenerator::cmLocalGenerator(cmLocalGenerator* parent) cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
cmLocalGenerator* parent)
{ {
this->Makefile = 0; // moved to after set on global this->GlobalGenerator = gg;
this->Parent = parent; this->Parent = parent;
if (parent) if (parent)
{ {
parent->AddChild(this); parent->AddChild(this);
this->StateSnapshot =
this->GetState()->CreateSnapshot(parent->StateSnapshot);
} }
this->WindowsShell = false; else
this->WindowsVSIDE = false; {
this->WatcomWMake = false; this->StateSnapshot =
this->MinGWMake = false; this->GetState()->CreateSnapshot(cmState::Snapshot(this->GetState()));
this->NMake = false; }
this->MSYSShell = false; this->Makefile = new cmMakefile(this);
this->LinkScriptShell = false; this->LinkScriptShell = false;
this->IgnoreLibPrefix = false; this->IgnoreLibPrefix = false;
this->UseRelativePaths = false; this->UseRelativePaths = false;
@ -73,6 +77,11 @@ cmLocalGenerator::~cmLocalGenerator()
delete this->Makefile; delete this->Makefile;
} }
bool cmLocalGenerator::IsRootMakefile() const
{
return !this->GetParent();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class cmLocalGeneratorCurrent class cmLocalGeneratorCurrent
{ {
@ -105,7 +114,7 @@ void cmLocalGenerator::Configure()
static_cast<void>(clg); static_cast<void>(clg);
// make sure the CMakeFiles dir is there // make sure the CMakeFiles dir is there
std::string filesDir = this->Makefile->GetCurrentBinaryDirectory(); std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory();
filesDir += cmake::GetCMakeFilesDirectory(); filesDir += cmake::GetCMakeFilesDirectory();
cmSystemTools::MakeDirectory(filesDir.c_str()); cmSystemTools::MakeDirectory(filesDir.c_str());
@ -181,48 +190,10 @@ void cmLocalGenerator::ComputeObjectMaxPath()
void cmLocalGenerator::ReadInputFile() void cmLocalGenerator::ReadInputFile()
{ {
// Look for the CMakeLists.txt file. // Look for the CMakeLists.txt file.
std::string currentStart = this->Makefile->GetCurrentSourceDirectory(); std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory();
currentStart += "/CMakeLists.txt"; currentStart += "/CMakeLists.txt";
if(cmSystemTools::FileExists(currentStart.c_str(), true)) assert(cmSystemTools::FileExists(currentStart.c_str(), true));
{
this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); this->Makefile->ProcessBuildsystemFile(currentStart.c_str());
return;
}
if(!this->Parent)
{
return;
}
// The file is missing. Check policy CMP0014.
cmMakefile* mf = this->Parent->GetMakefile();
std::ostringstream e;
e << "The source directory\n"
<< " " << this->Makefile->GetCurrentSourceDirectory() << "\n"
<< "does not contain a CMakeLists.txt file.";
switch (mf->GetPolicyStatus(cmPolicies::CMP0014))
{
case cmPolicies::WARN:
// Print the warning.
e << "\n"
<< "CMake does not support this case but it used "
<< "to work accidentally and is being allowed for "
<< "compatibility."
<< "\n"
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0014);
mf->IssueMessage(cmake::AUTHOR_WARNING, e.str());
case cmPolicies::OLD:
// OLD behavior does not warn.
return;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
e << "\n"
<< cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0014);
case cmPolicies::NEW:
// NEW behavior prints the error.
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
break;
}
} }
void cmLocalGenerator::SetupPathConversions() void cmLocalGenerator::SetupPathConversions()
@ -231,31 +202,23 @@ void cmLocalGenerator::SetupPathConversions()
// Convert // Convert
std::string outdir; std::string outdir;
outdir = outdir =
cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory()); cmSystemTools::CollapseFullPath(this->GetState()->GetSourceDirectory());
cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents); cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents);
outdir = outdir = cmSystemTools::CollapseFullPath(
cmSystemTools::CollapseFullPath( this->StateSnapshot.GetCurrentSourceDirectory());
this->Makefile->GetCurrentSourceDirectory());
cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents); cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
outdir = cmSystemTools::CollapseFullPath outdir = cmSystemTools::CollapseFullPath
(this->Makefile->GetHomeOutputDirectory()); (this->GetState()->GetBinaryDirectory());
cmSystemTools::SplitPath(outdir, cmSystemTools::SplitPath(outdir,
this->HomeOutputDirectoryComponents); this->HomeOutputDirectoryComponents);
outdir = cmSystemTools::CollapseFullPath outdir = cmSystemTools::CollapseFullPath
(this->Makefile->GetCurrentBinaryDirectory()); (this->StateSnapshot.GetCurrentBinaryDirectory());
cmSystemTools::SplitPath(outdir, cmSystemTools::SplitPath(outdir,
this->StartOutputDirectoryComponents); this->StartOutputDirectoryComponents);
} }
void cmLocalGenerator::SetGlobalGenerator(cmGlobalGenerator *gg)
{
this->GlobalGenerator = gg;
this->Makefile = new cmMakefile(this);
}
void cmLocalGenerator::ConfigureFinalPass() void cmLocalGenerator::ConfigureFinalPass()
{ {
this->Makefile->ConfigureFinalPass(); this->Makefile->ConfigureFinalPass();
@ -300,7 +263,7 @@ void cmLocalGenerator::GenerateTestFiles()
const std::string& config = const std::string& config =
this->Makefile->GetConfigurations(configurationTypes, false); this->Makefile->GetConfigurations(configurationTypes, false);
std::string file = this->Makefile->GetCurrentBinaryDirectory(); std::string file = this->StateSnapshot.GetCurrentBinaryDirectory();
file += "/"; file += "/";
file += "CTestTestfile.cmake"; file += "CTestTestfile.cmake";
@ -309,9 +272,9 @@ void cmLocalGenerator::GenerateTestFiles()
fout << "# CMake generated Testfile for " << std::endl fout << "# CMake generated Testfile for " << std::endl
<< "# Source directory: " << "# Source directory: "
<< this->Makefile->GetCurrentSourceDirectory() << std::endl << this->StateSnapshot.GetCurrentSourceDirectory() << std::endl
<< "# Build directory: " << "# Build directory: "
<< this->Makefile->GetCurrentBinaryDirectory() << std::endl << this->StateSnapshot.GetCurrentBinaryDirectory() << std::endl
<< "# " << std::endl << "# " << std::endl
<< "# This file includes the relevant testing commands " << "# This file includes the relevant testing commands "
<< "required for " << std::endl << "required for " << std::endl
@ -425,9 +388,9 @@ void cmLocalGenerator::GenerateInstallRules()
} }
// Create the install script file. // Create the install script file.
std::string file = this->Makefile->GetCurrentBinaryDirectory(); std::string file = this->StateSnapshot.GetCurrentBinaryDirectory();
std::string homedir = this->Makefile->GetHomeOutputDirectory(); std::string homedir = this->GetState()->GetBinaryDirectory();
std::string currdir = this->Makefile->GetCurrentBinaryDirectory(); std::string currdir = this->StateSnapshot.GetCurrentBinaryDirectory();
cmSystemTools::ConvertToUnixSlashes(file); cmSystemTools::ConvertToUnixSlashes(file);
cmSystemTools::ConvertToUnixSlashes(homedir); cmSystemTools::ConvertToUnixSlashes(homedir);
cmSystemTools::ConvertToUnixSlashes(currdir); cmSystemTools::ConvertToUnixSlashes(currdir);
@ -442,7 +405,7 @@ void cmLocalGenerator::GenerateInstallRules()
// Write the header. // Write the header.
fout << "# Install script for directory: " fout << "# Install script for directory: "
<< this->Makefile->GetCurrentSourceDirectory() << this->StateSnapshot.GetCurrentSourceDirectory()
<< std::endl << std::endl; << std::endl << std::endl;
fout << "# Set the install prefix" << std::endl fout << "# Set the install prefix" << std::endl
<< "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl << "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
@ -577,6 +540,16 @@ void cmLocalGenerator::GenerateTargetManifest()
} }
} }
cmState* cmLocalGenerator::GetState() const
{
return this->GlobalGenerator->GetCMakeInstance()->GetState();
}
cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const
{
return this->StateSnapshot;
}
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
const std::string& lang, const std::string& lang,
cmSourceFile& source, cmSourceFile& source,
@ -651,7 +624,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
source.GetFullPath(), source.GetFullPath(),
commandLines, commandLines,
comment.c_str(), comment.c_str(),
this->Makefile->GetCurrentBinaryDirectory() this->StateSnapshot.GetCurrentBinaryDirectory()
); );
} }
@ -673,12 +646,12 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
!sf->GetPropertyAsBool("EXTERNAL_OBJECT")) !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
{ {
std::string dir_max; std::string dir_max;
dir_max += this->Makefile->GetCurrentBinaryDirectory(); dir_max += this->StateSnapshot.GetCurrentBinaryDirectory();
dir_max += "/"; dir_max += "/";
std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max); std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
if(!obj.empty()) if(!obj.empty())
{ {
std::string ofname = this->Makefile->GetCurrentBinaryDirectory(); std::string ofname = this->StateSnapshot.GetCurrentBinaryDirectory();
ofname += "/"; ofname += "/";
ofname += obj; ofname += obj;
objVector.push_back(ofname); objVector.push_back(ofname);
@ -748,7 +721,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
"", "",
commandLines, commandLines,
comment.c_str(), comment.c_str(),
this->Makefile->GetCurrentBinaryDirectory() this->StateSnapshot.GetCurrentBinaryDirectory()
); );
this->Makefile->GetSource(targetFullPath); this->Makefile->GetSource(targetFullPath);
target.Target->AddSource(targetFullPath); target.Target->AddSource(targetFullPath);
@ -1242,7 +1215,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote,
// If this is a windows shell, the result has a space, and the path // 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 // already exists, we can use a short-path to reference it without a
// space. // space.
if(this->WindowsShell && result.find(' ') != result.npos && if(this->GlobalGenerator->WindowsShell && result.find(' ') != result.npos &&
cmSystemTools::FileExists(remote.c_str())) cmSystemTools::FileExists(remote.c_str()))
{ {
std::string tmp; std::string tmp;
@ -1552,19 +1525,19 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
if(includeBinaryDir) if(includeBinaryDir)
{ {
if(emitted.find( if(emitted.find(
this->Makefile->GetCurrentBinaryDirectory()) == emitted.end()) this->StateSnapshot.GetCurrentBinaryDirectory()) == emitted.end())
{ {
dirs.push_back(this->Makefile->GetCurrentBinaryDirectory()); dirs.push_back(this->StateSnapshot.GetCurrentBinaryDirectory());
emitted.insert(this->Makefile->GetCurrentBinaryDirectory()); emitted.insert(this->StateSnapshot.GetCurrentBinaryDirectory());
} }
} }
if(includeSourceDir) if(includeSourceDir)
{ {
if(emitted.find( if(emitted.find(
this->Makefile->GetCurrentSourceDirectory()) == emitted.end()) this->StateSnapshot.GetCurrentSourceDirectory()) == emitted.end())
{ {
dirs.push_back(this->Makefile->GetCurrentSourceDirectory()); dirs.push_back(this->StateSnapshot.GetCurrentSourceDirectory());
emitted.insert(this->Makefile->GetCurrentSourceDirectory()); emitted.insert(this->StateSnapshot.GetCurrentSourceDirectory());
} }
} }
@ -1606,8 +1579,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
// it is requested by the project. // it is requested by the project.
if(this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) if(this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"))
{ {
const char* topSourceDir = this->Makefile->GetHomeDirectory(); const char* topSourceDir = this->GetState()->GetSourceDirectory();
const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); const char* topBinaryDir = this->GetState()->GetBinaryDirectory();
for(std::vector<std::string>::const_iterator i = includes.begin(); for(std::vector<std::string>::const_iterator i = includes.begin();
i != includes.end(); ++i) i != includes.end(); ++i)
{ {
@ -2165,7 +2138,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// Treat the name as relative to the source directory in which it // Treat the name as relative to the source directory in which it
// was given. // was given.
dep = this->Makefile->GetCurrentSourceDirectory(); dep = this->StateSnapshot.GetCurrentSourceDirectory();
dep += "/"; dep += "/";
dep += inName; dep += inName;
return true; return true;
@ -2614,7 +2587,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
{ {
// Append the definition with proper escaping. // Append the definition with proper escaping.
std::string def = dflag; std::string def = dflag;
if(this->WatcomWMake) if(this->GlobalGenerator->WatcomWMake)
{ {
// The Watcom compiler does its own command line parsing instead // The Watcom compiler does its own command line parsing instead
// of using the windows shell rules. Definitions are one of // of using the windows shell rules. Definitions are one of
@ -2717,10 +2690,10 @@ const char* cmLocalGenerator::GetRelativeRootPath(RelativeRoot relroot)
{ {
switch (relroot) switch (relroot)
{ {
case HOME: return this->Makefile->GetHomeDirectory(); case HOME: return this->GetState()->GetSourceDirectory();
case START: return this->Makefile->GetCurrentSourceDirectory(); case START: return this->StateSnapshot.GetCurrentSourceDirectory();
case HOME_OUTPUT: return this->Makefile->GetHomeOutputDirectory(); case HOME_OUTPUT: return this->GetState()->GetBinaryDirectory();
case START_OUTPUT: return this->Makefile->GetCurrentBinaryDirectory(); case START_OUTPUT: return this->StateSnapshot.GetCurrentBinaryDirectory();
default: break; default: break;
} }
return 0; return 0;
@ -2793,7 +2766,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
// For the MSYS shell convert drive letters to posix paths, so // For the MSYS shell convert drive letters to posix paths, so
// that c:/some/path becomes /c/some/path. This is needed to // that c:/some/path becomes /c/some/path. This is needed to
// avoid problems with the shell path translation. // avoid problems with the shell path translation.
if(this->MSYSShell && !this->LinkScriptShell) if(this->GlobalGenerator->MSYSShell && !this->LinkScriptShell)
{ {
if(result.size() > 2 && result[1] == ':') if(result.size() > 2 && result[1] == ':')
{ {
@ -2801,7 +2774,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
result[0] = '/'; result[0] = '/';
} }
} }
if(this->WindowsShell) if(this->GlobalGenerator->WindowsShell)
{ {
std::replace(result.begin(), result.end(), '/', '\\'); std::replace(result.begin(), result.end(), '/', '\\');
} }
@ -2841,41 +2814,69 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmLocalGenerator::FindRelativePathTopSource() std::string cmLocalGenerator::FindRelativePathTopSource()
{ {
// Relative path conversion within a single tree managed by CMake is cmState::Snapshot snapshot = this->StateSnapshot;
// safe. We can use our parent relative path top if and only if std::vector<cmState::Snapshot> snapshots;
// this is a subdirectory of that top. snapshots.push_back(snapshot);
if(cmLocalGenerator* parent = this->GetParent()) while (true)
{ {
std::string parentTop = parent->FindRelativePathTopSource(); snapshot = snapshot.GetParent();
if(cmSystemTools::IsSubDirectory( if (snapshot.IsValid())
this->Makefile->GetCurrentSourceDirectory(), parentTop))
{ {
return parentTop; snapshots.push_back(snapshot);
}
else
{
break;
} }
} }
// Otherwise this directory itself is the new top. std::string result = snapshots.front().GetCurrentSourceDirectory();
return this->Makefile->GetCurrentSourceDirectory();
for (std::vector<cmState::Snapshot>::const_iterator it =
snapshots.begin() + 1; it != snapshots.end(); ++it)
{
std::string currentSource = it->GetCurrentSourceDirectory();
if(cmSystemTools::IsSubDirectory(result, currentSource))
{
result = currentSource;
}
}
return result;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmLocalGenerator::FindRelativePathTopBinary() std::string cmLocalGenerator::FindRelativePathTopBinary()
{ {
// Relative path conversion within a single tree managed by CMake is cmState::Snapshot snapshot = this->StateSnapshot;
// safe. We can use our parent relative path top if and only if std::vector<cmState::Snapshot> snapshots;
// this is a subdirectory of that top. snapshots.push_back(snapshot);
if(cmLocalGenerator* parent = this->GetParent()) while (true)
{ {
std::string parentTop = parent->FindRelativePathTopBinary(); snapshot = snapshot.GetParent();
if(cmSystemTools::IsSubDirectory( if (snapshot.IsValid())
this->Makefile->GetCurrentBinaryDirectory(), parentTop))
{ {
return parentTop; snapshots.push_back(snapshot);
}
else
{
break;
} }
} }
// Otherwise this directory itself is the new top. std::string result = snapshots.front().GetCurrentBinaryDirectory();
return this->Makefile->GetCurrentBinaryDirectory();
for (std::vector<cmState::Snapshot>::const_iterator it =
snapshots.begin() + 1; it != snapshots.end(); ++it)
{
std::string currentBinary = it->GetCurrentBinaryDirectory();
if(cmSystemTools::IsSubDirectory(result, currentBinary))
{
result = currentBinary;
}
}
return result;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -3284,6 +3285,31 @@ 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;
}
void cmLocalGenerator::SetConfiguredCMP0014(bool configured)
{
this->Configured = configured;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalGenerator cmLocalGenerator
@ -3391,35 +3417,6 @@ cmLocalGenerator
return source.GetLanguage(); return source.GetLanguage();
} }
//----------------------------------------------------------------------------
std::string cmLocalGenerator::EscapeForShellOldStyle(const std::string& str)
{
std::string result;
#if defined(_WIN32) && !defined(__CYGWIN__)
// if there are spaces
std::string temp = str;
if (temp.find(" ") != std::string::npos &&
temp.find("\"")==std::string::npos)
{
result = "\"";
result += str;
result += "\"";
return result;
}
return str;
#else
for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
{
if(*ch == ' ')
{
result += '\\';
}
result += *ch;
}
return result;
#endif
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static bool cmLocalGeneratorIsShellOperator(const std::string& str) static bool cmLocalGeneratorIsShellOperator(const std::string& str)
{ {
@ -3456,7 +3453,7 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
// Compute the flags for the target shell environment. // Compute the flags for the target shell environment.
int flags = 0; int flags = 0;
if(this->WindowsVSIDE) if(this->GlobalGenerator->WindowsVSIDE)
{ {
flags |= cmsysSystem_Shell_Flag_VSIDE; flags |= cmsysSystem_Shell_Flag_VSIDE;
} }
@ -3476,27 +3473,27 @@ std::string cmLocalGenerator::EscapeForShell(const std::string& str,
{ {
flags |= cmsysSystem_Shell_Flag_WatcomQuote; flags |= cmsysSystem_Shell_Flag_WatcomQuote;
} }
if(this->WatcomWMake) if(this->GlobalGenerator->WatcomWMake)
{ {
flags |= cmsysSystem_Shell_Flag_WatcomWMake; flags |= cmsysSystem_Shell_Flag_WatcomWMake;
} }
if(this->MinGWMake) if(this->GlobalGenerator->MinGWMake)
{ {
flags |= cmsysSystem_Shell_Flag_MinGWMake; flags |= cmsysSystem_Shell_Flag_MinGWMake;
} }
if(this->NMake) if(this->GlobalGenerator->NMake)
{ {
flags |= cmsysSystem_Shell_Flag_NMake; flags |= cmsysSystem_Shell_Flag_NMake;
} }
// Compute the buffer size needed. // Compute the buffer size needed.
int size = (this->WindowsShell ? int size = (this->GlobalGenerator->WindowsShell ?
cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) : cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) :
cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags)); cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags));
// Compute the shell argument itself. // Compute the shell argument itself.
std::vector<char> arg(size); std::vector<char> arg(size);
if(this->WindowsShell) if(this->GlobalGenerator->WindowsShell)
{ {
cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags); cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags);
} }

View File

@ -13,6 +13,7 @@
#define cmLocalGenerator_h #define cmLocalGenerator_h
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmState.h"
class cmMakefile; class cmMakefile;
class cmGlobalGenerator; class cmGlobalGenerator;
@ -33,9 +34,12 @@ class cmCustomCommandGenerator;
class cmLocalGenerator class cmLocalGenerator
{ {
public: public:
cmLocalGenerator(cmLocalGenerator* parent); cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
virtual ~cmLocalGenerator(); virtual ~cmLocalGenerator();
/// @return whether we are processing the top CMakeLists.txt file.
bool IsRootMakefile() const;
/** /**
* Generate the makefile for this directory. * Generate the makefile for this directory.
*/ */
@ -88,8 +92,8 @@ public:
const cmGlobalGenerator *GetGlobalGenerator() const { const cmGlobalGenerator *GetGlobalGenerator() const {
return this->GlobalGenerator; } return this->GlobalGenerator; }
///! Set the Global Generator, done on creation by the GlobalGenerator cmState* GetState() const;
void SetGlobalGenerator(cmGlobalGenerator *gg); cmState::Snapshot GetStateSnapshot() const;
/** /**
* Convert something to something else. This is a centralized conversion * Convert something to something else. This is a centralized conversion
@ -298,9 +302,6 @@ public:
bool forEcho = false, bool forEcho = false,
bool useWatcomQuote = false); bool useWatcomQuote = false);
/** Backwards-compatibility version of EscapeForShell. */
std::string EscapeForShellOldStyle(const std::string& str);
/** Escape the given string as an argument in a CMake script. */ /** Escape the given string as an argument in a CMake script. */
static std::string EscapeForCMake(const std::string& str); static std::string EscapeForCMake(const std::string& str);
@ -385,6 +386,13 @@ public:
std::map<cmSourceFile const*, std::string>& mapping, std::map<cmSourceFile const*, std::string>& mapping,
cmGeneratorTarget const* gt = 0); cmGeneratorTarget const* gt = 0);
bool IsWindowsShell() const;
bool IsWatcomWMake() const;
bool IsMinGWMake() const;
bool IsNMake() const;
void SetConfiguredCMP0014(bool configured);
protected: protected:
///! put all the libraries for a target on into the given stream ///! put all the libraries for a target on into the given stream
virtual void OutputLinkLibraries(std::string& linkLibraries, virtual void OutputLinkLibraries(std::string& linkLibraries,
@ -448,10 +456,8 @@ protected:
void ReadInputFile(); void ReadInputFile();
cmMakefile *Makefile; cmMakefile *Makefile;
cmState::Snapshot StateSnapshot;
cmGlobalGenerator *GlobalGenerator; cmGlobalGenerator *GlobalGenerator;
// members used for relative path function ConvertToMakefilePath
std::string RelativePathToSourceDir;
std::string RelativePathToBinaryDir;
std::vector<std::string> HomeDirectoryComponents; std::vector<std::string> HomeDirectoryComponents;
std::vector<std::string> StartDirectoryComponents; std::vector<std::string> StartDirectoryComponents;
std::vector<std::string> HomeOutputDirectoryComponents; std::vector<std::string> HomeOutputDirectoryComponents;
@ -461,18 +467,13 @@ protected:
std::map<std::string, std::string> UniqueObjectNamesMap; std::map<std::string, std::string> UniqueObjectNamesMap;
std::string::size_type ObjectPathMax; std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations; std::set<std::string> ObjectMaxPathViolations;
bool WindowsShell;
bool WindowsVSIDE;
bool WatcomWMake;
bool MinGWMake;
bool NMake;
bool ForceUnixPath;
bool MSYSShell;
bool LinkScriptShell; bool LinkScriptShell;
bool UseRelativePaths; bool UseRelativePaths;
bool IgnoreLibPrefix; bool IgnoreLibPrefix;
bool Configured; bool Configured;
bool EmitUniversalBinaryFlags; bool EmitUniversalBinaryFlags;
// Hack for ExpandRuleVariable until object-oriented version is // Hack for ExpandRuleVariable until object-oriented version is
// committed. // committed.
std::string TargetImplib; std::string TargetImplib;

View File

@ -16,8 +16,9 @@
#include "cmGhsMultiTargetGenerator.h" #include "cmGhsMultiTargetGenerator.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmLocalGenerator* parent) cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
: cmLocalGenerator(parent) cmLocalGenerator* parent)
: cmLocalGenerator(gg, parent)
{ {
} }

View File

@ -25,7 +25,7 @@ class cmGeneratedFileStream;
class cmLocalGhsMultiGenerator : public cmLocalGenerator class cmLocalGhsMultiGenerator : public cmLocalGenerator
{ {
public: public:
cmLocalGhsMultiGenerator(cmLocalGenerator* parent); cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
virtual ~cmLocalGhsMultiGenerator(); virtual ~cmLocalGhsMultiGenerator();

View File

@ -22,14 +22,12 @@
#include <assert.h> #include <assert.h>
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmLocalGenerator* parent) cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
: cmLocalGenerator(parent) cmLocalGenerator* parent)
: cmLocalGenerator(gg, parent)
, ConfigName("") , ConfigName("")
, HomeRelativeOutputPath("") , HomeRelativeOutputPath("")
{ {
#ifdef _WIN32
this->WindowsShell = true;
#endif
this->TargetImplib = "$TARGET_IMPLIB"; this->TargetImplib = "$TARGET_IMPLIB";
} }
@ -50,7 +48,7 @@ void cmLocalNinjaGenerator::Generate()
#endif #endif
// We do that only once for the top CMakeLists.txt file. // We do that only once for the top CMakeLists.txt file.
if(this->isRootMakefile()) if(this->IsRootMakefile())
{ {
this->WriteBuildFileTop(); this->WriteBuildFileTop();
@ -181,11 +179,6 @@ cmake* cmLocalNinjaGenerator::GetCMakeInstance()
return this->GetGlobalGenerator()->GetCMakeInstance(); return this->GetGlobalGenerator()->GetCMakeInstance();
} }
bool cmLocalNinjaGenerator::isRootMakefile() const
{
return !this->GetParent();
}
void cmLocalNinjaGenerator::WriteBuildFileTop() void cmLocalNinjaGenerator::WriteBuildFileTop()
{ {
// For the build file. // For the build file.
@ -314,7 +307,7 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
<< "# Write statements declared in CMakeLists.txt:" << std::endl << "# Write statements declared in CMakeLists.txt:" << std::endl
<< "# " << this->Makefile->GetCurrentListFile() << std::endl << "# " << this->Makefile->GetCurrentListFile() << std::endl
; ;
if(this->isRootMakefile()) if(this->IsRootMakefile())
os << "# Which is the root file." << std::endl; os << "# Which is the root file." << std::endl;
cmGlobalNinjaGenerator::WriteDivider(os); cmGlobalNinjaGenerator::WriteDivider(os);
os << std::endl; os << std::endl;

View File

@ -32,7 +32,7 @@ class cmLocalNinjaGenerator : public cmLocalGenerator
{ {
public: public:
/// Default constructor. /// Default constructor.
cmLocalNinjaGenerator(cmLocalGenerator* parent); cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
/// Destructor. /// Destructor.
virtual ~cmLocalNinjaGenerator(); virtual ~cmLocalNinjaGenerator();
@ -59,9 +59,6 @@ public:
std::string const& GetConfigName() const std::string const& GetConfigName() const
{ return this->ConfigName; } { return this->ConfigName; }
/// @return whether we are processing the top CMakeLists.txt file.
bool isRootMakefile() const;
/// @returns the relative path between the HomeOutputDirectory and this /// @returns the relative path between the HomeOutputDirectory and this
/// local generators StartOutputDirectory. /// local generators StartOutputDirectory.
std::string GetHomeRelativeOutputPath() const std::string GetHomeRelativeOutputPath() const

View File

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

View File

@ -34,7 +34,8 @@ class cmSourceFile;
class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator
{ {
public: public:
cmLocalUnixMakefileGenerator3(cmLocalGenerator* parent); cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg,
cmLocalGenerator* parent);
virtual ~cmLocalUnixMakefileGenerator3(); virtual ~cmLocalUnixMakefileGenerator3();
/** /**
@ -79,36 +80,6 @@ public:
void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; } void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; }
std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; } 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. * If set to true, then NULL is set to nil for non Windows_NT.
* This uses make syntax used by nmake and borland. * This uses make syntax used by nmake and borland.

View File

@ -62,8 +62,9 @@ class cmVS10XMLParser : public cmXMLParser
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudio10Generator cmLocalVisualStudio10Generator
::cmLocalVisualStudio10Generator(VSVersion v, cmLocalGenerator* parent): ::cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg,
cmLocalVisualStudio7Generator(v, parent) cmLocalGenerator* parent):
cmLocalVisualStudio7Generator(v, gg, parent)
{ {
} }

View File

@ -25,7 +25,8 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio10Generator(VSVersion v, cmLocalGenerator* parent); cmLocalVisualStudio10Generator(VSVersion v, cmGlobalGenerator* gg,
cmLocalGenerator* parent);
virtual ~cmLocalVisualStudio10Generator(); virtual ~cmLocalVisualStudio10Generator();

View File

@ -24,8 +24,9 @@
#include <cmsys/FStream.hxx> #include <cmsys/FStream.hxx>
cmLocalVisualStudio6Generator cmLocalVisualStudio6Generator
::cmLocalVisualStudio6Generator(cmLocalGenerator* parent): ::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
cmLocalVisualStudioGenerator(VS6, parent) cmLocalGenerator* parent):
cmLocalVisualStudioGenerator(VS6, gg, parent)
{ {
} }

View File

@ -29,7 +29,8 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio6Generator(cmLocalGenerator* parent); cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
cmLocalGenerator* parent);
virtual ~cmLocalVisualStudio6Generator(); virtual ~cmLocalVisualStudio6Generator();

View File

@ -55,8 +55,9 @@ static void cmConvertToWindowsSlash(std::string& s)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudio7Generator cmLocalVisualStudio7Generator
::cmLocalVisualStudio7Generator(VSVersion v, cmLocalGenerator* parent): ::cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg,
cmLocalVisualStudioGenerator(v, parent) cmLocalGenerator* parent):
cmLocalVisualStudioGenerator(v, gg, parent)
{ {
this->ExtraFlagTable = 0; this->ExtraFlagTable = 0;
this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);

View File

@ -35,7 +35,8 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalVisualStudio7Generator(VSVersion v, cmLocalGenerator* parent); cmLocalVisualStudio7Generator(VSVersion v, cmGlobalGenerator* gg,
cmLocalGenerator* parent);
virtual ~cmLocalVisualStudio7Generator(); virtual ~cmLocalVisualStudio7Generator();

View File

@ -19,11 +19,10 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudioGenerator cmLocalVisualStudioGenerator
::cmLocalVisualStudioGenerator(VSVersion v, cmLocalGenerator* parent) ::cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg,
: cmLocalGenerator(parent) cmLocalGenerator* parent)
: cmLocalGenerator(gg, parent)
{ {
this->WindowsShell = true;
this->WindowsVSIDE = true;
this->Version = v; this->Version = v;
} }

View File

@ -45,7 +45,8 @@ public:
VS14 = 140 VS14 = 140
}; };
cmLocalVisualStudioGenerator(VSVersion v, cmLocalGenerator* parent); cmLocalVisualStudioGenerator(VSVersion v, cmGlobalGenerator* gg,
cmLocalGenerator* parent);
virtual ~cmLocalVisualStudioGenerator(); virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */ /** Construct a script from the given list of command lines. */

View File

@ -15,8 +15,9 @@
#include "cmMakefile.h" #include "cmMakefile.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmLocalGenerator* parent) cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
: cmLocalGenerator(parent) cmLocalGenerator* parent)
: cmLocalGenerator(gg, parent)
{ {
// the global generator does this, so do not // the global generator does this, so do not
// put these flags into the language flags // put these flags into the language flags

View File

@ -24,7 +24,7 @@ class cmLocalXCodeGenerator : public cmLocalGenerator
{ {
public: public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmLocalXCodeGenerator(cmLocalGenerator* parent); cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent);
virtual ~cmLocalXCodeGenerator(); virtual ~cmLocalXCodeGenerator();
virtual std::string GetTargetDirectory(cmTarget const& target) const; virtual std::string GetTargetDirectory(cmTarget const& target) const;

View File

@ -153,27 +153,13 @@ public:
cmMakefile::cmMakefile(cmLocalGenerator* localGenerator) cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
: Internal(new Internals), : Internal(new Internals),
LocalGenerator(localGenerator), LocalGenerator(localGenerator),
StateSnapshot(localGenerator->GetGlobalGenerator() StateSnapshot(localGenerator->GetStateSnapshot())
->GetCMakeInstance()->GetState())
{ {
this->Internal->PushDefinitions(); this->Internal->PushDefinitions();
this->Internal->VarInitStack.push(std::set<std::string>()); this->Internal->VarInitStack.push(std::set<std::string>());
this->Internal->VarUsageStack.push(std::set<std::string>()); this->Internal->VarUsageStack.push(std::set<std::string>());
this->Internal->IsSourceFileTryCompile = false; this->Internal->IsSourceFileTryCompile = false;
if (this->LocalGenerator->GetParent())
{
cmMakefile* parentMf = this->LocalGenerator->GetParent()->GetMakefile();
this->StateSnapshot =
this->GetState()->CreateSnapshot(parentMf->StateSnapshot);
}
else
{
this->StateSnapshot =
this->GetState()->CreateSnapshot(this->StateSnapshot);
}
// Initialize these first since AddDefaultDefinitions calls AddDefinition // Initialize these first since AddDefaultDefinitions calls AddDefinition
this->WarnUnused = false; this->WarnUnused = false;
this->CheckSystemVars = false; this->CheckSystemVars = false;
@ -212,7 +198,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
this->HeaderFileExtensions.push_back( "txx" ); this->HeaderFileExtensions.push_back( "txx" );
this->DefineFlags = " "; this->DefineFlags = " ";
this->LocalGenerator = localGenerator;
this->AddDefaultDefinitions(); this->AddDefaultDefinitions();
@ -1657,12 +1642,47 @@ void cmMakefile::InitializeFromParent()
void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2) void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
{ {
lg2->GetMakefile()->InitializeFromParent(); lg2->GetMakefile()->InitializeFromParent();
std::string currentStart = lg2->GetMakefile()->GetCurrentSourceDirectory();
if (this->GetCMakeInstance()->GetDebugOutput()) if (this->GetCMakeInstance()->GetDebugOutput())
{ {
std::string msg=" Entering "; std::string msg=" Entering ";
msg += lg2->GetMakefile()->GetCurrentSourceDirectory(); msg += currentStart;
cmSystemTools::Message(msg.c_str()); cmSystemTools::Message(msg.c_str());
} }
currentStart += "/CMakeLists.txt";
if(!cmSystemTools::FileExists(currentStart.c_str(), true))
{
// The file is missing. Check policy CMP0014.
std::ostringstream e;
e << "The source directory\n"
<< " " << currentStart << "\n"
<< "does not contain a CMakeLists.txt file.";
switch (this->GetPolicyStatus(cmPolicies::CMP0014))
{
case cmPolicies::WARN:
// Print the warning.
e << "\n"
<< "CMake does not support this case but it used "
<< "to work accidentally and is being allowed for "
<< "compatibility."
<< "\n"
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0014);
this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
case cmPolicies::OLD:
// OLD behavior does not warn.
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
e << "\n"
<< cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0014);
case cmPolicies::NEW:
// NEW behavior prints the error.
this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
lg2->SetConfiguredCMP0014(true);
return;
}
// finally configure the subdir // finally configure the subdir
lg2->Configure(); lg2->Configure();
if (this->GetCMakeInstance()->GetDebugOutput()) if (this->GetCMakeInstance()->GetDebugOutput())
@ -4131,11 +4151,12 @@ const char *cmMakefile::GetProperty(const std::string& prop,
output = ""; output = "";
if (prop == "PARENT_DIRECTORY") if (prop == "PARENT_DIRECTORY")
{ {
if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) cmState::Snapshot parent = this->StateSnapshot.GetParent();
if(parent.IsValid())
{ {
output = plg->GetMakefile()->GetCurrentSourceDirectory(); return parent.GetCurrentSourceDirectory();
} }
return output.c_str(); return "";
} }
else if (prop == "INCLUDE_REGULAR_EXPRESSION" ) else if (prop == "INCLUDE_REGULAR_EXPRESSION" )
{ {

View File

@ -1118,8 +1118,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
pi != this->MultipleOutputPairs.end(); ++pi) pi != this->MultipleOutputPairs.end(); ++pi)
{ {
*this->InfoFileStream *this->InfoFileStream
<< " " << this->LocalGenerator->EscapeForCMake(pi->first) << " " << cmLocalGenerator::EscapeForCMake(pi->first)
<< " " << this->LocalGenerator->EscapeForCMake(pi->second) << " " << cmLocalGenerator::EscapeForCMake(pi->second)
<< "\n"; << "\n";
} }
*this->InfoFileStream << " )\n\n"; *this->InfoFileStream << " )\n\n";

View File

@ -53,7 +53,7 @@ bool cmProjectCommand
// CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build // CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
// will work. // will work.
if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME")
|| (this->Makefile->GetLocalGenerator()->GetParent() == 0) ) || (this->Makefile->GetLocalGenerator()->IsRootMakefile()))
{ {
this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str()); this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
this->Makefile->AddCacheDefinition this->Makefile->AddCacheDefinition

View File

@ -522,3 +522,24 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
cmSystemTools::CollapseFullPath( cmSystemTools::CollapseFullPath(
this->State->OutputLocations[this->Position]); this->State->OutputLocations[this->Position]);
} }
bool cmState::Snapshot::IsValid() const
{
return this->State ? true : false;
}
cmState::Snapshot cmState::Snapshot::GetParent() const
{
Snapshot snapshot;
if (!this->State)
{
return snapshot;
}
PositionType parentPos = this->State->ParentPositions[this->Position];
if (parentPos > 0)
{
snapshot = Snapshot(this->State, parentPos);
}
return snapshot;
}

View File

@ -36,6 +36,9 @@ public:
const char* GetCurrentBinaryDirectory() const; const char* GetCurrentBinaryDirectory() const;
void SetCurrentBinaryDirectory(std::string const& dir); void SetCurrentBinaryDirectory(std::string const& dir);
bool IsValid() const;
Snapshot GetParent() const;
private: private:
friend class cmState; friend class cmState;
cmState* State; cmState* State;

View File

@ -82,7 +82,6 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// be translated. // be translated.
std::string exe = command[0]; std::string exe = command[0];
cmMakefile* mf = this->Test->GetMakefile(); cmMakefile* mf = this->Test->GetMakefile();
cmLocalGenerator* lg = mf->GetLocalGenerator();
cmTarget* target = mf->FindTargetToUse(exe); cmTarget* target = mf->FindTargetToUse(exe);
if(target && target->GetType() == cmTarget::EXECUTABLE) if(target && target->GetType() == cmTarget::EXECUTABLE)
{ {
@ -98,13 +97,13 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
std::string emulatorExe(emulatorWithArgs[0]); std::string emulatorExe(emulatorWithArgs[0]);
cmSystemTools::ConvertToUnixSlashes(emulatorExe); cmSystemTools::ConvertToUnixSlashes(emulatorExe);
os << lg->EscapeForCMake(emulatorExe) << " "; os << cmLocalGenerator::EscapeForCMake(emulatorExe) << " ";
for(std::vector<std::string>::const_iterator ei = for(std::vector<std::string>::const_iterator ei =
emulatorWithArgs.begin()+1; emulatorWithArgs.begin()+1;
ei != emulatorWithArgs.end(); ei != emulatorWithArgs.end();
++ei) ++ei)
{ {
os << lg->EscapeForCMake(*ei) << " "; os << cmLocalGenerator::EscapeForCMake(*ei) << " ";
} }
} }
} }
@ -116,11 +115,12 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
} }
// Generate the command line with full escapes. // Generate the command line with full escapes.
os << lg->EscapeForCMake(exe); os << cmLocalGenerator::EscapeForCMake(exe);
for(std::vector<std::string>::const_iterator ci = command.begin()+1; for(std::vector<std::string>::const_iterator ci = command.begin()+1;
ci != command.end(); ++ci) ci != command.end(); ++ci)
{ {
os << " " << lg->EscapeForCMake(ge.Parse(*ci)->Evaluate(mf, config)); os << " " << cmLocalGenerator::EscapeForCMake(
ge.Parse(*ci)->Evaluate(mf, config));
} }
// Finish the test command. // Finish the test command.
@ -136,7 +136,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
i != pm.end(); ++i) i != pm.end(); ++i)
{ {
os << " " << i->first os << " " << i->first
<< " " << lg->EscapeForCMake( << " " << cmLocalGenerator::EscapeForCMake(
ge.Parse(i->second.GetValue())->Evaluate(mf, config)); ge.Parse(i->second.GetValue())->Evaluate(mf, config));
} }
os << ")" << std::endl; os << ")" << std::endl;
@ -197,8 +197,6 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout,
fout << ")" << std::endl; fout << ")" << std::endl;
// Output properties for the test. // Output properties for the test.
cmMakefile* mf = this->Test->GetMakefile();
cmLocalGenerator* lg = mf->GetLocalGenerator();
cmPropertyMap& pm = this->Test->GetProperties(); cmPropertyMap& pm = this->Test->GetProperties();
if(!pm.empty()) if(!pm.empty())
{ {
@ -208,7 +206,7 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout,
i != pm.end(); ++i) i != pm.end(); ++i)
{ {
fout << " " << i->first fout << " " << i->first
<< " " << lg->EscapeForCMake(i->second.GetValue()); << " " << cmLocalGenerator::EscapeForCMake(i->second.GetValue());
} }
fout << ")" << std::endl; fout << ")" << std::endl;
} }

View File

@ -0,0 +1,4 @@
^CMake Error at CTestTestfile.cmake:[0-9]+ \(subdirs\):
subdirs called with incorrect number of arguments
+
No tests were found!!!$

View File

@ -26,3 +26,16 @@ function(run_repeat_until_fail_tests)
) )
endfunction() endfunction()
run_repeat_until_fail_tests() run_repeat_until_fail_tests()
function(run_BadCTestTestfile)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BadCTestTestfile)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
subdirs()
")
run_cmake_command(BadCTestTestfile ${CMAKE_CTEST_COMMAND})
endfunction()
run_BadCTestTestfile()