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
This commit is contained in:
parent
32258b44bc
commit
5700deb16a
|
@ -230,7 +230,10 @@ void cmExtraCodeBlocksGenerator
|
||||||
|
|
||||||
|
|
||||||
// Collect all used source files in the project
|
// 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();
|
for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
|
||||||
lg!=lgs.end(); lg++)
|
lg!=lgs.end(); lg++)
|
||||||
{
|
{
|
||||||
|
@ -250,7 +253,32 @@ void cmExtraCodeBlocksGenerator
|
||||||
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
|
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
|
||||||
si!=sources.end(); si++)
|
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
|
default: // intended fallthrough
|
||||||
|
@ -265,9 +293,9 @@ void cmExtraCodeBlocksGenerator
|
||||||
// file exists. If it does, it is inserted into the map of files.
|
// 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
|
// A very similar version of that code exists also in the kdevelop
|
||||||
// project generator.
|
// project generator.
|
||||||
for (std::map<std::string, std::string>::const_iterator
|
for (std::map<std::string, cmSourceFile*>::const_iterator
|
||||||
sit=sourceFiles.begin();
|
sit=cFiles.begin();
|
||||||
sit!=sourceFiles.end();
|
sit!=cFiles.end();
|
||||||
++sit)
|
++sit)
|
||||||
{
|
{
|
||||||
std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first);
|
std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first);
|
||||||
|
@ -283,21 +311,37 @@ void cmExtraCodeBlocksGenerator
|
||||||
std::string hname=headerBasename;
|
std::string hname=headerBasename;
|
||||||
hname += ".";
|
hname += ".";
|
||||||
hname += *ext;
|
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()))
|
if(cmSystemTools::FileExists(hname.c_str()))
|
||||||
{
|
{
|
||||||
sourceFiles[hname] = hname;
|
otherFiles.insert(hname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert all used source files in the CodeBlocks project
|
// insert all source files in the CodeBlocks project
|
||||||
for (std::map<std::string, std::string>::const_iterator
|
// first the C/C++ implementation files, then all others
|
||||||
sit=sourceFiles.begin();
|
for (std::map<std::string, cmSourceFile*>::const_iterator
|
||||||
sit!=sourceFiles.end();
|
sit=cFiles.begin();
|
||||||
|
sit!=cFiles.end();
|
||||||
++sit)
|
++sit)
|
||||||
{
|
{
|
||||||
fout<<" <Unit filename=\""<<sit->first <<"\">\n"
|
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->c_str() <<"\">\n"
|
||||||
" </Unit>\n";
|
" </Unit>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue