CMake usage requirements in KDE Frameworks

Alexander Neundorf neundorf at kde.org
Tue Mar 19 20:02:09 UTC 2013


On Tuesday 19 March 2013, Stephen Kelly wrote:
> Alexander Neundorf wrote:
> >> which automatically adds
> >> 
> >>  "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};
> >> 
> >> ${CMAKE_CURRENT_SOURCE_DIR}>"
> >> 
> >> to the INTERFACE_INCLUDE_DIRECTORIES of each target.
> > 
> > Since cmake 2.4.0. the global cmake variable CMAKE_INCLUDE_CURRENT_DIR
> > exists. When set to TRUE, cmake automatically adds
> > CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR to the include
> > dirs.
> > 
> > I would say the name CMAKE_BUILD_INTERFACE_INCLUDES is too generic, it
> > should have a name which is more similar to CMAKE_INCLUDE_CURRENT_DIR,
> > since it does something quite similar, maybe
> > CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ?
> 
> I don't mind renaming it, but it's a topic for the cmake list.

Yes, but since you posted here... :-)
CCing...


So, I think the variable name CMAKE_BUILD_INTERFACE_INCLUDES is to general.
Since it is similar to the effect of CMAKE_INCLUDE_CURRENT_DIR, I suggest 
renaming it e.g. to CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.

> >> In the future there will also be a convenience to add
> >> 
> >>  "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
> >> 
> >> to each target, but we don't have that yet.
> > 
> > Do you mean a hardcoded "/include" ?
> > IMO this is too much guessing. Nowhere else (except when searching stuff)
> > cmake assumes anything about your install destinations.
> 
> Yes, sorry I wasn't clear about this part.
> 
>  http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/5734/focu
> s=5767
> 
> What I actually propose would look something like
> 
>  install(TARGETS KArchive EXPORT KArchiveTargets NAMESPACE KF5::
>    ...
>    INCLUDES DESTINATION "$<INSTALL_PREFIX>/${INCLUDES_INSTALL_DIR}"
>  )
> 
> so it could be folded into INSTALL_TARGETS_DEFAULT_ARGS. I don't know if it
> will be that easy in the end though.

Two comments on that: ${INCLUDE_INSTALL_DIR} can currently be both a relative 
or an absolute path. Do you want to drop that ?

install(TARGETS ...) already supports PRIVATE_HEADER and PUBLIC_HEADER 
destinations. They are currently used for OSX frameworks.
The proposed INCLUDES destination looks quite similar, maybe it is not 
necessary to add it, but the existing ones can be used.

> >> Private include directories are listed in the INCLUDE_DIRECTORIES
> >> property. Public include directories are listed in the
> >> INCLUDE_DIRECTORIES and in the INTERFACE_INCLUDE_DIRECTORIES property.
> >> If a directory appears in the INTERFACE_INCLUDE_DIRECTORIES but not in
> >> the INCLUDE_DIRECTORIES property of a target, that means that it will
> >> not be used to compile the target, but will be used by the user of the
> >> target.
> >> 
> >> A new command is also introduced in CMake 2.8.11 to set this stuff
> >> 
> >> conveniently:
> >>  add_library(foo ...)
> >>  
> >>  target_include_directories(foo PRIVATE "/foo/private")
> >>  target_include_directories(foo PUBLIC "/foo/public")
> >>  target_include_directories(foo INTERFACE "/foo/interface/only")
> > 
> > Does this actually apply to the BUILD or to the INSTALL include interface
> > ?
> 
>  target_include_directories(foo PRIVATE "/foo/private")
> 
> applies to neither. The PRIVATE entries don't go into the
> INTERFACE_INCLUDE_DIRECTORIES at all.
>
>  target_include_directories(foo PUBLIC "/foo/public")
>  target_include_directories(foo INTERFACE "/foo/interface/only")

Ok, so I could do the above also with the following, right ?
target_include_directories(foo PRIVATE "/foo/public" "/foo/private")
target_include_directories(foo INTERFACE "/foo/public" "/foo/interface/only")

 
> applies to both the BUILD and INSTALL include interfaces. To limit it to
> one or the other, you have to specify it:
> 
>  target_include_directories(foo INTERFACE
>    "$<BUILD_INTERFACE:/foo/interface/only>"
>  )

Why was this generator expression approach chosen over simply adding suitable 
keywords, as it is done for all other cmake commands ?

target_include_directories(foo INTERFACE_BUILD ${CMAKE_CURRENT_SOURCE_DIR} 
                                               ${CMAKE_CURRENT_SOURCE_DIR}/whatever/
                                               ${CMAKE_CURRENT_BINARY_DIR}
                               INTERFACE_INSTALL ${INCLUDE_INSTALL_DIR} ) 


Alex

P.S. I know I'm late, but I lost track in the huge threads on cmake-devel


More information about the Kde-frameworks-devel mailing list