Every symbol with exernal linkage needs to be unique. You cannot have two different versions of a function with the same name in one executable.
This would only work with header only libraries that do not create any such symbol.
But it should work If you create libA as shared library instead.
The other question is if you really want to have two different versions that potentially behave differently in the same executable.
This is a big reason why bundling is bad . libA could alternatively mangle all of the libyaml symbols in its internal copy to avoid such things, but this is so rare and means that FetchContent doesn’t generally work (since the project needs patched), so it’s “never” done. If you do port it all to FetchContent, there is some mechanism to at least get all of them agreeing to use the same libyaml. Though you still have the issue if someone wants to consume myLib with their own libyaml (which may come in through otherLib) as well…