IMPORTED INTERFACE library should behave as normal INTERFACE library and not as IMPORTED library.
Currently, when comparing an IMPORTED
library with an INTERFACE
(header-only) library one realizes quickly that they have similar restrictions, but an INTERFACE
library is less strict when it comes to setting usage-requirements:
An IMPORTED
library
- can set
INTERFACE_*
properties usingset_target_properties
andset_property
, -
cannot set
INTERFACE_*
properties using any oftarget_compile_definitions
,target_include_directories
,target_compile_options
ortarget_link_libraries
, -
cannot set
INTERFACE_*
properties usingtarget_sources
, -
cannot be aliased (using
add_library(...ALIAS...)
).
An INTERFACE
library
- can set
INTERFACE_*
properties usingset_target_properties
andset_property
, -
can set
INTERFACE_*
properties using any oftarget_compile_definitions
,target_include_directories
,target_compile_options
ortarget_link_libraries
, -
can set
INTERFACE_*
properties usingtarget_sources
, -
can be aliased (using
add_library(...ALIAS...)
).
Some observations:
- I do not see any reason for an
IMPORTED
target to not being able to support the commands mentioned in 2 and 4. - Not supporting the command from 3 is debatable, although I would not have any problems with an
IMPORTED
target to provide its sources although they are not used to build that target. - Why an
IMPORTED
target should not be able to be aliased is not clear to me. An alias should just be that, an alias (name), which behaves the same as the original target it aliases. If it somehow looses the properties of the original target (e.g. no longer beingIMPORTED
) the concept of anALIAS
target seems to be flawed and should be reworked.
However, these observations are not the reason I created the ticket for.
My main-concern is, that an IMPORTED INTERFACE
library exactly behaves like a general IMPORTED
library (regarding my 4 points from above) although it should behave like a general INTERFACE
library:
An IMPORTED INTERFACE
library
- can set
INTERFACE_*
properties usingset_target_properties
andset_property
, -
cannot set
INTERFACE_*
properties using any oftarget_compile_definitions
,target_include_directories
,target_compile_options
ortarget_link_libraries
, -
cannot set
INTERFACE_*
properties usingtarget_sources
, -
cannot be aliased (using
add_library(...ALIAS...)
).