how to order include directories best ?

Brad King brad.king at kitware.com
Tue Apr 25 16:04:03 CEST 2006


David Faure wrote:
> On Sun, Apr 23, 2006 at 11:33:53AM +0200, Alexander Neundorf wrote:
>>When building a KDE module, it is required that it prefers the headers in the 
>>module sources over the installed headers.
> 
> Could maybe the solution be that cmake automatically puts all
>  -I<relative path>
> before all
>  -I<absolute path>
> ?

I think what we really want is that all the include directories inside 
the user project come before all the diretories outside the user 
project.  I've added an option to the CMake generators.  If the project does

   SET(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE 1)

then this include directory ordering will be used.  KDE can set it in 
the same place it currently sets CMAKE_INCLUDE_DIRECTORIES_BEFORE. 
We'll include this change in the 2.4 release.

>>I think this should work for most cases. And I think we should even go that 
>>far to add a commit hook, which complains if INCLUDE_DIRECTORIES() is used 
>>without BEFORE or AFTER, giving a warning right now (is this possible ?) and 
>>reject the commit once everything builds reliably with cmake.
> 
> Can't we then simply redefine include_directories so that it barfs if neither
> BEFORE nor AFTER was passed? If something can be checked by cmake or a cmake
> macro, it would be better than checking when importing (which only happens
> for code in kde svn but not for 3rd party code).

You can do this by creating a kde4_add_include_directories macro and 
suggesting that user projects use it, but we will not add this to CMake. 
  There are plenty of projects that have been using CMake for years 
without either of these options...by using unique header names 
(myproj/foo.h or myprojFoo.h).

-Brad


More information about the Kde-buildsystem mailing list