ENH: INCLUDE_DIRECTORIES should have been written to prepend to the include path so that the most local directories are included first. This is a patch from Alex to resolve the problem by allowing users to switch the default using a variable CMAKE_INCLUDE_DIRECTORIES_BEFORE and then still explicitly appending or prepending by using AFTER or BEFORE arguments explicitly.

This commit is contained in:
Brad King 2006-04-04 09:35:22 -04:00
parent 66faeeeab4
commit cddedaa7d8
2 changed files with 13 additions and 4 deletions

View File

@ -26,12 +26,18 @@ bool cmIncludeDirectoryCommand::InitialPass(std::vector<std::string> const& args
std::vector<std::string>::const_iterator i = args.begin(); std::vector<std::string>::const_iterator i = args.begin();
bool before = false; bool before = this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
if ((*i) == "BEFORE") if ((*i) == "BEFORE")
{ {
before = true; before = true;
++i; ++i;
} }
else if ((*i) == "AFTER")
{
before = false;
++i;
}
for(; i != args.end(); ++i) for(; i != args.end(); ++i)
{ {

View File

@ -61,10 +61,13 @@ public:
virtual const char* GetFullDocumentation() virtual const char* GetFullDocumentation()
{ {
return return
" INCLUDE_DIRECTORIES([BEFORE] dir1 dir2 ...)\n" " INCLUDE_DIRECTORIES([AFTER|BEFORE] dir1 dir2 ...)\n"
"Add the given directories to those searched by the compiler for " "Add the given directories to those searched by the compiler for "
"include files. If BEFORE is specified, the directories are prepended " "include files. By default the directories are appended onto "
"onto the current list of directories instead of appended."; "the current list of directories. This default behavior can be "
"changed by setting CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. "
"By using BEFORE or AFTER you can select between appending and "
"prepending, independent from the default. ";
} }
cmTypeMacro(cmIncludeDirectoryCommand, cmCommand); cmTypeMacro(cmIncludeDirectoryCommand, cmCommand);