title: Building install packages with shared objects and symbolic links
body: <p>I am working on a project and we are starting release binaries. We are using CMake to generate build files, and CPack to create binaries.  Our binaries work, but we run into problem with shared objects.  Essentially, many of the issues, arise from symbolic linking on the system, especially with shared objects with multiple links. So, let say the RPATH results from ldd (or otool) for some executable include libmpich.so.10 and I've linked /usr/lib/x86_64-linux-gnu/libmpich.so from cmake and these files are related like this:</p>
  
  <pre><code>/usr/lib/x86_64-linux-gnu/libmpich.so -&gt; libmpich.so.10
  /usr/lib/x86_64-linux-gnu/libmpich.so.10 -&gt; libmpich.so.10.0.4
  /usr/lib/x86_64-linux-gnu/libmpich.so.10.0.4
  </code></pre>
  
  <p>Now, for some reason the RPATH uses the intermediate link (so.10) but readlink on libmpich.so (or get_filename_component(... REALPATH)) returns libmpich.so.10.0.4.  So if I install libmpich.so.10.0.4 under the name libmpich.so OR libmpich.so.10.0.4 (or create the symlink from one to the other), I've still missed the library asked for in the RPATH.</p>
  
  <p>I've been playing whack-a-mole on when dealing with these and/or using a file glob to try to grab the intermediate link but I would like to do something more robust. Anyone use a good design pattern for this? </p>
  
  <p>I have been looking into using functions like GET_PREREQUISITES, but those require the object to be built so I would need to add them into the install scripts somehow.... and it feels like their should be a better way.</p>
  
  <p>-Jameson</p>
  
  <p>P.S. I've also bee looking for a best practices guide for building binaries, either with cmake or in general.  We are producing binaries on windows, linux and mac. If you know of some good links please post them as well.</p>