From 5700deb16af5a0ff34b64adcce0e72c0d4109f01 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 10 Mar 2009 17:34:18 -0400 Subject: ENH: only check for the existance of a header file if: -the original file is a C/C++ implementation file -the header file is not already part of the sources Alex --- Source/cmExtraCodeBlocksGenerator.cxx | 66 +++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 96f3a95..b517335 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -230,7 +230,10 @@ void cmExtraCodeBlocksGenerator // Collect all used source files in the project - std::map sourceFiles; + // Sort them into two containers, one for C/C++ implementation files + // which may have an acompanying header, one for all other files + std::map cFiles; + std::set otherFiles; for (std::vector::const_iterator lg=lgs.begin(); lg!=lgs.end(); lg++) { @@ -250,7 +253,32 @@ void cmExtraCodeBlocksGenerator for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) { - sourceFiles[(*si)->GetFullPath()] = ti->first; + // check whether it is a C/C++ implementation file + bool isCFile = false; + if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) + { + for(std::vector::const_iterator + ext = mf->GetSourceExtensions().begin(); + ext != mf->GetSourceExtensions().end(); + ++ext) + { + if ((*si)->GetExtension() == *ext) + { + isCFile = true; + break; + } + } + } + + // then put it accordingly into one of the two containers + if (isCFile) + { + cFiles[(*si)->GetFullPath()] = *si ; + } + else + { + otherFiles.insert((*si)->GetFullPath()); + } } } default: // intended fallthrough @@ -265,9 +293,9 @@ void cmExtraCodeBlocksGenerator // 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(); + for (std::map::const_iterator + sit=cFiles.begin(); + sit!=cFiles.end(); ++sit) { std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first); @@ -283,21 +311,37 @@ void cmExtraCodeBlocksGenerator std::string hname=headerBasename; hname += "."; hname += *ext; + // if it's already in the set, don't check if it exists on disk + std::set::const_iterator headerIt=otherFiles.find(hname); + if (headerIt != otherFiles.end()) + { + break; + } + if(cmSystemTools::FileExists(hname.c_str())) { - sourceFiles[hname] = hname; + otherFiles.insert(hname); break; } } } - // insert all used source files in the CodeBlocks project - for (std::map::const_iterator - sit=sourceFiles.begin(); - sit!=sourceFiles.end(); + // insert all source files in the CodeBlocks project + // first the C/C++ implementation files, then all others + for (std::map::const_iterator + sit=cFiles.begin(); + sit!=cFiles.end(); + ++sit) + { + fout<<" first <<"\">\n" + " \n"; + } + for (std::set::const_iterator + sit=otherFiles.begin(); + sit!=otherFiles.end(); ++sit) { - fout<<" first <<"\">\n" + fout<<" c_str() <<"\">\n" " \n"; } -- cgit v0.12