[ROOT-8062] Add INTERFACE_INCLUDE_DIRECTORIES and namespacing to exported/imported CMake targets Created: 16/Mar/16 Updated: 15/May/18 Resolved: 01/Mar/18 |
|
Status: |
Closed |
Project: |
|
Component/s: |
|
Affects Version/s: |
|
Fix Version/s: |
Type: |
New Feature |
Priority: |
Medium |
Reporter: |
Assignee: |
||
Resolution: |
Fixed |
Votes: |
2 |
None |
|||
Remaining Estimate: |
Not Specified |
||
Time Spent: |
Not Specified |
||
Original Estimate: |
Not Specified |
||
Environment: |
All |
01/Mar/18 |
|
16/Mar/16 |
|
01/Mar/18 3:14 PM |
Description |
|
I'd like to request that ROOT's
CMake package configuration files add usage requirements The main usage requirement I'd like to request is use of the INTERFACE_INCLUDE_DIRECTORIES property on targets, that can be set using the target_include_directories command: https://cmake.org/cmake/help/v2.8.12/cmake.html#command:target_include_directories This can help both internally and externally as setting the include directories on a target means a client of the target does not need to explicitly call include_directories. For example, instead of doing
a client can simply do and CMake will handle adding the requisite include paths to the compilation of {{MyTarget}}s sources. I'd also like to request a "namespace" for the ROOT imported targets both to avoid name clashes and to clarify the origin of a consumed target in client scripts, e.g. A client can then do, for example
and not have a name clash between the internal and ROOT targets. Clients using the ROOT_LIBRARIES variable are not affected as the namespacing is hidden to them. The additional benefit here is that usage requirements are transitively applied and have public/private scope, so if the Client package exposes ROOT in its interface, it only needs to re-find ROOT in its own "ClientPackageConfig.cmake" file rather than manually configure/set up include directories (which might hard-code values). That helps both ease of use and creation of fully relocatable packages. Additional usage requirements such as compile options, definitions and features would be helpful, but I think the above are the most useful.
|
Comments |
|
Comment by Pere Mato Vila [ 24/Nov/16 ] |
|||||
Hi Ben, sorry for being very late on this one. I have
implemented the namespace for libraries with the following
commit What is not clear to me is how to implement the first part of your request. In particular, when using the command target_include_directories() I do not know what to put in there, the current location of the header files in the binary directory or the installation location. We have all the header files grouped under the same heading. I do not think is make sense that each library adds again the include directory pointing to the same place. Any light on this would be very much appreciated. |
|||||
Comment by Benjamin Morgan [ 29/Nov/16 ] |
|||||
Hi Pere, For target_include_directories, there are a couple of ways to do handle it. To retain the current build behaviour (include_directories) and just get INTERFACE_INCLUDE_DIRECTORIES in the installed targets, the INCLUDES DESTINATION argument to install(TARGETS ...) could be used with $CMAKE_INSTALL_INCLUDEDIR/root as input. If generator expressions are allowed in ROOT's targets then target_include_directories can handle both build and install contexts with something like However, I've had issues with dictionary generation when target-level include directories are used as ROOT_GENERATE_DICTIONARY and similar only use the directory level INCLUDE_DIRECTORIES property and don't consider target properties. It should be possible to use the above in addition to current include_directories calls without conflict as CMake should strip out duplicated entries (see below). Regarding repeated -I arguments, I think that for targets within a package/namespace, duplicate entries in expansion of INTERFACE_INCLUDE_DIRECTORIES will be removed, so in the install context should only result in -I/path/to/headers being added once in compilation commands for MyTarget sources. This should also be the same in the build context. I've tested this on CMake 3.3/3.6/3.7 with a test project of two libraries (when they don't link and when they do), and the header path only appears once even when linking both libraries - that's a very simple case though, so quite possible ROOT's larger dependency tree may cause other effects. |
|||||
Comment by Pere Mato Vila [ 29/Nov/16 ] |
|||||
Hi Ben. Thanks very much for the clear explanation. I'll give it a ry. |
|||||
Comment by Dennis Klein [ 11/Sep/17 ] |
|||||
We also would very much appreciate the added INTERFACE_INCLUDE_DIRECTORIES property to the exported targets. Currently, we use a workaround after the find_package(ROOT) call: This workaround is ofc ugly, because of the hardcoded target list, which will go out of sync over time. We would also love an exported variable that contains just a list of all exported targets. |
|||||
Comment by Guilherme Amadio [ 01/Mar/18 ] |
|||||
I believe that this has been solved by the commit below:
Can someone please confirm and close this issue? |
Generated at Sun Oct 10 08:00:48 CEST 2021 using Jira 8.17.0#817000-sha1:a507a62ee263f31d253569e578e747c4fedadad0.
Tags: cmake targets, on cmake, cmake, [root8062], exportedimported, targets, interfaceincludedirectories, namespacing