1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 22:37:30 +08:00

cmLocalGenerator: return directories as const std::string&

This commit is contained in:
Vitaly Stakhovsky
2018-08-24 09:43:35 -04:00
committed by Brad King
parent e33c6c357b
commit 50fbfee3a0
11 changed files with 21 additions and 22 deletions

View File

@@ -122,7 +122,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget(
for (cmLocalGenerator* lg : lgs) { for (cmLocalGenerator* lg : lgs) {
for (cmGeneratorTarget* lt : lg->GetGeneratorTargets()) { for (cmGeneratorTarget* lt : lg->GetGeneratorTargets()) {
cmStateEnums::TargetType type = lt->GetType(); cmStateEnums::TargetType type = lt->GetType();
std::string outputDir = lg->GetCurrentBinaryDirectory(); std::string const& outputDir = lg->GetCurrentBinaryDirectory();
std::string targetName = lt->GetName(); std::string targetName = lt->GetName();
std::string filename = outputDir + "/" + targetName + ".project"; std::string filename = outputDir + "/" + targetName + ".project";
retval.push_back(targetName); retval.push_back(targetName);
@@ -161,7 +161,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps(
// for each sub project in the workspace create a codelite project // for each sub project in the workspace create a codelite project
for (auto const& it : this->GlobalGenerator->GetProjectMap()) { for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
std::string outputDir = it.second[0]->GetCurrentBinaryDirectory(); std::string const& outputDir = it.second[0]->GetCurrentBinaryDirectory();
std::string projectName = it.second[0]->GetProjectName(); std::string projectName = it.second[0]->GetProjectName();
retval.push_back(projectName); retval.push_back(projectName);
std::string filename = outputDir + "/" + projectName + ".project"; std::string filename = outputDir + "/" + projectName + ".project";
@@ -184,7 +184,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps(
void cmExtraCodeLiteGenerator::CreateProjectFile( void cmExtraCodeLiteGenerator::CreateProjectFile(
const std::vector<cmLocalGenerator*>& lgs) const std::vector<cmLocalGenerator*>& lgs)
{ {
std::string outputDir = lgs[0]->GetCurrentBinaryDirectory(); std::string const& outputDir = lgs[0]->GetCurrentBinaryDirectory();
std::string projectName = lgs[0]->GetProjectName(); std::string projectName = lgs[0]->GetProjectName();
std::string filename = outputDir + "/"; std::string filename = outputDir + "/";

View File

@@ -3565,8 +3565,9 @@ bool cmGeneratorTarget::StrictTargetComparison::operator()(
{ {
int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str()); int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
if (nameResult == 0) { if (nameResult == 0) {
return strcmp(t1->GetLocalGenerator()->GetCurrentBinaryDirectory(), return strcmp(
t2->GetLocalGenerator()->GetCurrentBinaryDirectory()) < 0; t1->GetLocalGenerator()->GetCurrentBinaryDirectory().c_str(),
t2->GetLocalGenerator()->GetCurrentBinaryDirectory().c_str()) < 0;
} }
return nameResult < 0; return nameResult < 0;
} }

View File

@@ -1011,8 +1011,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
std::set<std::string> const& utils = target->GetUtilities(); std::set<std::string> const& utils = target->GetUtilities();
for (std::string const& util : utils) { for (std::string const& util : utils) {
std::string d = std::string d =
target->GetLocalGenerator()->GetCurrentBinaryDirectory() + target->GetLocalGenerator()->GetCurrentBinaryDirectory() + "/" + util;
std::string("/") + util;
outputs.push_back(this->ConvertToNinjaPath(d)); outputs.push_back(this->ConvertToNinjaPath(d));
} }
} else { } else {

View File

@@ -1014,7 +1014,7 @@ void cmGlobalVisualStudio10Generator::PathTooLong(cmGeneratorTarget* target,
std::string const& sfRel) std::string const& sfRel)
{ {
size_t len = size_t len =
(strlen(target->GetLocalGenerator()->GetCurrentBinaryDirectory()) + 1 + (target->GetLocalGenerator()->GetCurrentBinaryDirectory().length() + 1 +
sfRel.length()); sfRel.length());
if (len > this->LongestSource.Length) { if (len > this->LongestSource.Length) {
this->LongestSource.Length = len; this->LongestSource.Length = len;

View File

@@ -3040,7 +3040,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
// Point Xcode at the top of the source tree. // Point Xcode at the top of the source tree.
{ {
std::string pdir = std::string pdir =
this->RelativeToBinary(root->GetCurrentSourceDirectory()); this->RelativeToBinary(root->GetCurrentSourceDirectory().c_str());
this->RootObject->AddAttribute("projectDirPath", this->CreateString(pdir)); this->RootObject->AddAttribute("projectDirPath", this->CreateString(pdir));
this->RootObject->AddAttribute("projectRoot", this->CreateString("")); this->RootObject->AddAttribute("projectRoot", this->CreateString(""));
} }

View File

@@ -2522,14 +2522,14 @@ std::string const& cmLocalGenerator::GetBinaryDirectory() const
return this->GetCMakeInstance()->GetHomeOutputDirectory(); return this->GetCMakeInstance()->GetHomeOutputDirectory();
} }
const char* cmLocalGenerator::GetCurrentBinaryDirectory() const std::string const& cmLocalGenerator::GetCurrentBinaryDirectory() const
{ {
return this->StateSnapshot.GetDirectory().GetCurrentBinary().c_str(); return this->StateSnapshot.GetDirectory().GetCurrentBinary();
} }
const char* cmLocalGenerator::GetCurrentSourceDirectory() const std::string const& cmLocalGenerator::GetCurrentSourceDirectory() const
{ {
return this->StateSnapshot.GetDirectory().GetCurrentSource().c_str(); return this->StateSnapshot.GetDirectory().GetCurrentSource();
} }
std::string cmLocalGenerator::GetTargetDirectory( std::string cmLocalGenerator::GetTargetDirectory(

View File

@@ -296,8 +296,8 @@ public:
std::string const& GetSourceDirectory() const; std::string const& GetSourceDirectory() const;
std::string const& GetBinaryDirectory() const; std::string const& GetBinaryDirectory() const;
const char* GetCurrentBinaryDirectory() const; std::string const& GetCurrentBinaryDirectory() const;
const char* GetCurrentSourceDirectory() const; std::string const& GetCurrentSourceDirectory() const;
/** /**
* Generate a Mac OS X application bundle Info.plist file. * Generate a Mac OS X application bundle Info.plist file.

View File

@@ -118,7 +118,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles()
if (this->GetCurrentBinaryDirectory() != this->GetSourceDirectory()) { if (this->GetCurrentBinaryDirectory() != this->GetSourceDirectory()) {
if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) { if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) {
cmSystemTools::Error("Error creating directory ", cmSystemTools::Error("Error creating directory ",
this->GetCurrentBinaryDirectory()); this->GetCurrentBinaryDirectory().c_str());
} }
} }

View File

@@ -456,7 +456,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// clean set just in case. // clean set just in case.
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), this->LocalGenerator->GetCurrentBinaryDirectory(),
(targetFullPath + ".manifest").c_str())); targetFullPath + ".manifest"));
#endif #endif
if (targetNameReal != targetName) { if (targetNameReal != targetName) {
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(

View File

@@ -635,7 +635,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), this->LocalGenerator->GetCurrentBinaryDirectory(),
(targetFullPath + ".manifest").c_str())); targetFullPath + ".manifest"));
} }
#endif #endif

View File

@@ -250,7 +250,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
this->TargetCompileAsWinRT = false; this->TargetCompileAsWinRT = false;
this->IsMissingFiles = false; this->IsMissingFiles = false;
this->DefaultArtifactDir = this->DefaultArtifactDir =
this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/") + this->LocalGenerator->GetCurrentBinaryDirectory() + "/" +
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->InSourceBuild = this->InSourceBuild =
(strcmp(this->Makefile->GetCurrentSourceDirectory(), (strcmp(this->Makefile->GetCurrentSourceDirectory(),
@@ -1877,7 +1877,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2,
std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true); std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true);
size_t const maxLen = 250; size_t const maxLen = 250;
if (sf->GetCustomCommand() || if (sf->GetCustomCommand() ||
((strlen(this->LocalGenerator->GetCurrentBinaryDirectory()) + 1 + ((this->LocalGenerator->GetCurrentBinaryDirectory().length() + 1 +
sourceRel.length()) <= maxLen)) { sourceRel.length()) <= maxLen)) {
forceRelative = true; forceRelative = true;
sourceFile = sourceRel; sourceFile = sourceRel;
@@ -4131,8 +4131,7 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1)
// this can cause an overwrite problem if projects aren't organized in // this can cause an overwrite problem if projects aren't organized in
// folders // folders
std::string manifestFile = std::string manifestFile =
this->LocalGenerator->GetCurrentBinaryDirectory() + this->LocalGenerator->GetCurrentBinaryDirectory() + "/WMAppManifest.xml";
std::string("/WMAppManifest.xml");
std::string artifactDir = std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
ConvertToWindowsSlash(artifactDir); ConvertToWindowsSlash(artifactDir);