From 363c4e422d662dcc8e5cea5b2b396ea6e67220c7 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sun, 8 Mar 2009 15:33:58 -0400 Subject: [PATCH] ENH: automatically add headers of implementation file to the codeblocks project file Alex --- Source/cmExtraCodeBlocksGenerator.cxx | 40 ++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index a84b28d5a..96f3a95f9 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -259,15 +259,47 @@ void cmExtraCodeBlocksGenerator } } + // The following loop tries to add header files matching to implementation + // files to the project. It does that by iterating over all source files, + // replacing the file name extension with ".h" and checks whether such a + // file exists. If it does, it is inserted into the map of files. + // A very similar version of that code exists also in the kdevelop + // project generator. + for (std::map::const_iterator + sit=sourceFiles.begin(); + sit!=sourceFiles.end(); + ++sit) + { + std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first); + headerBasename+="/"; + headerBasename+=cmSystemTools::GetFilenameWithoutExtension(sit->first); + + // check if there's a matching header around + for(std::vector::const_iterator + ext = mf->GetHeaderExtensions().begin(); + ext != mf->GetHeaderExtensions().end(); + ++ext) + { + std::string hname=headerBasename; + hname += "."; + hname += *ext; + if(cmSystemTools::FileExists(hname.c_str())) + { + sourceFiles[hname] = hname; + break; + } + } + } + // insert all used source files in the CodeBlocks project for (std::map::const_iterator sit=sourceFiles.begin(); sit!=sourceFiles.end(); ++sit) - { - fout<<" first <<"\">\n" - " \n"; - } + { + fout<<" first <<"\">\n" + " \n"; + } fout<<" \n" "\n";