Using target_include_directories()
Alexander Neundorf
neundorf at kde.org
Mon Mar 25 20:09:03 UTC 2013
On Monday 25 March 2013, Stephen Kelly wrote:
> 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/focu
> s=5964
>
> I've pushed a patch to fix the docs.
Ah, ok :-)
> >> > 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.
Something which is in PUBLIC applies to
* building itself
* being used in-project
* being used as imported target
The difference between the first two is not that big, putting an include dir
into PUBLIC BUILD_INTERFACE doesn't add dependencies for the project compared
to putting it into PRIVATE, so being sloppy there won't break much typically.
PUBLIC does not imply automatically for the reader that kdeui is needed by
kwidgets headers.
If it was in INTERFACE, this would be obvious.
target_include_directories(kwidgets PUBLIC ...
"$<TARGET_PROPERTY:kdeui,INTERFACE_INCLUDE_DIRECTORIES>" )
But my question was actually the following: does the INSTALL interface of
kdeui end up in the INSTALL interface of kwidgets, and the BUILD interface of
kdeui goes into the BUILD interface of kwidgets ?
Alex
More information about the Kde-buildsystem
mailing list