MantisBT - CMake
View Issue Details
0015119CMakeCMakepublic2014-08-31 04:222015-03-02 08:57
Alex Lamaison 
Stephen Kelly 
normalminoralways
closedno change required 
CMake 3.0 
 
0015119: target_include_directories(target INTERFACE) does make sense for custom targets
This commit https://gitorious.org/cmake/cmake/commit/510fdcb18801076e2041eaae2941375eecc93ec2 [^] says "Setting include directories or compile definitions on a target created with add_custom_target does not make sense". But that's not quite true.

If that custom target generates a header file in a particular directory then the INTERFACE variant of target_include_directories makes sense so other targets can pick up its usage requirements by 'linking' against it.

Similarly, if the generated header needs certain compile defintions to use it, the INTERFACE variant of target_compile_definitions also makes sense.
use add_custom_target to generate a header file in some directory.

use target_include_directories to expose the header file's directory as a usage requirement of that header.

configure.

CMake says "target_include_directories called with non-compilable target type".
No tags attached.
Issue History
2014-08-31 04:22Alex LamaisonNew Issue
2014-09-02 09:07Brad KingAssigned To => Stephen Kelly
2014-09-02 09:07Brad KingStatusnew => assigned
2014-09-09 18:52Stephen KellyNote Added: 0036766
2014-09-09 18:52Stephen KellyStatusassigned => resolved
2014-09-09 18:52Stephen KellyResolutionopen => no change required
2015-03-02 08:57Robert MaynardNote Added: 0038110
2015-03-02 08:57Robert MaynardStatusresolved => closed

Notes
(0036766)
Stephen Kelly   
2014-09-09 18:52   
You can't 'link against' a custom target.

Consider

 add_library(iface INTERFACE)
 target_include_directories(iface INTERFACE /foo/bar)

for your use-case.
(0038110)
Robert Maynard   
2015-03-02 08:57   
Closing resolved issues that have not been updated in more than 4 months.