Using target_include_directories()

Stephen Kelly steveire at gmail.com
Sun Mar 24 19:41:02 UTC 2013


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?

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

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

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

If 'kdeui' is a non-imported target whose interface property is being read 
for use by another target, only the BUILD_INTERFACE entries are read.

When 'kdeui' is exported using export(), the generated IMPORTED target has 
the INSTALL_INTERFACE entries stripped out. Only the BUILD_INTERFACE parts 
remain.

When 'kdeui' is exported using install(EXPORT), the generated IMPORTED 
target has the BUILD_INTERFACE entries stripped out. Only the 
INSTALL_INTERFACE parts remain.

Thanks,

Steve.




More information about the Kde-buildsystem mailing list