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

Method FindMatchingHeaderfiles

Source/cmExtraCodeLiteGenerator.cxx:284–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles(
285 std::map<std::string, cmSourceFile*>& cFiles,
286 std::set<std::string>& otherFiles)
287{
288
289 std::vector<std::string> const& headerExts =
290 this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
291
292 // The following loop tries to add header files matching to implementation
293 // files to the project. It does that by iterating over all source files,
294 // replacing the file name extension with ".h" and checks whether such a
295 // file exists. If it does, it is inserted into the map of files.
296 // A very similar version of that code exists also in the CodeBlocks
297 // project generator.
298 for (auto const& sit : cFiles) {
299 std::string headerBasename =
300 cmStrCat(cmSystemTools::GetFilenamePath(sit.first), '/',
301 cmSystemTools::GetFilenameWithoutExtension(sit.first));
302
303 // check if there's a matching header around
304 for (std::string const& ext : headerExts) {
305 std::string hname = cmStrCat(headerBasename, '.', ext);
306 // if it's already in the set, don't check if it exists on disk
307 auto headerIt = otherFiles.find(hname);
308 if (headerIt != otherFiles.end()) {
309 break;
310 }
311
312 if (cmSystemTools::FileExists(hname)) {
313 otherFiles.insert(hname);
314 break;
315 }
316 }
317 }
318}
319
320void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
321 std::set<std::string>& cFiles, cmXMLWriter& xml,

Callers 1

Calls 6

cmStrCatFunction · 0.70
FileExistsFunction · 0.50
GetCMakeInstanceMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected