summaryrefslogtreecommitdiffstats
path: root/Source/cmExtraCodeBlocksGenerator.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-03-10 21:34:18 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2009-03-10 21:34:18 (GMT)
commit5700deb16af5a0ff34b64adcce0e72c0d4109f01 (patch)
tree765819432fea402e6c6f21089d0f227dc77e04d6 /Source/cmExtraCodeBlocksGenerator.cxx
parent32258b44bc5d335ca5143194852a7e6bed0b62a3 (diff)
downloadCMake-5700deb16af5a0ff34b64adcce0e72c0d4109f01.zip
CMake-5700deb16af5a0ff34b64adcce0e72c0d4109f01.tar.gz
CMake-5700deb16af5a0ff34b64adcce0e72c0d4109f01.tar.bz2
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
Diffstat (limited to 'Source/cmExtraCodeBlocksGenerator.cxx')
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx66
1 files 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<std::string, std::string> 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<std::string, cmSourceFile*> cFiles;
+ std::set<std::string> otherFiles;
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
lg!=lgs.end(); lg++)
{
@@ -250,7 +253,32 @@ void cmExtraCodeBlocksGenerator
for (std::vector<cmSourceFile*>::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<std::string>::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<std::string, std::string>::const_iterator
- sit=sourceFiles.begin();
- sit!=sourceFiles.end();
+ for (std::map<std::string, cmSourceFile*>::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<std::string>::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<std::string, std::string>::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<std::string, cmSourceFile*>::const_iterator
+ sit=cFiles.begin();
+ sit!=cFiles.end();
+ ++sit)
+ {
+ fout<<" <Unit filename=\""<< sit->first <<"\">\n"
+ " </Unit>\n";
+ }
+ for (std::set<std::string>::const_iterator
+ sit=otherFiles.begin();
+ sit!=otherFiles.end();
++sit)
{
- fout<<" <Unit filename=\""<<sit->first <<"\">\n"
+ fout<<" <Unit filename=\""<< sit->c_str() <<"\">\n"
" </Unit>\n";
}