ENH: Added option CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE to put all in-project include directories before all out-of-project include directories.

This commit is contained in:
Brad King 2006-04-25 09:54:12 -04:00
parent dbd70091f1
commit 8c02cc6627
1 changed files with 28 additions and 3 deletions

View File

@ -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);
}
}
}