Using target_include_directories()

Alexander Neundorf neundorf at kde.org
Mon Mar 25 18:09:16 UTC 2013


On Sunday 24 March 2013, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> > Hi,
> > 
> > we now are using the new cmake command target_include_directories() in
> > kde frameworks.
> > This makes it possible to specifiy per-target include directories.
> > When using the keyword PRIVATE, it's the include directories when
> > building the targets, INTERFACE is the include directories necessary
> > when using that target, and PUBLIC applies to both.
> > You can list directories (as you are used to), and also targets (this is
> > new), from the those include directories will be used, which have been
> > put into their interface via PUBLIC or INTERFACE.
> 
> Hi Alex,
> 
> Is there anything here that was not in my explanatory email, or is there
> some other reason to send this, or something that needs a response?

It won't hurt to repeat some things here for others on the mailing list.

> > 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 ?

> > 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 ?

> > or is the BUILD
> > interface of kdeui extracted for BUILD interface of kwidgets and
> > respectively also for the INSTALL interface ?
> 
> Perhaps looking at the generated config files provides the best answer. My
> writing prose here is second-best compared to what you can read and
> understand in your own way in the code. If understanding is your goal, I
> suggest just experimenting with it.

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 ?

Alex


More information about the Kde-buildsystem mailing list