| 48 | } |
| 49 | |
| 50 | void cmExtraCodeLiteGenerator::Generate() |
| 51 | { |
| 52 | // Hold root tree information for creating the workspace |
| 53 | std::string workspaceProjectName; |
| 54 | std::string workspaceOutputDir; |
| 55 | std::string workspaceFileName; |
| 56 | std::string workspaceSourcePath; |
| 57 | |
| 58 | std::map<std::string, std::vector<cmLocalGenerator*>> const& projectMap = |
| 59 | this->GlobalGenerator->GetProjectMap(); |
| 60 | |
| 61 | // loop projects and locate the root project. |
| 62 | // and extract the information for creating the workspace |
| 63 | // root makefile |
| 64 | for (auto const& it : projectMap) { |
| 65 | cmLocalGenerator* lg = it.second[0]; |
| 66 | cmMakefile const* mf = lg->GetMakefile(); |
| 67 | this->ConfigName = this->GetConfigurationName(mf); |
| 68 | |
| 69 | if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) { |
| 70 | workspaceOutputDir = lg->GetCurrentBinaryDirectory(); |
| 71 | workspaceProjectName = lg->GetProjectName(); |
| 72 | workspaceSourcePath = lg->GetSourceDirectory(); |
| 73 | workspaceFileName = |
| 74 | cmStrCat(workspaceOutputDir, '/', workspaceProjectName, ".workspace"); |
| 75 | this->WorkspacePath = lg->GetCurrentBinaryDirectory(); |
| 76 | break; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | cmGeneratedFileStream fout(workspaceFileName); |
| 81 | cmXMLWriter xml(fout); |
| 82 | |
| 83 | xml.StartDocument("utf-8"); |
| 84 | xml.StartElement("CodeLite_Workspace"); |
| 85 | xml.Attribute("Name", workspaceProjectName); |
| 86 | |
| 87 | bool const targetsAreProjects = |
| 88 | this->GlobalGenerator->GlobalSettingIsOn("CMAKE_CODELITE_USE_TARGETS"); |
| 89 | |
| 90 | std::vector<std::string> ProjectNames; |
| 91 | if (targetsAreProjects) { |
| 92 | ProjectNames = this->CreateProjectsByTarget(&xml); |
| 93 | } else { |
| 94 | ProjectNames = this->CreateProjectsByProjectMaps(&xml); |
| 95 | } |
| 96 | |
| 97 | xml.StartElement("BuildMatrix"); |
| 98 | xml.StartElement("WorkspaceConfiguration"); |
| 99 | xml.Attribute("Name", this->ConfigName); |
| 100 | xml.Attribute("Selected", "yes"); |
| 101 | |
| 102 | for (std::string const& it : ProjectNames) { |
| 103 | xml.StartElement("Project"); |
| 104 | xml.Attribute("Name", it); |
| 105 | xml.Attribute("ConfigName", this->ConfigName); |
| 106 | xml.EndElement(); |
| 107 | } |
nothing calls this directly
no test coverage detected