Merge topic 'cbp-unit-targets'
099b0cab
CodeBlocks: Declare which source file belongs to which targets.
This commit is contained in:
commit
a6d488f2ce
|
@ -376,11 +376,13 @@ void cmExtraCodeBlocksGenerator
|
||||||
fout<<" </Build>\n";
|
fout<<" </Build>\n";
|
||||||
|
|
||||||
|
|
||||||
// Collect all used source files in the project
|
// Collect all used source files in the project.
|
||||||
// Sort them into two containers, one for C/C++ implementation files
|
// Keep a list of C/C++ source files which might have an acompanying header
|
||||||
// which may have an acompanying header, one for all other files
|
// that should be looked for.
|
||||||
std::map<std::string, cmSourceFile*> cFiles;
|
typedef std::map<std::string, CbpUnit> all_files_map_t;
|
||||||
std::set<std::string> otherFiles;
|
all_files_map_t allFiles;
|
||||||
|
std::vector<std::string> cFiles;
|
||||||
|
|
||||||
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++)
|
||||||
{
|
{
|
||||||
|
@ -429,15 +431,15 @@ void cmExtraCodeBlocksGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// then put it accordingly into one of the two containers
|
std::string fullPath = (*si)->GetFullPath();
|
||||||
if (isCFile)
|
|
||||||
|
if(isCFile)
|
||||||
{
|
{
|
||||||
cFiles[(*si)->GetFullPath()] = *si ;
|
cFiles.push_back(fullPath);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
otherFiles.insert((*si)->GetFullPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CbpUnit &cbpUnit = allFiles[fullPath];
|
||||||
|
cbpUnit.Targets.push_back(&(ti->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: // intended fallthrough
|
default: // intended fallthrough
|
||||||
|
@ -447,19 +449,21 @@ void cmExtraCodeBlocksGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following loop tries to add header files matching to implementation
|
// The following loop tries to add header files matching to implementation
|
||||||
// files to the project. It does that by iterating over all source files,
|
// files to the project. It does that by iterating over all
|
||||||
|
// C/C++ source files,
|
||||||
// replacing the file name extension with ".h" and checks whether such a
|
// 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.
|
// 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, cmSourceFile*>::const_iterator
|
for (std::vector<std::string>::const_iterator
|
||||||
sit=cFiles.begin();
|
sit=cFiles.begin();
|
||||||
sit!=cFiles.end();
|
sit!=cFiles.end();
|
||||||
++sit)
|
++sit)
|
||||||
{
|
{
|
||||||
std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first);
|
std::string const& fileName = *sit;
|
||||||
|
std::string headerBasename=cmSystemTools::GetFilenamePath(fileName);
|
||||||
headerBasename+="/";
|
headerBasename+="/";
|
||||||
headerBasename+=cmSystemTools::GetFilenameWithoutExtension(sit->first);
|
headerBasename+=cmSystemTools::GetFilenameWithoutExtension(fileName);
|
||||||
|
|
||||||
// check if there's a matching header around
|
// check if there's a matching header around
|
||||||
for(std::vector<std::string>::const_iterator
|
for(std::vector<std::string>::const_iterator
|
||||||
|
@ -471,37 +475,38 @@ void cmExtraCodeBlocksGenerator
|
||||||
hname += ".";
|
hname += ".";
|
||||||
hname += *ext;
|
hname += *ext;
|
||||||
// if it's already in the set, don't check if it exists on disk
|
// 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 (allFiles.find(hname) != allFiles.end())
|
||||||
if (headerIt != otherFiles.end())
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
if(cmSystemTools::FileExists(hname.c_str()))
|
||||||
{
|
{
|
||||||
otherFiles.insert(hname);
|
allFiles[hname].Targets = allFiles[fileName].Targets;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert all source files in the CodeBlocks project
|
// insert all source files in the CodeBlocks project
|
||||||
// first the C/C++ implementation files, then all others
|
for (all_files_map_t::const_iterator
|
||||||
for (std::map<std::string, cmSourceFile*>::const_iterator
|
sit=allFiles.begin();
|
||||||
sit=cFiles.begin();
|
sit!=allFiles.end();
|
||||||
sit!=cFiles.end();
|
|
||||||
++sit)
|
++sit)
|
||||||
{
|
{
|
||||||
fout<<" <Unit filename=\""<< sit->first <<"\">\n"
|
std::string const& unitFilename = sit->first;
|
||||||
" </Unit>\n";
|
CbpUnit const& unit = sit->second;
|
||||||
}
|
|
||||||
for (std::set<std::string>::const_iterator
|
fout<<" <Unit filename=\""<< cmXMLSafe(unitFilename) <<"\">\n";
|
||||||
sit=otherFiles.begin();
|
|
||||||
sit!=otherFiles.end();
|
for(std::vector<const cmTarget*>::const_iterator ti = unit.Targets.begin();
|
||||||
++sit)
|
ti != unit.Targets.end(); ++ti)
|
||||||
{
|
{
|
||||||
fout<<" <Unit filename=\""<< *sit <<"\">\n"
|
std::string const& targetName = (*ti)->GetName();
|
||||||
" </Unit>\n";
|
fout<<" <Option target=\""<< cmXMLSafe(targetName) <<"\"/>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
fout<<" </Unit>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add CMakeLists.txt
|
// Add CMakeLists.txt
|
||||||
|
|
|
@ -39,6 +39,10 @@ public:
|
||||||
|
|
||||||
virtual void Generate();
|
virtual void Generate();
|
||||||
private:
|
private:
|
||||||
|
struct CbpUnit
|
||||||
|
{
|
||||||
|
std::vector<const cmTarget*> Targets;
|
||||||
|
};
|
||||||
|
|
||||||
void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
|
void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue