cmLocalGenerator: Add Home directory accessors.

Reduce reasons for cmLocalGenerator to have a cmMakefile.
This commit is contained in:
Stephen Kelly 2015-10-07 01:17:48 +02:00
parent 72efa15dc2
commit 12cb3bdce4
23 changed files with 94 additions and 82 deletions

View File

@ -1975,8 +1975,9 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
else if(use_link_rpath) else if(use_link_rpath)
{ {
// Do not add any path inside the source or build tree. // Do not add any path inside the source or build tree.
const char* topSourceDir = this->Makefile->GetHomeDirectory(); const char* topSourceDir = this->CMakeInstance->GetHomeDirectory();
const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); const char* topBinaryDir =
this->CMakeInstance->GetHomeOutputDirectory();
if(!cmSystemTools::ComparePath(*ri, topSourceDir) && if(!cmSystemTools::ComparePath(*ri, topSourceDir) &&
!cmSystemTools::ComparePath(*ri, topBinaryDir) && !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
!cmSystemTools::IsSubDirectory(*ri, topSourceDir) && !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&

View File

@ -245,8 +245,10 @@ static bool checkInterfaceDirs(const std::string &prepro,
{ {
const char* installDir = const char* installDir =
target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
const char* topSourceDir = target->Makefile->GetHomeDirectory(); const char* topSourceDir =
const char* topBinaryDir = target->Makefile->GetHomeOutputDirectory(); target->GetLocalGenerator()->GetSourceDirectory();
const char* topBinaryDir =
target->GetLocalGenerator()->GetBinaryDirectory();
std::vector<std::string> parts; std::vector<std::string> parts;
cmGeneratorExpression::Split(prepro, parts); cmGeneratorExpression::Split(prepro, parts);

View File

@ -273,7 +273,7 @@ void cmExtraCodeBlocksGenerator
} }
const std::string &relative = cmSystemTools::RelativePath( const std::string &relative = cmSystemTools::RelativePath(
it->second[0]->GetMakefile()->GetHomeDirectory(), it->second[0]->GetSourceDirectory(),
jt->c_str()); jt->c_str());
std::vector<std::string> splitted; std::vector<std::string> splitted;
cmSystemTools::SplitPath(relative, splitted, false); cmSystemTools::SplitPath(relative, splitted, false);
@ -297,7 +297,7 @@ void cmExtraCodeBlocksGenerator
tree.BuildVirtualFolder(virtualFolders); tree.BuildVirtualFolder(virtualFolders);
// And one for <Unit> // And one for <Unit>
std::string unitFiles; std::string unitFiles;
tree.BuildUnit(unitFiles, std::string(mf->GetHomeDirectory()) + "/"); tree.BuildUnit(unitFiles, std::string(lgs[0]->GetSourceDirectory()) + "/");
// figure out the compiler // figure out the compiler
std::string compiler = this->GetCBCompilerId(mf); std::string compiler = this->GetCBCompilerId(mf);
@ -332,7 +332,7 @@ void cmExtraCodeBlocksGenerator
// Only add the global targets from CMAKE_BINARY_DIR, // Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs // not from the subdirs
if (strcmp(makefile->GetCurrentBinaryDirectory(), if (strcmp(makefile->GetCurrentBinaryDirectory(),
makefile->GetHomeOutputDirectory())==0) (*lg)->GetBinaryDirectory())==0)
{ {
this->AppendTarget(fout, ti->first, 0, this->AppendTarget(fout, ti->first, 0,
make.c_str(), *lg, compiler.c_str()); make.c_str(), *lg, compiler.c_str());

View File

@ -69,11 +69,11 @@ void cmExtraCodeLiteGenerator::Generate()
this->ConfigName = GetConfigurationName( mf ); this->ConfigName = GetConfigurationName( mf );
if (strcmp(mf->GetCurrentBinaryDirectory(), if (strcmp(mf->GetCurrentBinaryDirectory(),
mf->GetHomeOutputDirectory()) == 0) it->second[0]->GetBinaryDirectory()) == 0)
{ {
workspaceOutputDir = mf->GetCurrentBinaryDirectory(); workspaceOutputDir = mf->GetCurrentBinaryDirectory();
workspaceProjectName = it->second[0]->GetProjectName(); workspaceProjectName = it->second[0]->GetProjectName();
workspaceSourcePath = mf->GetHomeDirectory(); workspaceSourcePath = it->second[0]->GetSourceDirectory();
workspaceFileName = workspaceOutputDir+"/"; workspaceFileName = workspaceOutputDir+"/";
workspaceFileName += workspaceProjectName + ".workspace"; workspaceFileName += workspaceProjectName + ".workspace";
this->WorkspacePath = mf->GetCurrentBinaryDirectory();; this->WorkspacePath = mf->GetCurrentBinaryDirectory();;

View File

@ -79,8 +79,8 @@ void cmExtraEclipseCDT4Generator
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::Generate() void cmExtraEclipseCDT4Generator::Generate()
{ {
const cmMakefile* mf cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); const cmMakefile* mf = lg->GetMakefile();
std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION"); std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION");
cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*"); cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*");
@ -106,8 +106,8 @@ void cmExtraEclipseCDT4Generator::Generate()
} }
// TODO: Decide if these are local or member variables // TODO: Decide if these are local or member variables
this->HomeDirectory = mf->GetHomeDirectory(); this->HomeDirectory = lg->GetSourceDirectory();
this->HomeOutputDirectory = mf->GetHomeOutputDirectory(); this->HomeOutputDirectory = lg->GetBinaryDirectory();
this->GenerateLinkedResources = mf->IsOn( this->GenerateLinkedResources = mf->IsOn(
"CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES"); "CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES");
@ -226,7 +226,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmState::STRING, cacheEntryName.c_str(), cmState::STRING,
true); true);
mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
} }
else if (envVarValue==0 && cacheValue!=0) else if (envVarValue==0 && cacheValue!=0)
{ {
@ -247,7 +247,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmState::STRING, cacheEntryName.c_str(), cmState::STRING,
true); true);
mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
} }
} }
@ -1091,7 +1091,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
virtDir += prefix; virtDir += prefix;
virtDir += ti->first; virtDir += ti->first;
std::string buildArgs = "-C \""; std::string buildArgs = "-C \"";
buildArgs += makefile->GetHomeOutputDirectory(); buildArgs += (*it)->GetBinaryDirectory();
buildArgs += "\" "; buildArgs += "\" ";
buildArgs += makeArgs; buildArgs += makeArgs;
this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "", this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "",

View File

@ -50,7 +50,7 @@ void cmExtraKateGenerator::Generate()
const cmMakefile* mf = lg->GetMakefile(); const cmMakefile* mf = lg->GetMakefile();
this->ProjectName = this->GenerateProjectName(lg->GetProjectName(), this->ProjectName = this->GenerateProjectName(lg->GetProjectName(),
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
this->GetPathBasename(mf->GetHomeOutputDirectory())); this->GetPathBasename(lg->GetBinaryDirectory()));
this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja"); this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja");
this->CreateKateProjectFile(lg); this->CreateKateProjectFile(lg);
@ -61,8 +61,7 @@ void cmExtraKateGenerator::Generate()
void cmExtraKateGenerator::CreateKateProjectFile( void cmExtraKateGenerator::CreateKateProjectFile(
const cmLocalGenerator* lg) const const cmLocalGenerator* lg) const
{ {
const cmMakefile* mf = lg->GetMakefile(); std::string filename = lg->GetBinaryDirectory();
std::string filename = mf->GetHomeOutputDirectory();
filename += "/.kateproject"; filename += "/.kateproject";
cmGeneratedFileStream fout(filename.c_str()); cmGeneratedFileStream fout(filename.c_str());
if (!fout) if (!fout)
@ -73,9 +72,9 @@ void cmExtraKateGenerator::CreateKateProjectFile(
fout << fout <<
"{\n" "{\n"
"\t\"name\": \"" << this->ProjectName << "\",\n" "\t\"name\": \"" << this->ProjectName << "\",\n"
"\t\"directory\": \"" << mf->GetHomeDirectory() << "\",\n" "\t\"directory\": \"" << lg->GetSourceDirectory() << "\",\n"
"\t\"files\": [ { " << this->GenerateFilesString(mf) << "} ],\n"; "\t\"files\": [ { " << this->GenerateFilesString(lg) << "} ],\n";
this->WriteTargets(mf, fout); this->WriteTargets(lg, fout);
fout << "}\n"; fout << "}\n";
} }
@ -84,15 +83,15 @@ void
cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
cmGeneratedFileStream& fout) const cmGeneratedFileStream& fout) const
{ {
cmMakefile* mf = lg->GetMakefile(); cmMakefile const* mf = lg->GetMakefile();
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
const std::string makeArgs = mf->GetSafeDefinition( const std::string makeArgs = mf->GetSafeDefinition(
"CMAKE_KATE_MAKE_ARGUMENTS"); "CMAKE_KATE_MAKE_ARGUMENTS");
const char* homeOutputDir = mf->GetHomeOutputDirectory(); const char* homeOutputDir = lg->GetBinaryDirectory();
fout << fout <<
"\t\"build\": {\n" "\t\"build\": {\n"
"\t\t\"directory\": \"" << mf->GetHomeOutputDirectory() << "\",\n" "\t\t\"directory\": \"" << lg->GetBinaryDirectory() << "\",\n"
"\t\t\"default_target\": \"all\",\n" "\t\t\"default_target\": \"all\",\n"
"\t\t\"clean_target\": \"clean\",\n"; "\t\t\"clean_target\": \"clean\",\n";
@ -123,7 +122,7 @@ cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); const cmTargets& targets = (*it)->GetMakefile()->GetTargets();
cmMakefile* makefile=(*it)->GetMakefile(); cmMakefile* makefile=(*it)->GetMakefile();
std::string currentDir = makefile->GetCurrentBinaryDirectory(); std::string currentDir = makefile->GetCurrentBinaryDirectory();
bool topLevel = (currentDir == makefile->GetHomeOutputDirectory()); bool topLevel = (currentDir == (*it)->GetBinaryDirectory());
for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti) for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti)
{ {
@ -237,8 +236,7 @@ void
cmExtraKateGenerator::CreateDummyKateProjectFile( cmExtraKateGenerator::CreateDummyKateProjectFile(
const cmLocalGenerator* lg) const const cmLocalGenerator* lg) const
{ {
cmMakefile* mf = lg->GetMakefile(); std::string filename = lg->GetBinaryDirectory();
std::string filename = mf->GetHomeOutputDirectory();
filename += "/"; filename += "/";
filename += this->ProjectName; filename += this->ProjectName;
filename += ".kateproject"; filename += ".kateproject";
@ -256,22 +254,21 @@ cmExtraKateGenerator::CreateDummyKateProjectFile(
std::string std::string
cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const
{ {
cmMakefile* mf = lg->GetMakefile(); std::string s = lg->GetSourceDirectory();
std::string s = mf->GetHomeDirectory();
s += "/.git"; s += "/.git";
if(cmSystemTools::FileExists(s.c_str())) if(cmSystemTools::FileExists(s.c_str()))
{ {
return std::string("\"git\": 1 "); return std::string("\"git\": 1 ");
} }
s = mf->GetHomeDirectory(); s = lg->GetSourceDirectory();
s += "/.svn"; s += "/.svn";
if(cmSystemTools::FileExists(s.c_str())) if(cmSystemTools::FileExists(s.c_str()))
{ {
return std::string("\"svn\": 1 "); return std::string("\"svn\": 1 ");
} }
s = mf->GetHomeDirectory(); s = lg->GetSourceDirectory();
s += "/"; s += "/";
std::set<std::string> files; std::set<std::string> files;

View File

@ -99,8 +99,8 @@ void cmExtraSublimeTextGenerator
} }
const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath( const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath(
mf->GetHomeOutputDirectory(), lgs[0]->GetBinaryDirectory(),
mf->GetHomeDirectory()); lgs[0]->GetSourceDirectory());
// Write the folder entries to the project file // Write the folder entries to the project file
fout << "{\n"; fout << "{\n";
fout << "\t\"folders\":\n\t[\n\t"; fout << "\t\"folders\":\n\t[\n\t";
@ -108,8 +108,8 @@ void cmExtraSublimeTextGenerator
{ {
fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\""; fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
const std::string &outputRelativeToSourceRoot = const std::string &outputRelativeToSourceRoot =
cmSystemTools::RelativePath(mf->GetHomeDirectory(), cmSystemTools::RelativePath(lgs[0]->GetSourceDirectory(),
mf->GetHomeOutputDirectory()); lgs[0]->GetBinaryDirectory());
if ((!outputRelativeToSourceRoot.empty()) && if ((!outputRelativeToSourceRoot.empty()) &&
((outputRelativeToSourceRoot.length() < 3) || ((outputRelativeToSourceRoot.length() < 3) ||
(outputRelativeToSourceRoot.substr(0, 3) != "../"))) (outputRelativeToSourceRoot.substr(0, 3) != "../")))
@ -173,8 +173,8 @@ void cmExtraSublimeTextGenerator::
{ {
// Only add the global targets from CMAKE_BINARY_DIR, // Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs // not from the subdirs
if (strcmp(makefile->GetCurrentBinaryDirectory(), if (strcmp((*lg)->GetCurrentBinaryDirectory(),
makefile->GetHomeOutputDirectory())==0) (*lg)->GetBinaryDirectory())==0)
{ {
this->AppendTarget(fout, ti->first, *lg, 0, this->AppendTarget(fout, ti->first, *lg, 0,
make.c_str(), makefile, compiler.c_str(), make.c_str(), makefile, compiler.c_str(),

View File

@ -68,7 +68,9 @@ cmGhsMultiTargetGenerator::GetRelBuildFilePath(const cmTarget *target)
std::string std::string
cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmTarget *target) cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmTarget *target)
{ {
return target->GetMakefile()->GetHomeOutputDirectory(); cmGeneratorTarget* gt = target->GetMakefile()->GetGlobalGenerator()
->GetGeneratorTarget(target);
return gt->GetLocalGenerator()->GetBinaryDirectory();
} }
std::string std::string
@ -450,7 +452,7 @@ void cmGhsMultiTargetGenerator::WriteSources(
cmSystemTools::ConvertToUnixSlashes(sgPath); cmSystemTools::ConvertToUnixSlashes(sgPath);
cmGlobalGhsMultiGenerator::AddFilesUpToPath( cmGlobalGhsMultiGenerator::AddFilesUpToPath(
this->GetFolderBuildStreams(), &this->FolderBuildStreams, this->GetFolderBuildStreams(), &this->FolderBuildStreams,
this->Makefile->GetHomeOutputDirectory(), sgPath, this->LocalGenerator->GetBinaryDirectory(), sgPath,
GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath); GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath);
std::string fullSourcePath((*si)->GetFullPath()); std::string fullSourcePath((*si)->GetFullPath());

View File

@ -399,7 +399,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
bool fatalError = false; bool fatalError = false;
mf->AddDefinition("RUN_CONFIGURE", true); mf->AddDefinition("RUN_CONFIGURE", true);
std::string rootBin = mf->GetHomeOutputDirectory(); std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory();
rootBin += cmake::GetCMakeFilesDirectory(); rootBin += cmake::GetCMakeFilesDirectory();
// If the configuration files path has been set, // If the configuration files path has been set,
@ -2879,10 +2879,8 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::WriteSummary() void cmGlobalGenerator::WriteSummary()
{ {
cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
// Record all target directories in a central location. // Record all target directories in a central location.
std::string fname = mf->GetHomeOutputDirectory(); std::string fname = this->CMakeInstance->GetHomeOutputDirectory();
fname += cmake::GetCMakeFilesDirectory(); fname += cmake::GetCMakeFilesDirectory();
fname += "/TargetDirectories.txt"; fname += "/TargetDirectories.txt";
cmGeneratedFileStream fout(fname.c_str()); cmGeneratedFileStream fout(fname.c_str());

View File

@ -51,7 +51,7 @@ void cmGlobalKdevelopGenerator::Generate()
{ {
cmMakefile* mf = it->second[0]->GetMakefile(); cmMakefile* mf = it->second[0]->GetMakefile();
std::string outputDir=mf->GetCurrentBinaryDirectory(); std::string outputDir=mf->GetCurrentBinaryDirectory();
std::string projectDir=mf->GetHomeDirectory(); std::string projectDir=it->second[0]->GetSourceDirectory();
std::string projectName=it->second[0]->GetProjectName(); std::string projectName=it->second[0]->GetProjectName();
std::string cmakeFilePattern("CMakeLists.txt;*.cmake;"); std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
std::string fileToOpen; std::string fileToOpen;

View File

@ -1198,16 +1198,15 @@ void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os)
void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
{ {
cmLocalGenerator *lg = this->LocalGenerators[0]; cmLocalGenerator *lg = this->LocalGenerators[0];
cmMakefile* mfRoot = lg->GetMakefile();
std::ostringstream cmd; std::ostringstream cmd;
cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(), cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
cmLocalGenerator::SHELL) cmLocalGenerator::SHELL)
<< " -H" << " -H"
<< lg->ConvertToOutputFormat(mfRoot->GetHomeDirectory(), << lg->ConvertToOutputFormat(lg->GetSourceDirectory(),
cmLocalGenerator::SHELL) cmLocalGenerator::SHELL)
<< " -B" << " -B"
<< lg->ConvertToOutputFormat(mfRoot->GetHomeOutputDirectory(), << lg->ConvertToOutputFormat(lg->GetBinaryDirectory(),
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
WriteRule(*this->RulesFileStream, WriteRule(*this->RulesFileStream,
"RERUN_CMAKE", "RERUN_CMAKE",

View File

@ -784,7 +784,7 @@ cmGlobalUnixMakefileGenerator3
depends.clear(); depends.clear();
cmLocalUnixMakefileGenerator3::EchoProgress progress; cmLocalUnixMakefileGenerator3::EchoProgress progress;
progress.Dir = lg->GetMakefile()->GetHomeOutputDirectory(); progress.Dir = lg->GetBinaryDirectory();
progress.Dir += cmake::GetCMakeFilesDirectory(); progress.Dir += cmake::GetCMakeFilesDirectory();
{ {
std::ostringstream progressArg; std::ostringstream progressArg;

View File

@ -312,10 +312,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
cmCustomCommandLine commandLine; cmCustomCommandLine commandLine;
commandLine.push_back(cmSystemTools::GetCMakeCommand()); commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string argH = "-H"; std::string argH = "-H";
argH += mf->GetHomeDirectory(); argH += lg->GetSourceDirectory();
commandLine.push_back(argH); commandLine.push_back(argH);
std::string argB = "-B"; std::string argB = "-B";
argB += mf->GetHomeOutputDirectory(); argB += lg->GetBinaryDirectory();
commandLine.push_back(argB); commandLine.push_back(argB);
commandLine.push_back("--check-stamp-list"); commandLine.push_back("--check-stamp-list");
commandLine.push_back(stampList.c_str()); commandLine.push_back(stampList.c_str());

View File

@ -590,7 +590,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
(this->CurrentReRunCMakeMakefile.c_str()); (this->CurrentReRunCMakeMakefile.c_str());
makefileStream.SetCopyIfDifferent(true); makefileStream.SetCopyIfDifferent(true);
makefileStream << "# Generated by CMake, DO NOT EDIT\n"; makefileStream << "# Generated by CMake, DO NOT EDIT\n";
std::string checkCache = mf->GetHomeOutputDirectory(); std::string checkCache = root->GetBinaryDirectory();
checkCache += "/"; checkCache += "/";
checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); checkCache += cmake::GetCMakeFilesDirectoryPostSlash();
checkCache += "cmake.check_cache"; checkCache += "cmake.check_cache";
@ -604,9 +604,9 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
makefileStream << "\n\t" << makefileStream << "\n\t" <<
this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str()) this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str())
<< " -H" << this->ConvertToRelativeForMake( << " -H" << this->ConvertToRelativeForMake(
mf->GetHomeDirectory()) root->GetSourceDirectory())
<< " -B" << this->ConvertToRelativeForMake( << " -B" << this->ConvertToRelativeForMake(
mf->GetHomeOutputDirectory()) << "\n"; root->GetBinaryDirectory()) << "\n";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -3749,7 +3749,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
// Since this call may have created new cache entries, save the cache: // Since this call may have created new cache entries, save the cache:
// //
root->GetMakefile()->GetCMakeInstance()->SaveCache( root->GetMakefile()->GetCMakeInstance()->SaveCache(
root->GetMakefile()->GetHomeOutputDirectory()); root->GetBinaryDirectory());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -2868,6 +2868,16 @@ cmake* cmLocalGenerator::GetCMakeInstance() const
return this->GlobalGenerator->GetCMakeInstance(); return this->GlobalGenerator->GetCMakeInstance();
} }
const char* cmLocalGenerator::GetSourceDirectory() const
{
return this->GetCMakeInstance()->GetHomeDirectory();
}
const char* cmLocalGenerator::GetBinaryDirectory() const
{
return this->GetCMakeInstance()->GetHomeOutputDirectory();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string std::string
cmLocalGenerator::GetTargetDirectory(cmTarget const&) const cmLocalGenerator::GetTargetDirectory(cmTarget const&) const

View File

@ -255,6 +255,9 @@ public:
cmake* GetCMakeInstance() const; cmake* GetCMakeInstance() const;
const char* GetSourceDirectory() const;
const char* GetBinaryDirectory() const;
/** /**
* Generate a Mac OS X application bundle Info.plist file. * Generate a Mac OS X application bundle Info.plist file.
*/ */

View File

@ -399,7 +399,7 @@ cmLocalUnixMakefileGenerator3
); );
} }
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
// Write the rule to the makefile. // Write the rule to the makefile.
@ -449,7 +449,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(this->GetRecursiveMakeCall commands.push_back(this->GetRecursiveMakeCall
(makefile2.c_str(),localName)); (makefile2.c_str(),localName));
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.", this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
localName, depends, commands, true); localName, depends, commands, true);
@ -478,7 +478,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(this->GetRecursiveMakeCall commands.push_back(this->GetRecursiveMakeCall
(makefileName.c_str(), makeTargetName)); (makefileName.c_str(), makeTargetName));
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "fast build rule for target.", this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
localName, depends, commands, true); localName, depends, commands, true);
@ -496,7 +496,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(this->GetRecursiveMakeCall commands.push_back(this->GetRecursiveMakeCall
(makefile2.c_str(), makeTargetName)); (makefile2.c_str(), makeTargetName));
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, this->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.", "Manual pre-install relink rule for target.",
@ -750,13 +750,13 @@ cmLocalUnixMakefileGenerator3
makefileStream makefileStream
<< "# The top-level source directory on which CMake was run.\n" << "# The top-level source directory on which CMake was run.\n"
<< "CMAKE_SOURCE_DIR = " << "CMAKE_SOURCE_DIR = "
<< this->Convert(this->Makefile->GetHomeDirectory(), FULL, SHELL) << this->Convert(this->GetSourceDirectory(), FULL, SHELL)
<< "\n" << "\n"
<< "\n"; << "\n";
makefileStream makefileStream
<< "# The top-level build directory on which CMake was run.\n" << "# The top-level build directory on which CMake was run.\n"
<< "CMAKE_BINARY_DIR = " << "CMAKE_BINARY_DIR = "
<< this->Convert(this->Makefile->GetHomeOutputDirectory(), FULL, SHELL) << this->Convert(this->GetBinaryDirectory(), FULL, SHELL)
<< "\n" << "\n"
<< "\n"; << "\n";
} }
@ -889,7 +889,7 @@ void cmLocalUnixMakefileGenerator3
if(!this->GetMakefile()->IsRootMakefile()) if(!this->GetMakefile()->IsRootMakefile())
{ {
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
} }
this->WriteMakeRule(makefileStream, this->WriteMakeRule(makefileStream,
@ -1838,7 +1838,7 @@ void cmLocalUnixMakefileGenerator3
depends.push_back("cmake_check_build_system"); depends.push_back("cmake_check_build_system");
std::string progressDir = this->Makefile->GetHomeOutputDirectory(); std::string progressDir = this->GetBinaryDirectory();
progressDir += cmake::GetCMakeFilesDirectory(); progressDir += cmake::GetCMakeFilesDirectory();
{ {
std::ostringstream progCmd; std::ostringstream progCmd;
@ -1862,7 +1862,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
recursiveTarget)); recursiveTarget));
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
{ {
std::ostringstream progCmd; std::ostringstream progCmd;
@ -1884,7 +1884,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
recursiveTarget)); recursiveTarget));
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
depends, commands, true); depends, commands, true);
@ -1914,7 +1914,7 @@ void cmLocalUnixMakefileGenerator3
commands.push_back commands.push_back
(this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
"preinstall", depends, commands, true); "preinstall", depends, commands, true);
@ -1935,7 +1935,7 @@ void cmLocalUnixMakefileGenerator3
runRule += " 1"; runRule += " 1";
commands.push_back(runRule); commands.push_back(runRule);
this->CreateCDCommand(commands, this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(), this->GetBinaryDirectory(),
cmLocalGenerator::START_OUTPUT); cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "clear depends", this->WriteMakeRule(ruleFileStream, "clear depends",
"depend", "depend",

View File

@ -112,7 +112,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
{ {
// If not an in source build, then create the output directory // If not an in source build, then create the output directory
if(strcmp(this->Makefile->GetCurrentBinaryDirectory(), if(strcmp(this->Makefile->GetCurrentBinaryDirectory(),
this->Makefile->GetHomeDirectory()) != 0) this->GetSourceDirectory()) != 0)
{ {
if(!cmSystemTools::MakeDirectory if(!cmSystemTools::MakeDirectory
(this->Makefile->GetCurrentBinaryDirectory())) (this->Makefile->GetCurrentBinaryDirectory()))
@ -226,10 +226,10 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
comment += makefileIn; comment += makefileIn;
std::string args; std::string args;
args = "-H"; args = "-H";
args += this->Makefile->GetHomeDirectory(); args += this->GetSourceDirectory();
commandLine.push_back(args); commandLine.push_back(args);
args = "-B"; args = "-B";
args += this->Makefile->GetHomeOutputDirectory(); args += this->GetBinaryDirectory();
commandLine.push_back(args); commandLine.push_back(args);
std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();

View File

@ -165,7 +165,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles()
{ {
// If not an in source build, then create the output directory // If not an in source build, then create the output directory
if(strcmp(this->Makefile->GetCurrentBinaryDirectory(), if(strcmp(this->Makefile->GetCurrentBinaryDirectory(),
this->Makefile->GetHomeDirectory()) != 0) this->GetSourceDirectory()) != 0)
{ {
if(!cmSystemTools::MakeDirectory if(!cmSystemTools::MakeDirectory
(this->Makefile->GetCurrentBinaryDirectory())) (this->Makefile->GetCurrentBinaryDirectory()))
@ -294,10 +294,10 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
comment += makefileIn; comment += makefileIn;
std::string args; std::string args;
args = "-H"; args = "-H";
args += this->Makefile->GetHomeDirectory(); args += this->GetSourceDirectory();
commandLine.push_back(args); commandLine.push_back(args);
args = "-B"; args = "-B";
args += this->Makefile->GetHomeOutputDirectory(); args += this->GetBinaryDirectory();
commandLine.push_back(args); commandLine.push_back(args);
commandLine.push_back("--check-stamp-file"); commandLine.push_back("--check-stamp-file");
std::string stampFilename = this->Convert(stampName.c_str(), FULL, std::string stampFilename = this->Convert(stampName.c_str(), FULL,

View File

@ -1095,7 +1095,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// translation table for the dependency scanning process. // translation table for the dependency scanning process.
depCmd << "cd " depCmd << "cd "
<< (this->LocalGenerator->Convert( << (this->LocalGenerator->Convert(
this->Makefile->GetHomeOutputDirectory(), this->LocalGenerator->GetBinaryDirectory(),
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)) cmLocalGenerator::FULL, cmLocalGenerator::SHELL))
<< " && "; << " && ";
#endif #endif
@ -1110,13 +1110,13 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// the state of our local generator sufficiently for its needs. // the state of our local generator sufficiently for its needs.
depCmd << "$(CMAKE_COMMAND) -E cmake_depends \"" depCmd << "$(CMAKE_COMMAND) -E cmake_depends \""
<< this->GlobalGenerator->GetName() << "\" " << this->GlobalGenerator->GetName() << "\" "
<< this->Convert(this->Makefile->GetHomeDirectory(), << this->Convert(this->LocalGenerator->GetSourceDirectory(),
cmLocalGenerator::FULL, cmLocalGenerator::SHELL) cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
<< " " << " "
<< this->Convert(this->Makefile->GetCurrentSourceDirectory(), << this->Convert(this->Makefile->GetCurrentSourceDirectory(),
cmLocalGenerator::FULL, cmLocalGenerator::SHELL) cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
<< " " << " "
<< this->Convert(this->Makefile->GetHomeOutputDirectory(), << this->Convert(this->LocalGenerator->GetBinaryDirectory(),
cmLocalGenerator::FULL, cmLocalGenerator::SHELL) cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
<< " " << " "
<< this->Convert(this->Makefile->GetCurrentBinaryDirectory(), << this->Convert(this->Makefile->GetCurrentBinaryDirectory(),
@ -1242,7 +1242,7 @@ void
cmMakefileTargetGenerator cmMakefileTargetGenerator
::MakeEchoProgress(cmLocalUnixMakefileGenerator3::EchoProgress& progress) const ::MakeEchoProgress(cmLocalUnixMakefileGenerator3::EchoProgress& progress) const
{ {
progress.Dir = this->Makefile->GetHomeOutputDirectory(); progress.Dir = this->LocalGenerator->GetBinaryDirectory();
progress.Dir += cmake::GetCMakeFilesDirectory(); progress.Dir += cmake::GetCMakeFilesDirectory();
std::ostringstream progressArg; std::ostringstream progressArg;
progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")"; progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";

View File

@ -666,7 +666,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
if (!preLinkCmdLines.empty()) if (!preLinkCmdLines.empty())
{ {
const std::string homeOutDir = localGen.ConvertToOutputFormat( const std::string homeOutDir = localGen.ConvertToOutputFormat(
mf->GetHomeOutputDirectory(), localGen.GetBinaryDirectory(),
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
preLinkCmdLines.push_back("cd " + homeOutDir); preLinkCmdLines.push_back("cd " + homeOutDir);
} }

View File

@ -47,7 +47,7 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
// in every directory, which we don't need. // in every directory, which we don't need.
cmMakefile *mf = target->Target->GetMakefile(); cmMakefile *mf = target->Target->GetMakefile();
if (strcmp(mf->GetCurrentSourceDirectory(), if (strcmp(mf->GetCurrentSourceDirectory(),
mf->GetHomeDirectory()) == 0) target->GetLocalGenerator()->GetSourceDirectory()) == 0)
return new cmNinjaUtilityTargetGenerator(target); return new cmNinjaUtilityTargetGenerator(target);
// else fallthrough // else fallthrough
} }

View File

@ -103,13 +103,13 @@ void cmNinjaUtilityTargetGenerator::Generate()
command, command,
"$(CMAKE_SOURCE_DIR)", "$(CMAKE_SOURCE_DIR)",
this->GetLocalGenerator()->ConvertToOutputFormat( this->GetLocalGenerator()->ConvertToOutputFormat(
this->GetTarget()->GetMakefile()->GetHomeDirectory(), this->GetLocalGenerator()->GetSourceDirectory(),
cmLocalGenerator::SHELL).c_str()); cmLocalGenerator::SHELL).c_str());
cmSystemTools::ReplaceString( cmSystemTools::ReplaceString(
command, command,
"$(CMAKE_BINARY_DIR)", "$(CMAKE_BINARY_DIR)",
this->GetLocalGenerator()->ConvertToOutputFormat( this->GetLocalGenerator()->ConvertToOutputFormat(
this->GetTarget()->GetMakefile()->GetHomeOutputDirectory(), this->GetLocalGenerator()->GetBinaryDirectory(),
cmLocalGenerator::SHELL).c_str()); cmLocalGenerator::SHELL).c_str());
cmSystemTools::ReplaceString(command, "$(ARGS)", ""); cmSystemTools::ReplaceString(command, "$(ARGS)", "");