[cmake-developers] INTERFACE_LIBRARY target type

Brad King brad.king at kitware.com
Thu May 2 14:05:59 EDT 2013


On 05/02/2013 11:26 AM, Stephen Kelly wrote:
> 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)

No, I like to be able to say that all logical target names are
created by an add_* call.  Actually your point about scopes of
target names means that ALIAS targets should be scoped like
IMPORTED targets since their purpose is to "self-import".  That
is an argument for ALIAS targets to be built on IMPORTED targets.

> This might need some deeper consideration. I like that IMPORTED targets can 
> not be re-exported, and I would expect the same for the INTERFACE_LIBRARY 
> type.

How should a project define an interface library and get CMake
to put it in a targets file through install(EXPORT) or export()?
Shouldn't header-only libraries be able to work like that?

> IMPORTED targets also have a different scope to non-imported targets. I'd 
> expect that if I find_package somewhere and a KF5::iface INTERFACE_LIBRARY 
> results, that follows the same scope rules as KF5::KArchive.

Perhaps IMPORTED and INTERFACE are orthogonal.  One could import
an interface library defined by another project.  I'll retract my
previous assertion that IMPORTED targets should always refer to
files.

-Brad



More information about the cmake-developers mailing list