Using target_include_directories()

Stephen Kelly steveire at gmail.com
Mon Mar 25 18:40:28 UTC 2013


Alexander Neundorf wrote:

>> > This is done e.g. in kwidgets:
>> > 
>> > target_include_directories(kwidgets PUBLIC
>> > 
>> >     "$<BUILD_INTERFACE:${kwidgets_INCLUDES}>"
>> >     "$<TARGET_PROPERTY:kdeui,INTERFACE_INCLUDE_DIRECTORIES>"
>> >     
>> >      )
>> > 
>> > I got a question here, why is not simply "kdeui" used, but why does the
>> > INTERFACE_INCLUDE_DIRECTORIES target property have to be used ?
>> 
>> Usually target_link_libraries() is used instead, which takes target
>> names.
> 
> target_include_directories() also accepts target names, according to the
> documentation (and I think I also tried it), doesn't it ?

We changed that after this thread:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/5925/focus=5964

I've pushed a patch to fix the docs.

> 
>> > Also, does this apply to the BUILD and INSTALL interface
>> 
>> Yes, it applies to both, because it is not wrapped in either specifier. I
>> can't think of any reason it would be appropriate for KDE to have
>> something like that wrapped in BUILD_INTERFACE or INSTALL_INTERFACE.
> 
> I'm not sure I understand how you mean that.
> Do you mean in general or specifically why the kdeui include dir should be
> restricted to one of the two ?

I mean in general.

If target foo headers need target bar headers, then the bar include paths 
are needed whether foo is used in-build or from an installed location.

> This is not just about me understanding this.
> This is also about spreading information for everybody else, so "read the
> code" doesn't help here.
> So, how do you explain what the lines above do to somebody who knows less
> about this than I do ?

 target_include_directories(kwidgets PUBLIC
     "$<BUILD_INTERFACE:${kwidgets_INCLUDES}>"
     "$<TARGET_PROPERTY:kdeui,INTERFACE_INCLUDE_DIRECTORIES>"
      )

The $<TARGET_PROPERTY:kdeui,INTERFACE_INCLUDE_DIRECTORIES> is fairly niche. 
It's only needed currently because kwidgets and kdeui have circular 
dependencies to each other. 

All the lines together mean 'kwidgets publically depends on the include dirs 
in the kwidgets_INCLUDES variable if kwidgets is used from this buildsystem. 
It also depends on the interface includes of kdeui.'

Thanks,

Steve.




More information about the Kde-buildsystem mailing list