[cmake-developers] INTERFACE_LIBRARY target type

Alexander Neundorf neundorf at kde.org
Thu May 2 15:37:44 EDT 2013


On Thursday 02 May 2013, Stephen Kelly wrote:
> Brad King wrote:
> >> Having said that, would IMPORTED targets actually be good enough for all
> >> the things you list, maybe with some wrapper macros ?
> > 
> > The IMPORTED targets still need to have an IMPORTED_LOCATION that refers
> > to a real file, so they are not quite equivalent to the proposed
> > INTERFACE or ALIAS targets.  What they all share in common is the lack
> > of build-time actions.
> 
> Actually it might be useful to make it possible to do this:
> 
>  add_library(foo SHARED foo.cpp)
>  add_library(bar SHARED bar.cpp)
>  add_library(iface INTERFACE)
>  target_link_libraries(iface INTERFACE foo bar)
> 
> and have
> 
>  make iface
> 
> cause a (re)build of foo and bar if necessary. This would be in conflict
> with the idea of considering targets with double colons to be imported
> targets if the INTERFACE_LIBRARY was used in the alias pattern I described
> before.
> 
> Perhaps we could do aliasing with a target property instead?
> 
>  add_library(foo SHARED foo.cpp)
>  set_property(TARGET foo APPEND PROPERTY ALIAS_NAME KF5::foo)

Why would I want an alias ?
Doesn't that make things only more complicated ?
If I have to be flexible on the name, I can do that right now already

if(something)
  set(theTargetName KF5::foo)
else()
  set(theTargetName foo)
endif()

tll(blub ${theTargetName})


Alex



More information about the cmake-developers mailing list