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

Method CreateNewProjectFile

Source/cmExtraCodeBlocksGenerator.cxx:203–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
204 std::vector<cmLocalGenerator*> const& lgs, std::string const& filename)
205{
206 cmMakefile const* mf = lgs[0]->GetMakefile();
207 cmGeneratedFileStream fout(filename);
208 if (!fout) {
209 return;
210 }
211
212 Tree tree;
213
214 // build tree of virtual folders
215 for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
216 // Collect all files
217 std::vector<std::string> listFiles;
218 for (cmLocalGenerator* lg : it.second) {
219 cm::append(listFiles, lg->GetMakefile()->GetListFiles());
220 }
221
222 // Convert
223 for (std::string const& listFile : listFiles) {
224 // don't put cmake's own files into the project (#12110):
225 if (cmHasPrefix(listFile, cmSystemTools::GetCMakeRoot())) {
226 continue;
227 }
228
229 std::string const& relative = cmSystemTools::RelativePath(
230 it.second[0]->GetSourceDirectory(), listFile);
231 std::vector<std::string> split;
232 cmSystemTools::SplitPath(relative, split, false);
233 // Split filename from path
234 std::string fileName = *(split.end() - 1);
235 split.erase(split.end() - 1, split.end());
236
237 // We don't want paths with CMakeFiles in them
238 // or do we?
239 // In speedcrunch those where purely internal
240 //
241 // Also we can disable external (outside the project) files by setting ON
242 // CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable.
243 bool const excludeExternal = it.second[0]->GetMakefile()->IsOn(
244 "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES");
245 if (!split.empty() &&
246 (!excludeExternal || (relative.find("..") == std::string::npos)) &&
247 relative.find("CMakeFiles") == std::string::npos) {
248 tree.InsertPath(split, 1, fileName);
249 }
250 }
251 }
252
253 // figure out the compiler
254 std::string compiler = this->GetCBCompilerId(mf);
255 std::string const& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
256 std::string const& makeArgs =
257 mf->GetSafeDefinition("CMAKE_CODEBLOCKS_MAKE_ARGUMENTS");
258
259 cmXMLWriter xml(fout);
260 xml.StartDocument();

Callers 1

CreateProjectFileMethod · 0.95

Calls 15

GetCBCompilerIdMethod · 0.95
AppendTargetMethod · 0.95
appendFunction · 0.85
cmHasPrefixFunction · 0.85
cmHasLiteralPrefixFunction · 0.85
eraseMethod · 0.80
InsertPathMethod · 0.80
StartDocumentMethod · 0.80
AttributeMethod · 0.80
BuildVirtualFolderMethod · 0.80
GetSourceFilesMethod · 0.80
GetIsGeneratedMethod · 0.80

Tested by

no test coverage detected