CMake usage requirements in KDE Frameworks

Stephen Kelly steveire at gmail.com
Mon Mar 18 23:06:48 UTC 2013


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.

>> 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/focus=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.

> 
>> 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")

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>"
 )

>  
> 
> Thanks for the nice explanation :-)
> Alex

You're welcome.

Thanks,

Steve.




More information about the Kde-frameworks-devel mailing list