[CMake] order of include dirs

Alexander Neundorf a.neundorf-work at gmx.net
Thu Mar 30 15:45:11 EST 2006


> --- Ursprüngliche Nachricht ---  
> Von: Brad King <brad.king at kitware.com>  
> An: Alexander Neundorf <a.neundorf-work at gmx.net>  
> Kopie: cmake at cmake.org  
> Betreff: Re: [CMake] order of include dirs  
> Datum: Thu, 30 Mar 2006 09:42:44 -0500  
>   
> Alexander Neundorf wrote:  
> >>Von: Brad King <brad.king at kitware.com>   
> >>   
> >>Alexander Neundorf wrote:   
> >>  
> >>>in KDE we have the problem that e.g. when compiling kdebase the   
> >>>headers    
> >>>in the source dir should be preferred over the installed ones.    
> >>>Usually we would do     
> >>>include_directories( ${KDE4_INCLUDES} ) in the toplevel   
> >>>CMakeLists.txt.    
> >>>When adding more include dirs in CMakeLists.txt in deeper   
> >>>directories, these directories will be appended to the list of   
> >>>include dirs, except when used with the BEFORE keyword.    
> >>>But now we cannot realistically expect that every KDE developer will   

> >>>always remember the BEFORE keyword.    
> >>>So we had two ideas:    
> >>>make the behaviour configurable:    
> >>># make prepend default:    
> >>>set(CMAKE_INCLUDE_DIRS_APPEND false)     
> >>># to force appending:    
> >>>include_directories(AFTER dir1 dir2)    
> >>>    
> >>>Problem here: moving cmake files around to another project where  
this    
> >>>isn't set would change the behaviour.    
> >>>    
> >>>Second idea:    
> >>>    
> >>>include_directories(LAST dir1 dir2)    
> >>>    
> >>>which would have the effect that the listed directories would always   
> >>>be used after all other include dirs specified without the "LAST"   
> >>>keyword.    
> >>  
> >>   
> >>I think that will create two ordered lists of include directories   
> >>instead of one, which will just be confusing.     
> >   
> >    
> > What about the first idea ?   
> > I think this would fit good to the include_directories() command.   
>   
> I think a magic switch that can easily be accidentally inherited by   
> projects not expecting it will not work well.  
  
Maybe.  
I think the order matters only if there is a file with the same name in  
several of the include directories.  
In that case I'd even go so far to say that if foo.h exists in a include  
dir specified in the top level CMakeLists.txt, but also in a directory  
which was added explicitely somewhere deeper in the source tree using  
INCLUDE_DIRECTORIES(), the intention was probably that this file should  
be prefered, since the include dir was specified more "locally" (which  
would equal always BEFORE by default).  
  
Bye  
Alex  
  

-- 
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl


More information about the CMake mailing list