cmMakefile: Require the localGenerator in the constructor.

Move the contents of cmMakeile::SetLocalGenerator to the Initialize
method.
This commit is contained in:
Stephen Kelly 2015-04-27 22:38:45 +02:00
parent a48aebcb67
commit 86f3cd0f7e
3 changed files with 38 additions and 52 deletions

View File

@ -253,8 +253,7 @@ void cmLocalGenerator::SetupPathConversions()
void cmLocalGenerator::SetGlobalGenerator(cmGlobalGenerator *gg) void cmLocalGenerator::SetGlobalGenerator(cmGlobalGenerator *gg)
{ {
this->GlobalGenerator = gg; this->GlobalGenerator = gg;
this->Makefile = new cmMakefile; this->Makefile = new cmMakefile(this);
this->Makefile->SetLocalGenerator(this);
} }
void cmLocalGenerator::ConfigureFinalPass() void cmLocalGenerator::ConfigureFinalPass()

View File

@ -53,7 +53,8 @@ public:
}; };
// default is not to be building executables // default is not to be building executables
cmMakefile::cmMakefile(): Internal(new Internals) cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
: Internal(new Internals)
{ {
const cmDefinitions& defs = cmDefinitions(); const cmDefinitions& defs = cmDefinitions();
const std::set<std::string> globalKeys = defs.LocalKeys(); const std::set<std::string> globalKeys = defs.LocalKeys();
@ -97,7 +98,7 @@ cmMakefile::cmMakefile(): Internal(new Internals)
this->HeaderFileExtensions.push_back( "txx" ); this->HeaderFileExtensions.push_back( "txx" );
this->DefineFlags = " "; this->DefineFlags = " ";
this->LocalGenerator = 0; this->LocalGenerator = localGenerator;
this->AddDefaultDefinitions(); this->AddDefaultDefinitions();
this->Initialize(); this->Initialize();
@ -126,6 +127,39 @@ void cmMakefile::Initialize()
// By default the check is not done. It is enabled by // By default the check is not done. It is enabled by
// cmListFileCache in the top level if necessary. // cmListFileCache in the top level if necessary.
this->CheckCMP0000 = false; this->CheckCMP0000 = false;
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->AddSourceGroup("", "^.*$");
this->AddSourceGroup
("Source Files",
"\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp"
"|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
this->AddSourceGroup("Header Files", CM_HEADER_REGEX);
this->AddSourceGroup("CMake Rules", "\\.rule$");
this->AddSourceGroup("Resources", "\\.plist$");
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
#endif
this->Properties.SetCMakeInstance(this->GetCMakeInstance());
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
{
const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
this->AddDefinition("CMAKE_SOURCE_DIR", dir);
if ( !this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR") )
{
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
}
}
{
const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory();
this->AddDefinition("CMAKE_BINARY_DIR", dir);
if ( !this->GetDefinition("CMAKE_CURRENT_BINARY_DIR") )
{
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
}
}
} }
cmMakefile::~cmMakefile() cmMakefile::~cmMakefile()
@ -630,46 +664,6 @@ void cmMakefile::EnforceDirectoryLevelRules() const
} }
} }
// Set the make file
void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
{
this->LocalGenerator = lg;
// the source groups need to access the global generator
// so don't create them until the lg is set
#if defined(CMAKE_BUILD_WITH_CMAKE)
this->AddSourceGroup("", "^.*$");
this->AddSourceGroup
("Source Files",
"\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp"
"|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
this->AddSourceGroup("Header Files", CM_HEADER_REGEX);
this->AddSourceGroup("CMake Rules", "\\.rule$");
this->AddSourceGroup("Resources", "\\.plist$");
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
#endif
this->Properties.SetCMakeInstance(this->GetCMakeInstance());
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
{
const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
this->AddDefinition("CMAKE_SOURCE_DIR", dir);
if ( !this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR") )
{
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
}
}
{
const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory();
this->AddDefinition("CMAKE_BINARY_DIR", dir);
if ( !this->GetDefinition("CMAKE_CURRENT_BINARY_DIR") )
{
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
}
}
}
namespace namespace
{ {
struct file_not_persistent struct file_not_persistent

View File

@ -74,7 +74,7 @@ public:
/** /**
* Construct an empty makefile. * Construct an empty makefile.
*/ */
cmMakefile(); cmMakefile(cmLocalGenerator* localGenerator);
/** /**
* Destructor. * Destructor.
@ -138,13 +138,6 @@ public:
bool GetIsSourceFileTryCompile() const; bool GetIsSourceFileTryCompile() const;
/**
* Specify the makefile generator. This is platform/compiler
* dependent, although the interface is through a generic
* superclass.
*/
void SetLocalGenerator(cmLocalGenerator*);
///! Get the current makefile generator. ///! Get the current makefile generator.
cmLocalGenerator* GetLocalGenerator() const cmLocalGenerator* GetLocalGenerator() const
{ return this->LocalGenerator;} { return this->LocalGenerator;}