Should target_link_options(staticLib PRIVATE -lfoo) pierce through static libs to the head target?

Currently if one calls target_link_libraries(staticLib PRIVATE myLib) the implementation of target_link_libraries ensures to also add a $<LINK_ONLY:myLib> on staticLib’s INTERFACE_LINK_LIBRARIES.

Should the same be done for link options as well, given that link options don’t make sense / are not used when archiving a static library?

From docs:
https://cmake.org/cmake/help/latest/command/target_link_options.html

This command cannot be used to add options for static library targets, since they do not use a linker.

Link options should be looked at when $<LINK_ONLY:> is used. Are they not?

@brad.king I would think it should, but I don’t see any tests for it. Would likely need a policy to change that though.

Cc: @marc.chevrier

See policy CMP0099.

Right. I couldn’t find relevant mentions of the behaviour in the docs of target_link_options / target_link_libraries and the associated properties
My test project was setting 3.14 as the minimum version.

Increasing the cmake minimum version which enables the policy does indeed propagate the link options.
Thanks!