meson
meson copied to clipboard
Improve the use of both_libraries
FIxes #5452
- Internal dependency objects now carry both_libraries objects, allowing to choose either the static or the shared version of a library, at a later stage. There is now
as_static
andas_shared
methods on dependencies for that (otherwise the default is automatically used) - Added a
default_both_libraries
to configure the default behavior of both_dependencies. Previously, it was always the shared version by default. - Using the same option with 'auto' value, it is now possible to build hierarchies of both_libraries, with static dependencies for static libs, and shared dependencies for shared libs (internal dependencies only).
In my monorepo, I need to compile static and shared versions of many common libs, for different uses. For instance, I usually prefer the shared version, but for plugins, I need to compile them with static dependencies to make them independent from the version of the common libs used in the main app. With the proposed changes, I can remove a lot of duplication in my build files, by using both_libraries instead of having to duplicate shared_library and static_library, along with their respective declare_dependency.