Set the current dirs on the snapshot before creating the cmMakefile.
The cmMakefile should get a fully prepared snapshot and not clobber its definitions. It should eventually be able to process list files from any starting-point snapshot, though that is some refactoring away still.
This commit is contained in:
parent
f716460ed8
commit
360e4e1db0
|
@ -318,16 +318,13 @@ void cmCTestScriptHandler::CreateCMake()
|
|||
this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
|
||||
|
||||
cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
|
||||
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
||||
snapshot.GetDirectory().SetCurrentSource(cwd);
|
||||
snapshot.GetDirectory().SetCurrentBinary(cwd);
|
||||
this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
|
||||
|
||||
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
|
||||
|
||||
// Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR.
|
||||
// Also, some commands need Makefile->GetCurrentSourceDirectory().
|
||||
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
||||
this->Makefile->SetCurrentSourceDirectory(cwd);
|
||||
this->Makefile->SetCurrentBinaryDirectory(cwd);
|
||||
|
||||
// remove all cmake commands which are not scriptable, since they can't be
|
||||
// used in ctest scripts
|
||||
this->CMake->GetState()->RemoveUnscriptableCommands();
|
||||
|
|
|
@ -1108,16 +1108,16 @@ void cmGlobalGenerator::Configure()
|
|||
this->FirstTimeProgress = 0.0f;
|
||||
this->ClearGeneratorMembers();
|
||||
|
||||
cmMakefile* dirMf =
|
||||
new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot());
|
||||
this->Makefiles.push_back(dirMf);
|
||||
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
|
||||
|
||||
// set the Start directories
|
||||
dirMf->SetCurrentSourceDirectory
|
||||
snapshot.GetDirectory().SetCurrentSource
|
||||
(this->CMakeInstance->GetHomeDirectory());
|
||||
dirMf->SetCurrentBinaryDirectory
|
||||
snapshot.GetDirectory().SetCurrentBinary
|
||||
(this->CMakeInstance->GetHomeOutputDirectory());
|
||||
|
||||
cmMakefile* dirMf = new cmMakefile(this, snapshot);
|
||||
this->Makefiles.push_back(dirMf);
|
||||
|
||||
this->BinaryDirectories.insert(
|
||||
this->CMakeInstance->GetHomeOutputDirectory());
|
||||
|
||||
|
|
|
@ -585,12 +585,11 @@ void cmGlobalUnixMakefileGenerator3
|
|||
else
|
||||
{
|
||||
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
|
||||
mf = new cmMakefile(this, snapshot);
|
||||
// set the Start directories
|
||||
mf->SetCurrentSourceDirectory
|
||||
snapshot.GetDirectory().SetCurrentSource
|
||||
(this->CMakeInstance->GetHomeDirectory());
|
||||
mf->SetCurrentBinaryDirectory
|
||||
snapshot.GetDirectory().SetCurrentBinary
|
||||
(this->CMakeInstance->GetHomeOutputDirectory());
|
||||
mf = new cmMakefile(this, snapshot);
|
||||
}
|
||||
|
||||
std::string tname = targetName;
|
||||
|
|
|
@ -120,15 +120,34 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
|
|||
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
||||
#endif
|
||||
|
||||
this->AddDefinition("CMAKE_SOURCE_DIR",
|
||||
this->GetCMakeInstance()->GetHomeDirectory());
|
||||
this->AddDefinition("CMAKE_BINARY_DIR",
|
||||
this->GetCMakeInstance()->GetHomeOutputDirectory());
|
||||
{
|
||||
const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
|
||||
this->AddDefinition("CMAKE_SOURCE_DIR", dir);
|
||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
|
||||
const char* dir = this->StateSnapshot.GetDirectory().GetCurrentSource();
|
||||
if (dir)
|
||||
{
|
||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
||||
this->GetCMakeInstance()->GetHomeDirectory());
|
||||
}
|
||||
}
|
||||
{
|
||||
const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
||||
this->AddDefinition("CMAKE_BINARY_DIR", dir);
|
||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
|
||||
const char* dir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
||||
if (dir)
|
||||
{
|
||||
cmSystemTools::MakeDirectory(dir);
|
||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
|
||||
this->GetCMakeInstance()->GetHomeOutputDirectory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1472,11 +1491,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib)
|
|||
|
||||
void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
||||
{
|
||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
||||
this->GetCurrentSourceDirectory());
|
||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
|
||||
this->GetCurrentBinaryDirectory());
|
||||
|
||||
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
||||
|
||||
// define flags
|
||||
|
@ -1747,15 +1761,14 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
|
|||
this->ContextStack.back()->Name,
|
||||
this->ContextStack.back()->Line);
|
||||
|
||||
newSnapshot.InitializeFromParent();
|
||||
|
||||
newSnapshot.GetDirectory().SetCurrentSource(srcPath);
|
||||
newSnapshot.GetDirectory().SetCurrentBinary(binPath);
|
||||
|
||||
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
|
||||
this->GetGlobalGenerator()->AddMakefile(subMf);
|
||||
|
||||
// set the subdirs start dirs
|
||||
subMf->SetCurrentSourceDirectory(srcPath);
|
||||
subMf->SetCurrentBinaryDirectory(binPath);
|
||||
|
||||
subMf->StateSnapshot.InitializeFromParent();
|
||||
|
||||
if(excludeFromAll)
|
||||
{
|
||||
subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
||||
|
|
|
@ -178,9 +178,10 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
|
|||
cmGlobalGenerator gg(&cm);
|
||||
|
||||
cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
|
||||
snapshot.GetDirectory().SetCurrentBinary(targetDirectory);
|
||||
snapshot.GetDirectory().SetCurrentSource(targetDirectory);
|
||||
|
||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot));
|
||||
mf->SetCurrentBinaryDirectory(targetDirectory);
|
||||
mf->SetCurrentSourceDirectory(targetDirectory);
|
||||
gg.SetCurrentMakefile(mf.get());
|
||||
|
||||
this->ReadAutogenInfoFile(mf.get(), targetDirectory, config);
|
||||
|
|
|
@ -377,11 +377,11 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
|
|||
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
||||
snapshot.GetDirectory().SetCurrentBinary
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
snapshot.GetDirectory().SetCurrentSource
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
|
||||
mf->SetCurrentBinaryDirectory
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
mf->SetCurrentSourceDirectory
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
if (this->GetWorkingMode() != NORMAL_MODE)
|
||||
{
|
||||
std::string file(cmSystemTools::CollapseFullPath(path));
|
||||
|
@ -418,13 +418,13 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
|
|||
this->SetGlobalGenerator(gg);
|
||||
|
||||
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
||||
snapshot.GetDirectory().SetCurrentBinary
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
snapshot.GetDirectory().SetCurrentSource
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
// read in the list file to fill the cache
|
||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
|
||||
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
|
||||
mf->SetCurrentBinaryDirectory
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
mf->SetCurrentSourceDirectory
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
|
||||
mf->SetArgcArgv(args);
|
||||
|
||||
|
|
|
@ -769,11 +769,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
|||
{
|
||||
cm.SetGlobalGenerator(ggd);
|
||||
cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
|
||||
snapshot.GetDirectory().SetCurrentBinary
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
snapshot.GetDirectory().SetCurrentSource
|
||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
|
||||
cmsys::auto_ptr<cmLocalGenerator> lgd(
|
||||
ggd->CreateLocalGenerator(mf.get()));
|
||||
lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
|
||||
lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);
|
||||
|
||||
// Actually scan dependencies.
|
||||
return lgd->UpdateDependencies(depInfo.c_str(),
|
||||
|
|
Loading…
Reference in New Issue