LINK_OPTIONS: Add new family of properties
This family enable to manage link flags Three new properties: * directory property: LINK_OPTIONS * target properties: LINK_OPTIONS and INTERFACE_LINK_OPTIONS Two new commands * add_link_options(): to populate directory property * target_link_options(): to populate target properties Fixes: #16543
Is there a way to use this feature to make an import target library be surrounded by
--no-whole-archivein the link line of someone using that target? Maybe something like:
target_link_options(BEFORE Foo INTERFACE LINKER:--whole-archive) target_link_options(Foo INTERFACE LINKER:--no-whole--archive)
though I don't think that will actually ensure it surrounds the library.
I think the correct approach is to rely on both
target_link_options(Foo INTERFACE "SHELL:LINKER:--whole-archive $<TARGET_LINKER_FILE:Foo> LINKER:--no-whole-archive")
SHELL:will ensure all options will delivered as specified and will avoid any suppression due to option duplication. And
$<TARGET_LINKER_FILE:...>will ensure the library is specified between the two required keywords.
Awesome. This works great. While the library still is listed twice in the compiler commandline having it surrounded at least once still does the trick. Good thing it is a whole-archive block I'm using as it doesn't really matter where on the linker commandline that ends up ;) Thanks for your work on this feature. Have a nice weekend.