From e75992a871705131be41b56873522db5c62ce8e3 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 2 Dec 2004 13:14:14 -0500 Subject: [PATCH] BUG: fix for 1369 before include directories need to be always added --- Source/cmMakefile.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 445985afb..3187c4b2b 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::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)