MCPcopy Create free account
hub / github.com/Kitware/CMake / CreateNewProjectFile

Method CreateNewProjectFile

Source/cmExtraSublimeTextGenerator.cxx:95–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void cmExtraSublimeTextGenerator::CreateNewProjectFile(
96 std::vector<cmLocalGenerator*> const& lgs, std::string const& filename)
97{
98 cmMakefile const* mf = lgs[0]->GetMakefile();
99
100 cmGeneratedFileStream fout(filename);
101 if (!fout) {
102 return;
103 }
104
105 std::string const& sourceRootRelativeToOutput = cmSystemTools::RelativePath(
106 lgs[0]->GetBinaryDirectory(), lgs[0]->GetSourceDirectory());
107 // Write the folder entries to the project file
108 fout << "{\n";
109 fout << "\t\"folders\":\n\t[\n\t";
110 if (!sourceRootRelativeToOutput.empty()) {
111 fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\"";
112 std::string const& outputRelativeToSourceRoot =
113 cmSystemTools::RelativePath(lgs[0]->GetSourceDirectory(),
114 lgs[0]->GetBinaryDirectory());
115 if ((!outputRelativeToSourceRoot.empty()) &&
116 ((outputRelativeToSourceRoot.length() < 3) ||
117 (outputRelativeToSourceRoot.substr(0, 3) != "../"))) {
118 if (this->ExcludeBuildFolder) {
119 fout << ",\n\t\t\t\"folder_exclude_patterns\": [\""
120 << outputRelativeToSourceRoot << "\"]";
121 }
122 }
123 } else {
124 fout << "\t{\n\t\t\t\"path\": \"./\"";
125 }
126 fout << "\n\t\t}";
127 // End of the folders section
128 fout << "\n\t]";
129
130 // Write the beginning of the build systems section to the project file
131 fout << ",\n\t\"build_systems\":\n\t[\n\t";
132
133 // Set of include directories over all targets (sublime text/sublimeclang
134 // doesn't currently support these settings per build system, only project
135 // wide
136 MapSourceFileFlags sourceFileFlags;
137 this->AppendAllTargets(lgs, mf, fout, sourceFileFlags);
138
139 // End of build_systems
140 fout << "\n\t]";
141 std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
142 cmList tokens{ this->EnvSettings };
143
144 if (!this->EnvSettings.empty()) {
145 fout << ",";
146 fout << "\n\t\"env\":";
147 fout << "\n\t{";
148 fout << "\n\t\t" << systemName << ":";
149 fout << "\n\t\t{";
150 for (std::string const& t : tokens) {
151 size_t const pos = t.find_first_of('=');
152

Callers 1

CreateProjectFileMethod · 0.95

Calls 8

AppendAllTargetsMethod · 0.95
lengthMethod · 0.80
find_first_ofMethod · 0.80
strMethod · 0.80
GetMakefileMethod · 0.45
emptyMethod · 0.45
substrMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected