summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-04-25 13:54:12 (GMT)
committerBrad King <brad.king@kitware.com>2006-04-25 13:54:12 (GMT)
commit8c02cc662734a93d5168cb1e5aec2ad5d2aafd15 (patch)
tree3f71f2ef2a8b58b2ab788d3566e24392143ee2eb /Source/cmLocalGenerator.cxx
parentdbd70091f16e81f685228af8fc80b96fdddcbd08 (diff)
downloadCMake-8c02cc662734a93d5168cb1e5aec2ad5d2aafd15.zip
CMake-8c02cc662734a93d5168cb1e5aec2ad5d2aafd15.tar.gz
CMake-8c02cc662734a93d5168cb1e5aec2ad5d2aafd15.tar.bz2
ENH: Added option CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE to put all in-project include directories before all out-of-project include directories.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx31
1 files changed, 28 insertions, 3 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 988db36..7707c3d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1103,15 +1103,40 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs)
}
}
- // Construct the ordered list.
+ // Get the project-specified include directories.
std::vector<std::string>& includes = this->Makefile->GetIncludeDirectories();
+
+ // Support putting all the in-project include directories first if
+ // it is requested by the project.
+ if(this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"))
+ {
+ const char* topSourceDir = this->Makefile->GetHomeDirectory();
+ const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory();
+ for(std::vector<std::string>::iterator i = includes.begin();
+ i != includes.end(); ++i)
+ {
+ // Emit this directory only if it is a subdirectory of the
+ // top-level source or binary tree.
+ if(cmSystemTools::ComparePath(i->c_str(), topSourceDir) ||
+ cmSystemTools::ComparePath(i->c_str(), topBinaryDir) ||
+ cmSystemTools::IsSubDirectory(i->c_str(), topSourceDir) ||
+ cmSystemTools::IsSubDirectory(i->c_str(), topBinaryDir))
+ {
+ if(emitted.insert(*i).second)
+ {
+ dirs.push_back(*i);
+ }
+ }
+ }
+ }
+
+ // Construct the final ordered include directory list.
for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i)
{
- if(emitted.find(*i) == emitted.end())
+ if(emitted.insert(*i).second)
{
dirs.push_back(*i);
- emitted.insert(*i);
}
}
}