BUG: fix for 1369 before include directories need to be always added

This commit is contained in:
Bill Hoffman 2004-12-02 13:14:14 -05:00
parent ec6b579717
commit e75992a871
1 changed files with 14 additions and 2 deletions

View File

@ -879,8 +879,10 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
// this linear search results in n^2 behavior, but n won't be // this linear search results in n^2 behavior, but n won't be
// getting much bigger than 20. We cannot use a set because of // getting much bigger than 20. We cannot use a set because of
// order dependency of the include path. // order dependency of the include path.
if(std::find(m_IncludeDirectories.begin(), std::vector<std::string>::iterator i =
m_IncludeDirectories.end(), inc) == m_IncludeDirectories.end()) std::find(m_IncludeDirectories.begin(),
m_IncludeDirectories.end(), inc);
if(i == m_IncludeDirectories.end())
{ {
if (before) if (before)
{ {
@ -892,6 +894,16 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
m_IncludeDirectories.push_back(inc); m_IncludeDirectories.push_back(inc);
} }
} }
else
{
if(before)
{
// if this before and already in the path then remove it
m_IncludeDirectories.erase(i);
// WARNING: this *is* expensive (linear time) since it's a vector
m_IncludeDirectories.insert(m_IncludeDirectories.begin(), inc);
}
}
} }
void cmMakefile::AddDefinition(const char* name, const char* value) void cmMakefile::AddDefinition(const char* name, const char* value)