title: How can I make a yocto layer compatible with different releases that come with incompatible lib versions
body: <p>I have a layer with recipes that is compatible with rocko. I'd like to add compatibility for thud. <code>LAYERSERIES_COMPAT_layer</code> supports a <strong>list</strong>, so supporting more than one release with a layer seems to be intended.</p>
  
  <p>Thud contains some version bumps to libraries that break compatibility. An example would be protobuf-3.6, which contains incompatible API changes to the earlier version used in rocko.</p>
  
  <p>For all packages in the layer, I have patches for their sources that make them compatible with the new API versions (only).</p>
  
  <p>Currently, there is a culture of creating different branches (or even forks) of meta-layers in order to support different library versions. This causes heavy fragmentation and deviation between the projects and departments.</p>
  
  <p>If I can create recipes that work independent of, for example, the exact version of protobuf used in a build, then I can merge back some of those forks and branches and maintain <strong>one</strong> repo.</p>
  
  <ul>
  <li><p>I tried some approach with conditional <code>.bbappend</code>, but couldn't find a way to do it. There seems to be no equivalent for COMPATIBLE_MACHINE, for example, that I could use to differentiate between releases. </p></li>
  <li><p>I also tried an approach of conditionally patching the sources depending on actual PV of a dependency. Basically trying to do what is described in the following snipped of recipe pseudo code: </p></li>
  </ul>
  
  <pre><code>DEPENDS += "protobuf"
  SRC_URI = "git://github.com/foo/bar;"
  
  if ${protobuf_PV} larger_or_equal "3.6.0"
    SRC_URI_append = " file://replace_protobuf_scoped_ptr.patch"
  endif
  </code></pre>
  
  <p>I found an existing answer here which made me doubt that this is possible: <a href="https://stackoverflow.com/questions/56794981">How can I reference/find the ${PV} of one recipe in another recipe in Yocto/Bitbake?</a></p>
  
  <p>So, what mechanisms, if any, does bitbake provide to help me make a recipe compatible with different versions of dependencies in general, and with different yocto releases in particular?</p>