cmLocalGenerator: Add GetProjectName method.

This commit is contained in:
Stephen Kelly 2015-10-07 00:29:25 +02:00
parent c8187f414b
commit 4ab2750c54
13 changed files with 36 additions and 30 deletions

View File

@ -78,7 +78,7 @@ void cmExtraCodeBlocksGenerator::CreateProjectFile(
{
const cmMakefile* mf=lgs[0]->GetMakefile();
std::string outputDir=mf->GetCurrentBinaryDirectory();
std::string projectName=mf->GetProjectName();
std::string projectName=lgs[0]->GetProjectName();
std::string filename=outputDir+"/";
filename+=projectName+".cbp";
@ -307,7 +307,7 @@ void cmExtraCodeBlocksGenerator
"<CodeBlocks_project_file>\n"
" <FileVersion major=\"1\" minor=\"6\" />\n"
" <Project>\n"
" <Option title=\"" << mf->GetProjectName()<<"\" />\n"
" <Option title=\"" << lgs[0]->GetProjectName()<<"\" />\n"
" <Option makefile_is_custom=\"1\" />\n"
" <Option compiler=\"" << compiler << "\" />\n"
" "<<virtualFolders<<"\n"

View File

@ -72,7 +72,7 @@ void cmExtraCodeLiteGenerator::Generate()
mf->GetHomeOutputDirectory()) == 0)
{
workspaceOutputDir = mf->GetCurrentBinaryDirectory();
workspaceProjectName = mf->GetProjectName();
workspaceProjectName = it->second[0]->GetProjectName();
workspaceSourcePath = mf->GetHomeDirectory();
workspaceFileName = workspaceOutputDir+"/";
workspaceFileName += workspaceProjectName + ".workspace";
@ -93,7 +93,7 @@ void cmExtraCodeLiteGenerator::Generate()
// retrive project information
const cmMakefile* mf = it->second[0]->GetMakefile();
std::string outputDir = mf->GetCurrentBinaryDirectory();
std::string projectName = mf->GetProjectName();
std::string projectName = it->second[0]->GetProjectName();
std::string filename = outputDir + "/" + projectName + ".project";
// Make the project file relative to the workspace
@ -123,7 +123,7 @@ void cmExtraCodeLiteGenerator::CreateProjectFile(
{
const cmMakefile* mf = lgs[0]->GetMakefile();
std::string outputDir = mf->GetCurrentBinaryDirectory();
std::string projectName = mf->GetProjectName();
std::string projectName = lgs[0]->GetProjectName();
std::string filename = outputDir + "/";
filename += projectName + ".project";
@ -143,7 +143,7 @@ void cmExtraCodeLiteGenerator
////////////////////////////////////
fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<CodeLite_Project Name=\"" << mf->GetProjectName()
"<CodeLite_Project Name=\"" << lgs[0]->GetProjectName()
<< "\" InternalType=\"\">\n";
// Collect all used source files in the project

View File

@ -157,9 +157,8 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
assert(this->HomeDirectory != this->HomeOutputDirectory);
// set up the project name: <project>-Source@<baseSourcePathName>
const cmMakefile* mf
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
std::string name = this->GenerateProjectName(mf->GetProjectName(), "Source",
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
std::string name = this->GenerateProjectName(lg->GetProjectName(), "Source",
this->GetPathBasename(this->HomeDirectory));
const std::string filename = this->HomeDirectory + "/.project";
@ -259,8 +258,8 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator::CreateProjectFile()
{
cmMakefile* mf
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
cmMakefile* mf = lg->GetMakefile();
const std::string filename = this->HomeOutputDirectory + "/.project";
@ -280,7 +279,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<projectDescription>\n"
"\t<name>" <<
this->GenerateProjectName(mf->GetProjectName(),
this->GenerateProjectName(lg->GetProjectName(),
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
this->GetPathBasename(this->HomeOutputDirectory))
<< "</name>\n"
@ -696,8 +695,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
{
std::set<std::string> emmited;
const cmMakefile* mf
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
const cmMakefile* mf = lg->GetMakefile();
const std::string filename = this->HomeOutputDirectory + "/.cproject";
@ -1151,8 +1150,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
fout << "</cconfiguration>\n"
"</storageModule>\n"
"<storageModule moduleId=\"cdtBuildSystem\" version=\"4.0.0\">\n"
"<project id=\"" << this->EscapeForXML(mf->GetProjectName())
<< ".null.1\" name=\"" << this->EscapeForXML(mf->GetProjectName())
"<project id=\"" << this->EscapeForXML(lg->GetProjectName())
<< ".null.1\" name=\"" << this->EscapeForXML(lg->GetProjectName())
<< "\"/>\n"
"</storageModule>\n"
"</cproject>\n"

View File

@ -46,9 +46,9 @@ cmExtraKateGenerator::cmExtraKateGenerator()
void cmExtraKateGenerator::Generate()
{
const cmMakefile* mf
= this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile();
this->ProjectName = this->GenerateProjectName(mf->GetProjectName(),
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
const cmMakefile* mf = lg->GetMakefile();
this->ProjectName = this->GenerateProjectName(lg->GetProjectName(),
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
this->GetPathBasename(mf->GetHomeOutputDirectory()));
this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja");

View File

@ -79,7 +79,7 @@ void cmExtraSublimeTextGenerator::CreateProjectFile(
{
const cmMakefile* mf=lgs[0]->GetMakefile();
std::string outputDir=mf->GetCurrentBinaryDirectory();
std::string projectName=mf->GetProjectName();
std::string projectName=lgs[0]->GetProjectName();
const std::string filename =
outputDir + "/" + projectName + ".sublime-project";
@ -302,7 +302,7 @@ void cmExtraSublimeTextGenerator::
{
fout << ",\n\t";
}
fout << "\t{\n\t\t\t\"name\": \"" << makefile->GetProjectName() << " - " <<
fout << "\t{\n\t\t\t\"name\": \"" << lg->GetProjectName() << " - " <<
targetName << "\",\n";
fout << "\t\t\t\"cmd\": [" <<
this->BuildMakeCommand(make, makefileName.c_str(), targetName) <<

View File

@ -52,7 +52,7 @@ void cmGlobalKdevelopGenerator::Generate()
cmMakefile* mf = it->second[0]->GetMakefile();
std::string outputDir=mf->GetCurrentBinaryDirectory();
std::string projectDir=mf->GetHomeDirectory();
std::string projectName=mf->GetProjectName();
std::string projectName=it->second[0]->GetProjectName();
std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
std::string fileToOpen;
const std::vector<cmLocalGenerator*>& lgs= it->second;

View File

@ -260,7 +260,7 @@ void cmGlobalVisualStudio6Generator
}
std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory();
fname += "/";
fname += root->GetMakefile()->GetProjectName();
fname += root->GetProjectName();
fname += ".dsw";
cmsys::ofstream fout(fname.c_str());
if(!fout)

View File

@ -362,10 +362,10 @@ void cmGlobalVisualStudio7Generator
{
return;
}
this->CurrentProject = root->GetMakefile()->GetProjectName();
this->CurrentProject = root->GetProjectName();
std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory();
fname += "/";
fname += root->GetMakefile()->GetProjectName();
fname += root->GetProjectName();
fname += ".sln";
cmGeneratedFileStream fout(fname.c_str());
fout.SetCopyIfDifferent(true);

View File

@ -250,7 +250,7 @@ cmGlobalVisualStudioGenerator
{
topLevelSlnName = mf->GetCurrentBinaryDirectory();
topLevelSlnName += "/";
topLevelSlnName += mf->GetProjectName();
topLevelSlnName += this->LocalGenerators[0]->GetProjectName();
topLevelSlnName += ".sln";
}

View File

@ -410,7 +410,7 @@ void cmGlobalXCodeGenerator::Generate()
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root)
{
this->CurrentProject = root->GetMakefile()->GetProjectName();
this->CurrentProject = root->GetProjectName();
this->SetCurrentLocalGenerator(root);
cmSystemTools::SplitPath(this->CurrentMakefile->GetCurrentSourceDirectory(),
this->ProjectSourceDirectoryComponents);
@ -3342,7 +3342,7 @@ bool cmGlobalXCodeGenerator
this->RootObject->SetComment("Project object");
std::string project_id = "PROJECT_";
project_id += root->GetMakefile()->GetProjectName();
project_id += root->GetProjectName();
this->RootObject->SetId(this->GetOrCreateId(
project_id.c_str(), this->RootObject->GetId()).c_str());
@ -3729,7 +3729,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
}
std::string xcodeDir = root->GetMakefile()->GetCurrentBinaryDirectory();
xcodeDir += "/";
xcodeDir += root->GetMakefile()->GetProjectName();
xcodeDir += root->GetProjectName();
xcodeDir += ".xcode";
if(this->XcodeVersion > 20)
{

View File

@ -2431,6 +2431,11 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature,
return 0;
}
std::string cmLocalGenerator::GetProjectName() const
{
return this->StateSnapshot.GetProjectName();
}
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,

View File

@ -182,6 +182,8 @@ public:
const std::string& config,
const std::string& lang);
std::string GetProjectName() const;
/** Compute the language used to compile the given source file. */
std::string GetSourceFileLanguage(const cmSourceFile& source);

View File

@ -183,7 +183,7 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
os
<< "# Project: " << this->GetMakefile()->GetProjectName() << std::endl
<< "# Project: " << this->GetProjectName() << std::endl
<< "# Configuration: " << this->ConfigName << std::endl
;
cmGlobalNinjaGenerator::WriteDivider(os);