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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,7 +52,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=mf->GetHomeDirectory();
std::string projectName=mf->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;
const std::vector<cmLocalGenerator*>& lgs= it->second; const std::vector<cmLocalGenerator*>& lgs= it->second;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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