[cmake-developers] Setting include directories via target_link_libraries() ?
Brad King
brad.king at kitware.com
Tue Dec 18 11:25:19 EST 2012
On 12/18/2012 11:09 AM, Stephen Kelly wrote:
>> At generate time that property
>> will be used to accumulate values from INTERFACE_-like properties on
>> the named interfaces and append them to LINK_LIBRARIES, etc.
>
> You wrote before that you don't propose using properties and generator
> expressions:
Well, the raw properties (e.g. INCLUDE_DIRECTORIES) would initially
populate the generate-time C++ structures. Then the structures would
be extended after evaluating interfaces of dependencies.
>> This can all be done inside C++ structures rather than with
>> properties and generator expressions because it is only done during
>> generation.
>
> That is the kind of thing I'm confused about. I don't see what value the
> USE_INTERFACES property adds.
1. It puts the transitivity in one place rather than separately
in each kind of build property.
2. It makes interfaces first-class rather than hidden behind linking.
3. There is no change in behavior for existing use cases because the
new behavior comes only from new interfaces.
> Here's some code that works with my branch (imagining a new command, and
> without the USE_INTERFACES property). How would it look with your proposal?
>
> add_library(foo ...)
> set_property(TARGET foo PROPERTY INTERFACE_INCLUDE_DIRECTORIES
> $<$<CONFIG:Debug>:/foo/include>
> )
>
> add_executable(bar ...)
> target_use_interfaces(bar INTERFACES foo)
They keyword "INTERFACES" might not be the same but otherwise the
example would work in my proposed approach.
> The idea of a new command and the idea of a non-granular USE_INTERFACE
> property are not tied together. But if you clarify what you wrote about
> how/when *_INTERFACE properties would be used, that would at least get the
> understanding of your proposal off the ground.
In the above example the target_use_interfaces command would not do
anything except append foo to bar's USE_INTERFACES property. Then at
generate time for building bar, CMake would read its USE_INTERFACES
and see that it needs to include the interface defined by foo. It
would then go read INTERFACE_INCLUDE_DIRECTORIES from foo and append
the value to bar's include directories when generating.
-Brad
More information about the cmake-developers
mailing list