BUG: fix #5326: source files with the same name in different groups lead to colliding object file names
Alex
This commit is contained in:
parent
8302ea66d2
commit
94f0eca689
|
@ -50,6 +50,61 @@ bool cmLocalVisualStudioGenerator::SourceFileCompiles(const cmSourceFile* sf)
|
|||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalVisualStudioGenerator::CountObjectNames(
|
||||
const std::vector<cmSourceGroup>& groups,
|
||||
std::map<cmStdString, int>& counts)
|
||||
{
|
||||
for(unsigned int i = 0; i < groups.size(); ++i)
|
||||
{
|
||||
cmSourceGroup sg = groups[i];
|
||||
std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
|
||||
for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
|
||||
s != srcs.end(); ++s)
|
||||
{
|
||||
const cmSourceFile* sf = *s;
|
||||
if(this->SourceFileCompiles(sf))
|
||||
{
|
||||
std::string objectName = cmSystemTools::LowerCase(
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(
|
||||
sf->GetFullPath()));
|
||||
objectName += ".obj";
|
||||
counts[objectName] += 1;
|
||||
}
|
||||
}
|
||||
this->CountObjectNames(sg.GetGroupChildren(), counts);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalVisualStudioGenerator::InsertNeedObjectNames(
|
||||
const std::vector<cmSourceGroup>& groups,
|
||||
std::map<cmStdString, int>& count)
|
||||
{
|
||||
for(unsigned int i = 0; i < groups.size(); ++i)
|
||||
{
|
||||
cmSourceGroup sg = groups[i];
|
||||
std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
|
||||
for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
|
||||
s != srcs.end(); ++s)
|
||||
{
|
||||
const cmSourceFile* sf = *s;
|
||||
if(this->SourceFileCompiles(sf))
|
||||
{
|
||||
std::string objectName = cmSystemTools::LowerCase(
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
|
||||
objectName += ".obj";
|
||||
if(count[objectName] > 1)
|
||||
{
|
||||
this->NeedObjectName.insert(sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->InsertNeedObjectNames(sg.GetGroupChildren(), count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
|
||||
(std::vector<cmSourceGroup> const& sourceGroups)
|
||||
|
@ -60,50 +115,11 @@ void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
|
|||
// Count the number of object files with each name. Note that
|
||||
// windows file names are not case sensitive.
|
||||
std::map<cmStdString, int> objectNameCounts;
|
||||
for(unsigned int i = 0; i < sourceGroups.size(); ++i)
|
||||
{
|
||||
cmSourceGroup sg = sourceGroups[i];
|
||||
std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
|
||||
for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
|
||||
s != srcs.end(); ++s)
|
||||
{
|
||||
const cmSourceFile* sf = *s;
|
||||
if(this->SourceFileCompiles(sf))
|
||||
{
|
||||
std::string objectName =
|
||||
cmSystemTools::LowerCase(
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(
|
||||
sf->GetFullPath()));
|
||||
objectName += ".obj";
|
||||
objectNameCounts[objectName] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
this->CountObjectNames(sourceGroups, objectNameCounts);
|
||||
|
||||
// For all source files producing duplicate names we need unique
|
||||
// object name computation.
|
||||
for(unsigned int i = 0; i < sourceGroups.size(); ++i)
|
||||
{
|
||||
cmSourceGroup sg = sourceGroups[i];
|
||||
std::vector<const cmSourceFile*> const& srcs = sg.GetSourceFiles();
|
||||
for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
|
||||
s != srcs.end(); ++s)
|
||||
{
|
||||
const cmSourceFile* sf = *s;
|
||||
if(this->SourceFileCompiles(sf))
|
||||
{
|
||||
std::string objectName =
|
||||
cmSystemTools::LowerCase(
|
||||
cmSystemTools::GetFilenameWithoutLastExtension(
|
||||
sf->GetFullPath()));
|
||||
objectName += ".obj";
|
||||
if(objectNameCounts[objectName] > 1)
|
||||
{
|
||||
this->NeedObjectName.insert(sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this->InsertNeedObjectNames(sourceGroups, objectNameCounts);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -46,6 +46,11 @@ protected:
|
|||
// Safe object file name generation.
|
||||
void ComputeObjectNameRequirements(std::vector<cmSourceGroup> const&);
|
||||
bool SourceFileCompiles(const cmSourceFile* sf);
|
||||
void CountObjectNames(const std::vector<cmSourceGroup>& groups,
|
||||
std::map<cmStdString, int>& count);
|
||||
void InsertNeedObjectNames(const std::vector<cmSourceGroup>& groups,
|
||||
std::map<cmStdString, int>& count);
|
||||
|
||||
std::set<const cmSourceFile*> NeedObjectName;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue