New library type (design discussion)
(for a long time already) I want to implement the new library type (or any other) way to do the following:
GNU ar
(with MRI file), as well as MS librarian (lib.exe
), could combine several static libs into a single one. Nowadays few of my projects use custom targets but native CMake support for this can give more flexibility (like exporting, using the result for further target_link_libraries
by name/alias, &etc.).
It should produce a static library that includes all other static libs (or OBJECT
libs, or *.o
files of the given sources) mentioned in the target_link_libraries
(ignoring dynamic libs).
Here I want to hear opinions about how to implement it:
- add a new library type to the existing
STATIC
,SHARED
... e.g. smth likeCOMBINED_STATIC
add_library( foo COMBINED_STATIC # Some sources may follow, but no sources also Ok ) target_link_libraries( foo PUBLIC bar_static another_static ... )
- implement it as a target property (e.g. setting
COMBINED
toTRUE
)add_library( foo STATIC # Some sources may follow, but no sources also Ok ) set_target_properties( foo PROPERTIES COMBINED TRUE ) ...
- maybe as a genex?
add_library( foo STATIC # Some sources may follow, but no sources also Ok ) target_link_libraries( foo PUBLIC $<COMBINE_WITH:bar_static;another_static> ... )
What do you think?