summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2004-12-02 18:14:14 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2004-12-02 18:14:14 (GMT)
commite75992a871705131be41b56873522db5c62ce8e3 (patch)
treeb154f3109b5cafd8b088868acbf4e28c60024e38
parentec6b579717a966d765dfbbc1ed5a16e8ffc769e4 (diff)
downloadCMake-e75992a871705131be41b56873522db5c62ce8e3.zip
CMake-e75992a871705131be41b56873522db5c62ce8e3.tar.gz
CMake-e75992a871705131be41b56873522db5c62ce8e3.tar.bz2
BUG: fix for 1369 before include directories need to be always added
-rw-r--r--Source/cmMakefile.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 445985a..3187c4b 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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
// getting much bigger than 20. We cannot use a set because of
// order dependency of the include path.
- if(std::find(m_IncludeDirectories.begin(),
- m_IncludeDirectories.end(), inc) == m_IncludeDirectories.end())
+ std::vector<std::string>::iterator i =
+ std::find(m_IncludeDirectories.begin(),
+ m_IncludeDirectories.end(), inc);
+ if(i == m_IncludeDirectories.end())
{
if (before)
{
@@ -892,6 +894,16 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before)
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)